Clarified Axis keys using constants.

This commit is contained in:
evilynux 2007-01-17 20:42:51 +00:00
parent abe99a1e16
commit 29a1eef1de
1 changed files with 8 additions and 7 deletions

View File

@ -231,32 +231,33 @@ u16 process_ctrls_events(u16 keypad)
{ {
switch (event.type) switch (event.type)
{ {
/* Joystick axis motion */ /* Joystick axis motion
Note: button constants have a 1bit offset. */
case SDL_JOYAXISMOTION: case SDL_JOYAXISMOTION:
/* Horizontal */ /* Horizontal */
if (event.jaxis.axis == 0) if (event.jaxis.axis == 0)
if( event.jaxis.value == 0 ) if( event.jaxis.value == 0 )
{ {
key = KEYMASK_( 4 ) | KEYMASK_( 5 ); key = KEYMASK_( KEY_RIGHT-1 ) | KEYMASK_( KEY_LEFT-1 );
RM_KEY( keypad, key ); RM_KEY( keypad, key );
} }
else else
{ {
if( event.jaxis.value > 0 ) key = KEYMASK_( 4 ); if( event.jaxis.value > 0 ) key = KEYMASK_( KEY_RIGHT-1 );
else key = KEYMASK_( 5 ); else key = KEYMASK_( KEY_LEFT-1 );
ADD_KEY( keypad, key ); ADD_KEY( keypad, key );
} }
/* Vertical */ /* Vertical */
else if (event.jaxis.axis == 1) else if (event.jaxis.axis == 1)
if( event.jaxis.value == 0 ) if( event.jaxis.value == 0 )
{ {
key = KEYMASK_( 6 ) | KEYMASK_( 7 ); key = KEYMASK_( KEY_UP-1 ) | KEYMASK_( KEY_DOWN-1 );
RM_KEY( keypad, key ); RM_KEY( keypad, key );
} }
else else
{ {
if( event.jaxis.value > 0 ) key = KEYMASK_( 7 ); if( event.jaxis.value > 0 ) key = KEYMASK_( KEY_DOWN-1 );
else key = KEYMASK_( 6 ); else key = KEYMASK_( KEY_UP-1 );
ADD_KEY( keypad, key ); ADD_KEY( keypad, key );
} }
break; break;