all repos — mgba @ c69c34ab2d419fa5ca605094e4afbb8f9e406a47

mGBA Game Boy Advance Emulator

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
commit

c69c34ab2d419fa5ca605094e4afbb8f9e406a47

parent

78ef8523ac3c49ccce9108427895dfd49cd829ce

1 files changed, 6 insertions(+), 0 deletions(-)

jump to
M src/platform/sdl/sdl-events.csrc/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);