// handle joystick motion events
case SDL_JOYAXISMOTION:
// initialize all joystick variables
eventStates[ JOYSTICK_UP ] = 0;
eventStates[ JOYSTICK_DOWN ] = 0;
eventStates[ JOYSTICK_RIGHT ] = 0;
eventStates[ JOYSTICK_LEFT ] = 0;
// check left-right movement
if( event->jaxis.axis == 0 )
{
// if joystick moving left
if ( event->jaxis.value < -800 )
{
// move left
eventStates[ JOYSTICK_LEFT ] = 1;
}
// if joystick moving right
else if ( event->jaxis.value > 800 )
{
// move right
eventStates[ JOYSTICK_RIGHT ] = 1;
}
}
// check up-down movement
if( event->jaxis.axis == 1 )
{
// if joystick moving up
if ( event->jaxis.value < -800 )
{
// move up
eventStates[ JOYSTICK_UP ] = 1;
}
// if joystick moving down
else if ( event->jaxis.value > 800 )
{
// move down
eventStates[ JOYSTICK_DOWN ] = 1;
}
}
eventStates[ JOYSTICK_SCALE ] = event->jaxis.value;
break;
my joystick event states are one directional. is it possible to get diagonal states in SDL?
something like this: joystick mapping
Edited by hikarihe, 28 February 2013 - 09:11 PM.






