View Single Post
Old 01-10-2007, 09:20 PM   #9
sama
FLAC
sama's CarPC Specs
 
sama's Avatar
 
Join Date: Feb 2006
Location: London, UK
Vehicle: BMW 850CSi
Posts: 1,280
My Photos: ()
ok, say you get two lines back that look like this:

Code:
1 8 0 161 255 251 255 2 245 255 0 0 238 255

you organise this as follows:

Code:
[0] [1] [2] [3] [4] [5] [6] 1 8 0 161 255 251 255 [0] [1] [2] [3] [4] [5] [6] 2 245 255 0 0 238 255


and this by using the table below, you can determine the stick's position.


Code:
pan left/right axis value from 1[1] right: 2[1] = 0 left : 2[1] = 255 pan fwd/back axis value from 3[1] back : 4[1] = 0 fwd : 4[1] = 255 push/pull axis value from 5[1] push : 6[1] = 0 pull : 6[1] = 255 tilt fwd/back axis value from 1[2] back : 2[2] = 0 fwd : 2[2] = 255 tilt left/right axis value from 3[2] left : 4[2] = 0 right: 4[2] = 255 twist axis value from 5[2] right: 6[2] = 0 left : 6[2] = 255


And finally, buttons are on lines that start with a 3, and they are:

Quote:
3 1 0 0 0 0 0 Left Button
3 2 0 0 0 0 0 Right Buton
3 3 0 0 0 0 0 Both Buttons


Just need to tidy the code now so each axis value ranges from -255 to +255, with a 2 bit modifier to indicate button state (0=none, 1 = left, 2 = right, 3 = both).


Damn, I need to sleep. I have to wake up in 5 hours!
__________________
///Mputer - Velocity - TomTom - Vision - Bezel - CarPC
sama is offline   Reply With Quote