diff options
| author | Maraco91 <43787609+Maraco91@users.noreply.github.com> | 2026-11-23 23:15:46 +0100 |
|---|---|---|
| committer | Maraco91 <43787609+Maraco91@users.noreply.github.com> | 2026-11-23 23:15:46 +0100 |
| commit | 29bd7a11a68574e1aa79908805ee6f56a8ae8e76 (patch) | |
| tree | 61d46a5d5cf8300c8a39e9a61e2802c3c112358d /runtime/shims/gameinput.cpp | |
| parent | 5d74c272363f2703265d44e6aaab1a1df8ddfaf3 (diff) | |
gameinput: the device info has its GameInputLabel members
gameinput_abi.h left out the labels of the public v0 layout. In
GameInputControllerAxisInfo and GameInputControllerButtonInfo a label
sits at offset 4, in what is otherwise padding, so the sizes matched
while isContinuous, restValue, legacyDInputIndex and rawReportIndex were
four bytes early. GameInputGamepadInfo and GameInputUiNavigationInfo are
tables of 14 and 21 labels; they were declared empty, and the pointers
in GameInputDeviceInfo led to one-byte members, so a title reading a
label read whatever followed.
The header declares the enum, the two tables and the two label members
and pins each offset that moved. fill_info gives every control the Xbox
label of its position on every pad, since every pad is presented as an
Xbox One pad.
gameinput_test reads the tables by the public header's byte offsets, so
the shim's own header cannot agree with itself.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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; |