filename | src/drivers/joy_linux.c |
changeset | 1010:a506a2f66180 |
prev | 984:a01567058a47 |
next | 1296:30ecee61f811 |
author | nkeynes |
date | Sun Feb 12 16:30:26 2012 +1000 (12 years ago) |
permissions | -rw-r--r-- |
last change | Add -Werror for mregparm check, so it actually fails if mregparm isn't accepted |
file | annotate | diff | log | raw |
1.1 --- a/src/drivers/joy_linux.c Sun Feb 15 21:47:39 2009 +00001.2 +++ b/src/drivers/joy_linux.c Sun Feb 12 16:30:26 2012 +10001.3 @@ -52,6 +52,11 @@1.5 } *linux_joystick_t;1.7 +/* Linux joysticks return data in the range -32767 to 32767 - rescale this to1.8 + * -127 .. 1271.9 + */1.10 +#define SCALE_PRESSURE(x) ((x)>>8)1.11 +1.12 static gboolean linux_joystick_callback( GIOChannel *source, GIOCondition condition,1.13 gpointer data );1.14 static int linux_joystick_scan();1.15 @@ -146,21 +151,21 @@1.16 if( event.type == JS_EVENT_BUTTON ) {1.17 int keycode = event.number+1;1.18 if( event.value == 0 ) {1.19 - input_event_keyup( (input_driver_t)joy, keycode, 0 );1.20 + input_event_keyup( (input_driver_t)joy, keycode );1.21 } else {1.22 - input_event_keydown( (input_driver_t)joy, keycode, event.value );1.23 + input_event_keydown( (input_driver_t)joy, keycode, MAX_PRESSURE );1.24 }1.25 } else if( event.type == JS_EVENT_AXIS ) {1.26 int keycode = (event.number*2) + joy->button_count + 1;1.27 if( event.value == 0 ) {1.28 - input_event_keyup( (input_driver_t)joy, keycode, 0 );1.29 - input_event_keyup( (input_driver_t)joy, keycode+1, 0 );1.30 + input_event_keyup( (input_driver_t)joy, keycode );1.31 + input_event_keyup( (input_driver_t)joy, keycode+1 );1.32 } else if( event.value < 0 ) {1.33 - input_event_keydown( (input_driver_t)joy, keycode+1, -event.value );1.34 - input_event_keyup( (input_driver_t)joy, keycode, 0 );1.35 + input_event_keyup( (input_driver_t)joy, keycode );1.36 + input_event_keydown( (input_driver_t)joy, keycode+1, SCALE_PRESSURE(-event.value) );1.37 } else {1.38 - input_event_keydown( (input_driver_t)joy, keycode, event.value );1.39 - input_event_keyup( (input_driver_t)joy, keycode+1, 0 );1.40 + input_event_keyup( (input_driver_t)joy, keycode+1 );1.41 + input_event_keydown( (input_driver_t)joy, keycode, SCALE_PRESSURE(event.value) );1.42 }1.43 }1.44 }
.