diff --git a/src/input_common/sdl_input/sdl_input.cpp b/src/input_common/sdl_input/sdl_input.cpp index 6958aa473..c47f6f859 100644 --- a/src/input_common/sdl_input/sdl_input.cpp +++ b/src/input_common/sdl_input/sdl_input.cpp @@ -111,10 +111,68 @@ void SDLController::ProcessInput() { pad_id += input_event.jhat.hat * 4; switch(input_event.jhat.value) { - case SDL_HAT_LEFT: break; - case SDL_HAT_RIGHT: pad_id += 1; break; - case SDL_HAT_UP: pad_id += 2; break; - case SDL_HAT_DOWN: pad_id += 3; break; + case SDL_HAT_CENTERED: + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+1, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+2, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+3, joypad_id}).hex; + break; + + case SDL_HAT_LEFT: + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+1, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+2, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+3, joypad_id}).hex; + break; + + case SDL_HAT_LEFTUP: + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+1, joypad_id}).hex; + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id+2, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+3, joypad_id}).hex; + break; + + case SDL_HAT_LEFTDOWN: + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+1, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+2, joypad_id}).hex; + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id+3, joypad_id}).hex; + break; + + case SDL_HAT_RIGHT: + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id, joypad_id}).hex; + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id+1, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+2, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+3, joypad_id}).hex; + break; + + case SDL_HAT_RIGHTUP: + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id, joypad_id}).hex; + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id+1, joypad_id}).hex; + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id+2, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+3, joypad_id}).hex; + break; + + case SDL_HAT_RIGHTDOWN: + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id, joypad_id}).hex; + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id+1, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+2, joypad_id}).hex; + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id+3, joypad_id}).hex; + break; + + case SDL_HAT_UP: + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+1, joypad_id}).hex; + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id+2, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+3, joypad_id}).hex; + break; + + case SDL_HAT_DOWN: + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+1, joypad_id}).hex; + controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+2, joypad_id}).hex; + controller.pad_state.hex |= KeyMap::GetPadKey({pad_id+3, joypad_id}).hex; + break; } break;