mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-17 18:40:02 +00:00
Fix SDL_GAMECONTROLLER handling
1. Do not disable SDL_JOYSTICK events. Disabling these events causes game controller events to be disabled as well. Instead, filter these events out. 2. Fix button mapping (it was off by one).
This commit is contained in:
parent
a92b310e0e
commit
5a36a26dd1
@ -390,20 +390,24 @@ static void SDLash_EventFilter( SDL_Event *event )
|
||||
|
||||
/* Joystick events */
|
||||
case SDL_JOYAXISMOTION:
|
||||
Joy_AxisMotionEvent( event->jaxis.axis, event->jaxis.value );
|
||||
if ( SDL_GameControllerFromInstanceID( event->jaxis.which ) == NULL )
|
||||
Joy_AxisMotionEvent( event->jaxis.axis, event->jaxis.value );
|
||||
break;
|
||||
|
||||
case SDL_JOYBALLMOTION:
|
||||
Joy_BallMotionEvent( event->jball.ball, event->jball.xrel, event->jball.yrel );
|
||||
if ( SDL_GameControllerFromInstanceID( event->jball.which ) == NULL )
|
||||
Joy_BallMotionEvent( event->jball.ball, event->jball.xrel, event->jball.yrel );
|
||||
break;
|
||||
|
||||
case SDL_JOYHATMOTION:
|
||||
Joy_HatMotionEvent( event->jhat.hat, event->jhat.value );
|
||||
if ( SDL_GameControllerFromInstanceID( event->jhat.which ) == NULL )
|
||||
Joy_HatMotionEvent( event->jhat.hat, event->jhat.value );
|
||||
break;
|
||||
|
||||
case SDL_JOYBUTTONDOWN:
|
||||
case SDL_JOYBUTTONUP:
|
||||
Joy_ButtonEvent( event->jbutton.button, event->jbutton.state );
|
||||
if ( SDL_GameControllerFromInstanceID( event->jbutton.which ) == NULL )
|
||||
Joy_ButtonEvent( event->jbutton.button, event->jbutton.state );
|
||||
break;
|
||||
|
||||
case SDL_QUIT:
|
||||
@ -514,7 +518,7 @@ static void SDLash_EventFilter( SDL_Event *event )
|
||||
|
||||
// TODO: Use joyinput funcs, for future multiple gamepads support
|
||||
if( Joy_IsActive() )
|
||||
Key_Event( sdlControllerButtonToEngine[event->cbutton.button], event->cbutton.state );
|
||||
Key_Event( sdlControllerButtonToEngine[event->cbutton.button + 1], event->cbutton.state );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,6 @@ static int SDLash_JoyInit_New( int numjoy )
|
||||
SDL_GameControllerGetProductVersion( gamecontroller ));
|
||||
#endif // SDL_VERSION_ATLEAST( 2, 0, 6 )
|
||||
SDL_GameControllerEventState( SDL_ENABLE );
|
||||
SDL_JoystickEventState( SDL_DISABLE );
|
||||
|
||||
return num;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user