Joystick API

  • Thread starter Thread starter Jack Russell
  • Start date Start date
J

Jack Russell

Can anyone give me an example of using joygetdevcaps and joygetposex in
vb.net. I have no problem in VB6 but get various exceptions, memory
violations in .net. I have (I think converted all the longs to integers
etc)

Thanks

Jack Russell
 
Can anyone give me an example of using joygetdevcaps and joygetposex in
vb.net. I have no problem in VB6 but get various exceptions, memory
violations in .net. I have (I think converted all the longs to integers
etc)

Thanks

Jack Russell

Wow, surprisingly nothing show up for either function on pinvoke.net.
Perhaps you could post the API's so we could take a look at the
original, and your new declarations.

Thanks,

Seth Rowe
 
Can anyone give me an example of using joygetdevcaps and joygetposex in
vb.net. I have no problem in VB6 but get various exceptions, memory
violations in .net. I have (I think converted all the longs to integers
etc)

Have you taken a look at managed direct x? You could try using DirectInput?
 
Spam said:
@TK2MSFTNGP05.phx.gbl:




Have you taken a look at managed direct x? You could try using DirectInput?
I am using Express versions which I understand do not support Direct X

Jack Russell
 
I am using Express versions which I understand do not support Direct X

DirectX is an additional download. The Managed SDK is inside the SDK along
with associated documentation and samples.
 
Spam said:
@TK2MSFTNGP05.phx.gbl:




DirectX is an additional download. The Managed SDK is inside the SDK along
with associated documentation and samples.
Thanks, I will take a look

Jack
 
rowe_newsgroups said:
Wow, surprisingly nothing show up for either function on pinvoke.net.
Perhaps you could post the API's so we could take a look at the
original, and your new declarations.

Thanks,

Seth Rowe
Still struggling although have found I can make it work (VB6 needs the
structures passed by val, .net by ref).

However I need the following structure

Private Type JOYCAPS
wMid As Integer
wPid As Integer
szPname As String *32
wXmin As Long
wXmax As Long
wYmin As Long
wYmax As Long
wZmin As Long
wZmax As Long
wNumButtons As Long
wPeriodMin As Long
wPeriodMax As Long
End Type

How do I do the string in .net (I know to change the type to a
structure). The only way I have found is to pad it with integers
although strangely not to the length that I would have expected!
 
Jack Russell said:
Still struggling although have found I can make it work (VB6 needs
the structures passed by val, .net by ref).

The API function needs them "ByRef", in VB6 as well as in VB.Net. If you
don't specify anything in VB6, it defaults to ByRef.
However I need the following structure

Private Type JOYCAPS
wMid As Integer
wPid As Integer
szPname As String *32
wXmin As Long
wXmax As Long
wYmin As Long
wYmax As Long
wZmin As Long
wZmax As Long
wNumButtons As Long
wPeriodMin As Long
wPeriodMax As Long
End Type

How do I do the string in .net (I know to change the type to a
structure). The only way I have found is to pad it with integers
although strangely not to the length that I would have expected!

What's your current VB.Net declaration?


Armin
 
Armin said:
The API function needs them "ByRef", in VB6 as well as in VB.Net. If you
don't specify anything in VB6, it defaults to ByRef.
I agree with you, it is just that the sample program I found on the net
had them byval and it worked in VB^. Maybe VB6 is cleverer than we thought!
What's your current VB.Net declaration?


Armin
I got it to work after finding this in a sample program (unfortunately I
cannot get Help to tell me what it means).

<StructLayout(LayoutKind.Sequential)> _
Private Structure JOYCAPS
Dim wMid As Int16
Dim wPid As Int16
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)> _
Dim szPname As String ' * MAXPNAMELEN
Dim wXmin As Integer
Dim wXmax As Integer
Dim wYmin As Integer
Dim wYmax As Integer
Dim wZmin As Integer
Dim wZmax As Integer
Dim wNumButtons As Integer
Dim wPeriodMin As Integer
Dim wPeriodMax As Integer
End Structure
 
Back
Top