By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,083 Members | 1,274 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,083 IT Pros & Developers. It's quick & easy.

Joystick API

P: n/a
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
Oct 4 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Oct 4, 4:06 am, Jack Russell <ja...@norubbish.tpg.com.auwrote:
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

Oct 4 '07 #2

P: n/a
Jack Russell <ja***@norubbish.tpg.com.auwrote in news:O4HMq1lBIHA.3848
@TK2MSFTNGP05.phx.gbl:
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?
Oct 4 '07 #3

P: n/a
Spam Catcher wrote:
Jack Russell <ja***@norubbish.tpg.com.auwrote in news:O4HMq1lBIHA.3848
@TK2MSFTNGP05.phx.gbl:

>>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?
I am using Express versions which I understand do not support Direct X

Jack Russell
Oct 4 '07 #4

P: n/a
rowe_newsgroups wrote:
On Oct 4, 4:06 am, Jack Russell <ja...@norubbish.tpg.com.auwrote:
>>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
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!
Oct 8 '07 #5

P: n/a
"Jack Russell" <ja***@norubbish.tpg.com.auschrieb
rowe_newsgroups wrote:
On Oct 4, 4:06 am, Jack Russell <ja...@norubbish.tpg.com.au>
wrote:
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
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

Oct 8 '07 #6

P: n/a
Armin Zingler wrote:
"Jack Russell" <ja***@norubbish.tpg.com.auschrieb
>rowe_newsgroups wrote:
On Oct 4, 4:06 am, Jack Russell <ja...@norubbish.tpg.com.au>
wrote:

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
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.
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!
>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
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
Oct 8 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.