diff options
Diffstat (limited to 'runtime/shims/gameinput.cpp')
| -rw-r--r-- | runtime/shims/gameinput.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/runtime/shims/gameinput.cpp b/runtime/shims/gameinput.cpp index 4a42afbcf..9bd7be94a 100644 --- a/runtime/shims/gameinput.cpp +++ b/runtime/shims/gameinput.cpp | |||
| @@ -1180,7 +1180,40 @@ void fill_info(Device* d, SDL_Gamepad* p, const AppLocalDeviceId& id) { | |||
| 1180 | d->button_info[b].mappedInputKinds = GameInputKindGamepad; | 1180 | d->button_info[b].mappedInputKinds = GameInputKindGamepad; |
| 1181 | d->button_info[b].legacyHidIndex = static_cast<uint16_t>(b); | 1181 | d->button_info[b].legacyHidIndex = static_cast<uint16_t>(b); |
| 1182 | d->button_info[b].legacyDInputIndex = static_cast<uint16_t>(b); | 1182 | d->button_info[b].legacyDInputIndex = static_cast<uint16_t>(b); |
| 1183 | } | 1183 | d->button_info[b].label = GameInputLabelUnknown; // paddles, touchpad, misc: no gamepad meaning to name |
| 1184 | } | ||
| 1185 | // Labels. Every pad is presented as an Xbox One pad (docs/gameinput.md), so every control carries the Xbox label | ||
| 1186 | // of its position, whatever is printed on the pad in the player's hands. A stick axis has no label in v0, so | ||
| 1187 | // only the triggers are named. UI navigation names the controls read_pad reads it from; scrolling is the right | ||
| 1188 | // stick, which has none. | ||
| 1189 | const GameInputLabel face[4] = {GameInputLabelXboxA, GameInputLabelXboxB, GameInputLabelXboxX, | ||
| 1190 | GameInputLabelXboxY}; | ||
| 1191 | const GameInputLabel menu = GameInputLabelXboxMenu, view = GameInputLabelXboxView; | ||
| 1192 | const GameInputLabel up = GameInputLabelXboxDPadUp, down = GameInputLabelXboxDPadDown; | ||
| 1193 | const GameInputLabel left = GameInputLabelXboxDPadLeft, right = GameInputLabelXboxDPadRight; | ||
| 1194 | const GameInputLabel lb = GameInputLabelXboxLeftShoulder, rb = GameInputLabelXboxRightShoulder; | ||
| 1195 | const GameInputLabel ls = GameInputLabelXboxLeftStickButton, rs = GameInputLabelXboxRightStickButton; | ||
| 1196 | const GameInputLabel lt = GameInputLabelXboxLeftTrigger, rt = GameInputLabelXboxRightTrigger; | ||
| 1197 | const GameInputLabel none = GameInputLabelNone; | ||
| 1198 | d->gamepad_info = {menu, view, face[0], face[1], face[2], face[3], up, down, left, right, lb, rb, ls, rs}; | ||
| 1199 | d->ui_info = {menu, view, face[0], face[1], up, down, left, right, face[2], face[3], ls, rs, lt, rt, lb, rb, | ||
| 1200 | none, none, none, none, GameInputLabelXboxGuide}; | ||
| 1201 | d->axis_info[4].label = lt; | ||
| 1202 | d->axis_info[5].label = rt; | ||
| 1203 | const struct { | ||
| 1204 | SDL_GamepadButton sdl; | ||
| 1205 | GameInputLabel label; | ||
| 1206 | } labelled[] = { | ||
| 1207 | {SDL_GAMEPAD_BUTTON_SOUTH, face[0]}, {SDL_GAMEPAD_BUTTON_EAST, face[1]}, | ||
| 1208 | {SDL_GAMEPAD_BUTTON_WEST, face[2]}, {SDL_GAMEPAD_BUTTON_NORTH, face[3]}, | ||
| 1209 | {SDL_GAMEPAD_BUTTON_BACK, view}, {SDL_GAMEPAD_BUTTON_GUIDE, GameInputLabelXboxGuide}, | ||
| 1210 | {SDL_GAMEPAD_BUTTON_START, menu}, {SDL_GAMEPAD_BUTTON_LEFT_STICK, ls}, | ||
| 1211 | {SDL_GAMEPAD_BUTTON_RIGHT_STICK, rs}, {SDL_GAMEPAD_BUTTON_LEFT_SHOULDER, lb}, | ||
| 1212 | {SDL_GAMEPAD_BUTTON_RIGHT_SHOULDER, rb}, {SDL_GAMEPAD_BUTTON_DPAD_UP, up}, | ||
| 1213 | {SDL_GAMEPAD_BUTTON_DPAD_DOWN, down}, {SDL_GAMEPAD_BUTTON_DPAD_LEFT, left}, | ||
| 1214 | {SDL_GAMEPAD_BUTTON_DPAD_RIGHT, right}, | ||
| 1215 | }; | ||
| 1216 | for (const auto& l : labelled) d->button_info[l.sdl].label = l.label; | ||
| 1184 | i.controllerAxisInfo = d->axis_info; | 1217 | i.controllerAxisInfo = d->axis_info; |
| 1185 | i.controllerButtonInfo = d->button_info; | 1218 | i.controllerButtonInfo = d->button_info; |
| 1186 | i.gamepadInfo = &d->gamepad_info; | 1219 | i.gamepadInfo = &d->gamepad_info; |