nls-archive
[Top] [All Lists]

[nls-archive] joystick event handler

To: Brian Cardanha <brian_cardanha@yahoo.com>
Cc: nls-archive@chm.cim3.net
From: Jonathan Cheyer <jonathan@cheyer.biz>
Date: Thu, 05 Jan 2006 03:28:10 -0800
Message-id: <43BD02CA.7020503@cheyer.biz>
Hi Brian,    (01)

I managed to write some C code to do basic event handling for the analog 
gameport joystick, connecting through USB.    (02)

It works as I was hoping, namely that the USB stuff is transparent, and 
  when I read from the /dev/input/js0 device, the standard linux 
joystick driver gives me back values in that simple data structure I 
mentioned to you earlier.    (03)

It pretty much just keeps sending values continually, but I can build my 
own event handler just by storing the state of the previous values and 
comparing when they change.    (04)

For now, I have the event handler program tracking (x,y) values as they 
change, and also when the button0 and button1 is pressed or released (my 
joystick has two buttons). Since the events are independent, I can tell 
when either or both buttons are pressed and released.    (05)

The good news is that the joystick driver code appears to support up to 
32 buttons. So I think we may not even need to do anything special with 
mapping the chord keyset keys to x or y coordinates. It should be 
possible to map all five keyset keys directly, although I don't know 
what bits need to be sent at a hardware level in order for the driver to 
recognize them as the first five buttons instead of coordinates.    (06)

--Jon    (07)
<Prev in Thread] Current Thread [Next in Thread>
  • [nls-archive] joystick event handler, Jonathan Cheyer <=