Mercurial > repos > blastem
diff render_sdl.c @ 1804:34370330eaf3
Support controllers that have their dpad mapped to an axis
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 26 Mar 2019 23:26:08 -0700 |
parents | ed6c38cd288c |
children | c2057d79998c |
line wrap: on
line diff
--- a/render_sdl.c Tue Mar 26 22:34:41 2019 -0700 +++ b/render_sdl.c Tue Mar 26 23:26:08 2019 -0700 @@ -1864,6 +1864,7 @@ } SDL_GameControllerButtonBind cbind; + int32_t is_positive = RENDER_AXIS_POS; if (is_axis) { int sdl_axis = render_lookup_axis(name); @@ -1878,6 +1879,10 @@ SDL_GameControllerClose(control); return RENDER_INVALID_NAME; } + if (sdl_button == SDL_CONTROLLER_BUTTON_DPAD_UP || sdl_button == SDL_CONTROLLER_BUTTON_DPAD_LEFT) { + //assume these will be negative if they are an axis + is_positive = 0; + } cbind = SDL_GameControllerGetBindForButton(control, sdl_button); } SDL_GameControllerClose(control); @@ -1886,7 +1891,7 @@ case SDL_CONTROLLER_BINDTYPE_BUTTON: return cbind.value.button; case SDL_CONTROLLER_BINDTYPE_AXIS: - return RENDER_AXIS_BIT | cbind.value.axis; + return RENDER_AXIS_BIT | cbind.value.axis | is_positive; case SDL_CONTROLLER_BINDTYPE_HAT: return RENDER_DPAD_BIT | (cbind.value.hat.hat << 4) | cbind.value.hat.hat_mask; }