diff --git a/gl.c b/gl.c index 2ebb87c7..1803d8a7 100644 --- a/gl.c +++ b/gl.c @@ -2,7 +2,11 @@ #include #include -#include +#if defined(__arm__) + #include +#else + #include +#endif #include "gl_platform.h" #include "gl.h" diff --git a/gl_platform.c b/gl_platform.c index d5f0c201..0f03dbc2 100644 --- a/gl_platform.c +++ b/gl_platform.c @@ -1,7 +1,11 @@ #include #include #include -#include +#if defined(__arm__) + #include +#else + #include +#endif #include "gl.h" #include "gl_platform.h" diff --git a/in_sdl.c b/in_sdl.c index 046f92dc..852fdffd 100644 --- a/in_sdl.c +++ b/in_sdl.c @@ -300,6 +300,34 @@ static int handle_joy_event(struct in_sdl_state *state, SDL_Event *event, } break; + case SDL_JOYHATMOTION: + if (event->jhat.which != state->joy_id) + return -2; + if (event->jhat.value == SDL_HAT_CENTERED) { + kc = state->axis_keydown[event->jhat.hat]; + state->axis_keydown[event->jhat.hat] = 0; + ret = 1; + } + else if (event->jhat.value & SDL_HAT_UP || event->jhat.value & SDL_HAT_LEFT) { + kc = state->axis_keydown[event->jhat.hat]; + if (kc) + update_keystate(state->keystate, kc, 0); + kc = (event->jhat.value & SDL_HAT_UP) ? SDLK_UP : SDLK_LEFT; + state->axis_keydown[event->jhat.hat] = kc; + down = 1; + ret = 1; + } + else if (event->jhat.value & SDL_HAT_DOWN || event->jhat.value & SDL_HAT_RIGHT) { + kc = state->axis_keydown[event->jhat.hat]; + if (kc) + update_keystate(state->keystate, kc, 0); + kc = (event->jhat.value & SDL_HAT_DOWN) ? SDLK_DOWN : SDLK_RIGHT; + state->axis_keydown[event->jhat.hat] = kc; + down = 1; + ret = 1; + } + break; + case SDL_JOYBUTTONDOWN: case SDL_JOYBUTTONUP: if (event->jbutton.which != state->joy_id)