[Gambas-user] Gambas class to read a joystick

Rob sourceforge-raindog2 at ...94...
Sun Mar 2 23:36:43 CET 2008


Someone on linuxbasic.net asked for a way to read a joystick in 
Gambas.  I couldn't find anything in the SDL component for that 
purpose, so I wrote a minimal class that reads from the raw device, 
parses the data into something useful, and throws events.  I wrote a 
program to demonstrate it as well.

To make it work, I had to EXEC ["cat", device] instead of just OPEN 
device FOR READ WATCH.  Gambas told me "System error: Invalid 
argument" every time the File_Read event fired and I tried to read 
from the file handle, even though the example makes it look like it 
works with device nodes.  I'm sure there's a better way to do this, 
but ultimately gb.sdl should probably have joystick support anyway 
(and if I were more familiar with SDL, I would have done that instead 
of this.)  Nonetheless, this works.

In case the archived version of the list doesn't store attachments, 
it's also available at http://www.kudla.org/jstest-0.0.2.tar.gz for 
future reference.

Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: jstest-0.0.2.tar.gz
Type: application/x-tgz
Size: 6731 bytes
Desc: not available
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20080302/09fb6d01/attachment.bin>


More information about the User mailing list