1. Opening Devices & Joystick Input
- Posted by Andy Feb 18, 2009
- 989 views
- Last edited Feb 19, 2009
Hey Guys,
I know you can use the open command to open files and devices, but I was wondering how you would get a device from the USB port, like if you had a USB joystick, how would you get data from the device and stuff? I know you use the open command, but I'm not sure how to go about it. Any help? Example code would be nice.
2. Re: Opening Devices & Joystick Input
- Posted by DanM Feb 18, 2009
- 1010 views
- Last edited Feb 19, 2009
Hey Guys,
I know you can use the open command to open files and devices, but I was wondering how you would get a device from the USB port, like if you had a USB joystick, how would you get data from the device and stuff? I know you use the open command, but I'm not sure how to go about it. Any help? Example code would be nice.
A look in the archives under "joystick" yields:
http://www.rapideuphoria.com/winjoy.zip
I know I've used a USB joystick in an app, but I don't think it was the above lib that I used; it's possible that there might be a demo from Win32Lib that also lets you use USB joystick, I'm not sure. But give the above a try & see if it lets you do what you want. If not, let us know & I'll look for what I did, don't know where it is right now though.
It is, btw, always a good bet to look first in the archives
Dan
3. Re: Opening Devices & Joystick Input
- Posted by Andy Feb 19, 2009
- 992 views
Hey Guys,
I know you can use the open command to open files and devices, but I was wondering how you would get a device from the USB port, like if you had a USB joystick, how would you get data from the device and stuff? I know you use the open command, but I'm not sure how to go about it. Any help? Example code would be nice.
A look in the archives under "joystick" yields:
http://www.rapideuphoria.com/winjoy.zip
I know I've used a USB joystick in an app, but I don't think it was the above lib that I used; it's possible that there might be a demo from Win32Lib that also lets you use USB joystick, I'm not sure. But give the above a try & see if it lets you do what you want. If not, let us know & I'll look for what I did, don't know where it is right now though.
It is, btw, always a good bet to look first in the archives
Dan
Alright, thanks, I'll check it out
4. Re: Opening Devices & Joystick Input
- Posted by DanM Feb 19, 2009
- 973 views
Turns out the aforementioned lib (or earlier version?) IS what I used, you can get buttons off the joystick too. May have to play with values and methods, tho. One thing I did mention in my app is that the query for available joysticks on system didn't work right on XP system, as follows (with fix):
-- JOYSTICK INPUT STUFF: include joy.ew object void if joy_init()=0 then puts(1,"No joystick(s) attached!") abort(0) end if -- NOTE: BOTH ABOVE AND THIS DO *NOT* WORK ON XP, SHOWS 1 CONNECTED WHEN NONE IS! puts(1, "number of joysticks attached: " & sprint(joy_init()) & "\n") -- these DO work: sequence joy_info,s integer button_mask joy_info = {} s = joy_get_state(1) --DM THIS MAKES QUIT IF NO JOYSTICK FOUND ON XP SYSTEM. if equal(s, {}) then puts(1, "no joystick connected.\n") puts(1, "press any key to exit; then attach a joystick to a USB port") void= wait_key() abort(0) end if
I'm pretty sure that the demo with the lib does show more about how to use it.
Dan
5. Re: Opening Devices & Joystick Input
- Posted by Andy Feb 19, 2009
- 956 views
Turns out the aforementioned lib (or earlier version?) IS what I used, you can get buttons off the joystick too. May have to play with values and methods, tho. One thing I did mention in my app is that the query for available joysticks on system didn't work right on XP system, as follows (with fix):
-- JOYSTICK INPUT STUFF: include joy.ew object void if joy_init()=0 then puts(1,"No joystick(s) attached!") abort(0) end if -- NOTE: BOTH ABOVE AND THIS DO *NOT* WORK ON XP, SHOWS 1 CONNECTED WHEN NONE IS! puts(1, "number of joysticks attached: " & sprint(joy_init()) & "\n") -- these DO work: sequence joy_info,s integer button_mask joy_info = {} s = joy_get_state(1) --DM THIS MAKES QUIT IF NO JOYSTICK FOUND ON XP SYSTEM. if equal(s, {}) then puts(1, "no joystick connected.\n") puts(1, "press any key to exit; then attach a joystick to a USB port") void= wait_key() abort(0) end if
I'm pretty sure that the demo with the lib does show more about how to use it.
Dan
Well the joystick library helps. But I was wondering how I'd go about getting input and info from an Xbox360 controller.
6. Re: Opening Devices & Joystick Input
- Posted by bernie Feb 19, 2009
- 959 views
Well the joystick library helps. But I was wondering how I'd go about getting input and info from an Xbox360 controller.
In order to control a device on the windows operating system;
a device driver for that device must be installed on windows.
I do not think there is a device driver written for windows using
an xbox360 controler.
Unless you write your own or find one written by someone else
your out of luck.
If the device was a serial or parallel device it would be much simpler.
7. Re: Opening Devices & Joystick Input
- Posted by DanM Feb 19, 2009
- 1070 views
Well the joystick library helps. But I was wondering how I'd go about getting input and info from an Xbox360 controller.
Googling Xbox360 controller yields:
http://www.microsoft.com/hardware/gaming/ProductDetails.aspx?pid=091
which suggests that there is a xbox360 controller that will work with both the xbox AND windows computers. Whether this is a different controller than one shipped with xbox, I have no idea.
Here's another Googled link that might be important with regard to drivers and actually using it, but the web site is somewhat hard to read:
http://mattbrett.com/2005/11/configuring-your-xbox-360-controller-for-windows/
Dan
8. Re: Opening Devices & Joystick Input
- Posted by DanM Feb 19, 2009
- 1044 views
- Last edited Feb 20, 2009
Well the joystick library helps. But I was wondering how I'd go about getting input and info from an Xbox360 controller.
Googling Xbox360 controller yields:
http://www.microsoft.com/hardware/gaming/ProductDetails.aspx?pid=091
which suggests that there is a xbox360 controller that will work with both the xbox AND windows computers. Whether this is a different controller than one shipped with xbox, I have no idea.
Here's another Googled link that might be important with regard to drivers and actually using it, but the web site is somewhat hard to read:
http://mattbrett.com/2005/11/configuring-your-xbox-360-controller-for-windows/
Dan
And then there's this too:
http://www.redcl0ud.com/xbcd.html
and:
http://xbcd360guide.50webs.com/
hope that helps, that's all I can do relative to gaming.
Dan
9. Re: Opening Devices & Joystick Input
- Posted by Andy Feb 19, 2009
- 998 views
- Last edited Feb 20, 2009
Well the joystick library helps. But I was wondering how I'd go about getting input and info from an Xbox360 controller.
Googling Xbox360 controller yields:
http://www.microsoft.com/hardware/gaming/ProductDetails.aspx?pid=091
which suggests that there is a xbox360 controller that will work with both the xbox AND windows computers. Whether this is a different controller than one shipped with xbox, I have no idea.
Here's another Googled link that might be important with regard to drivers and actually using it, but the web site is somewhat hard to read:
http://mattbrett.com/2005/11/configuring-your-xbox-360-controller-for-windows/
Dan
And then there's this too:
http://www.redcl0ud.com/xbcd.html
and:
http://xbcd360guide.50webs.com/
hope that helps, that's all I can do relative to gaming.
Dan
Thanks, I know the 360 controller works on windows, I've already used it with other apps. I'd just like to use it with Euphoria or rather make library in Euphoria to use it with Euphoria.