Added support for hat input aka 'dpads'
This commit is contained in:
parent
d1d04df937
commit
c736bc2572
1 changed files with 62 additions and 4 deletions
|
@ -111,10 +111,68 @@ void SDLController::ProcessInput() {
|
||||||
pad_id += input_event.jhat.hat * 4;
|
pad_id += input_event.jhat.hat * 4;
|
||||||
|
|
||||||
switch(input_event.jhat.value) {
|
switch(input_event.jhat.value) {
|
||||||
case SDL_HAT_LEFT: break;
|
case SDL_HAT_CENTERED:
|
||||||
case SDL_HAT_RIGHT: pad_id += 1; break;
|
controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id, joypad_id}).hex;
|
||||||
case SDL_HAT_UP: pad_id += 2; break;
|
controller.pad_state.hex &= ~KeyMap::GetPadKey({pad_id+1, joypad_id}).hex;
|
||||||
case SDL_HAT_DOWN: pad_id += 3; break;
|
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;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue