SDL: Fix crash when attempting to sample sensors with no controller attached
Jeffrey Pfau jeffrey@endrift.com
Sun, 31 Jan 2016 23:52:03 -0800
1 files changed,
6 insertions(+),
0 deletions(-)
jump to
M
src/platform/sdl/sdl-events.c
→
src/platform/sdl/sdl-events.c
@@ -599,6 +599,9 @@ }
#endif static int32_t _readTilt(struct GBASDLPlayer* player, int axis) { + if (!player->joystick) { + return 0; + } return SDL_JoystickGetAxis(player->joystick->joystick, axis) * 0x3800; }@@ -621,6 +624,9 @@
static void _GBASDLRotationSample(struct GBARotationSource* source) { struct GBASDLRotation* rotation = (struct GBASDLRotation*) source; SDL_JoystickUpdate(); + if (!rotation->p->joystick) { + return; + } int x = SDL_JoystickGetAxis(rotation->p->joystick->joystick, rotation->gyroX); int y = SDL_JoystickGetAxis(rotation->p->joystick->joystick, rotation->gyroY);