TechTalkz.com Logo Ask the Experts!

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > VB.NET

Joystick API

VB.NET

 
 
Thread Tools Display Modes
Unread 04-10-2007, 09:00 AM   #1
Jack Russell
Guest
 
Posts: n/a
Joystick API

Can anyone give me an example of using joygetdevcaps and joygetpo*** 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
 
Unread 04-10-2007, 11:02 AM   #2
rowe_newsgroups
Guest
 
Posts: n/a
Re: Joystick API

On Oct 4, 4:06 am, Jack Russell <ja...@norubbish.tpg.com.au> wrote:
> Can anyone give me an example of using joygetdevcaps and joygetpo*** 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

 
Unread 04-10-2007, 07:16 PM   #3
Spam Catcher
Guest
 
Posts: n/a
Re: Joystick API

Jack Russell <jackr@norubbish.tpg.com.au> wrote in news:O4HMq1lBIHA.3848
@TK2MSFTNGP05.phx.gbl:

> Can anyone give me an example of using joygetdevcaps and joygetpo*** 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?
 
Unread 04-10-2007, 09:10 PM   #4
Jack Russell
Guest
 
Posts: n/a
Re: Joystick API

Spam Catcher wrote:
> Jack Russell <jackr@norubbish.tpg.com.au> wrote in news:O4HMq1lBIHA.3848
> @TK2MSFTNGP05.phx.gbl:
>
>
>>Can anyone give me an example of using joygetdevcaps and joygetpo*** 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
 
Unread 04-10-2007, 09:10 PM   #5
Spam Catcher
Guest
 
Posts: n/a
Re: Joystick API

Jack Russell <jackr@norubbish.tpg.com.au> wrote in news:OHsBZPsBIHA.912
@TK2MSFTNGP05.phx.gbl:

> 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.
 
Unread 05-10-2007, 12:03 AM   #6
Jack Russell
Guest
 
Posts: n/a
Re: Joystick API

Spam Catcher wrote:
> Jack Russell <jackr@norubbish.tpg.com.au> wrote in news:OHsBZPsBIHA.912
> @TK2MSFTNGP05.phx.gbl:
>
>
>>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.

Thanks, I will take a look

Jack
 
Unread 08-10-2007, 12:59 AM   #7
Jack Russell
Guest
 
Posts: n/a
Re: Joystick API

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 joygetpo*** 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!
 
Unread 08-10-2007, 08:06 AM   #8
Armin Zingler
Guest
 
Posts: n/a
Re: Joystick API

"Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
> 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
> > > joygetpo*** 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

 
Unread 08-10-2007, 10:02 AM   #9
Jack Russell
Guest
 
Posts: n/a
Re: Joystick API

Armin Zingler wrote:
> "Jack Russell" <jackr@norubbish.tpg.com.au> schrieb
>
>> 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
>> > > joygetpo*** 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
 
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Joystick stops working from one day to the other Martin Windows Vista All 1 19-10-2007 03:01 AM
K750i Joystick failure rate Rab Sony Ericsson 6 15-09-2007 03:14 PM
Joystick / games port support Jack Russell VB.NET 2 15-09-2007 05:05 AM
Re: strange behaviour of USB joystick Ruud Windows XP 0 16-08-2007 03:46 PM
A samsung phone with optical joystick. CorpoAlert Mobile Phones & Gadgets 0 19-12-2006 04:48 PM


< Home - Windows Help - MS Office Help - Hardware Support >


New To Site? Need Help?

All times are GMT. The time now is 08:30 AM.


vBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2013, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional