Files
Vlad Yanhursky 650dfe14ed feat(input): mapping rules on keyboard.h's key table
Add input_map.{c,h} (target xbox_input_map): named bindings and their
text format, key resolution, pad remapping, radial stick deadzones,
trigger thresholds and pad merging.

Built on #191's key table rather than beside it. A binding holds a
Windows VK code from keyboard.h, the held-key array is that table, and
the names are only the persistence format; keyboard.h gains the XBOX_VK_*
codes the names need. Outputs are XBOX_GAMEPAD with the XBOX_GAMEPAD_*
bits and XBOX_BUTTON_* slots from xinput_xbox.h, so the module has no pad
type of its own.

Stick keys keep keyboard.c's full deflection on a diagonal by default;
INPUT_DIAGONAL_ROUND opts into a unit circle. The mouse wheel has no VK
code, so wheel names are rejected and counted like any unknown name.

tests/input_map is the first version's suite ported to these types, plus
the name <-> VK table written out independently and binding strings saved
by the first version (d9a0a38).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-16 19:57:55 -04:00

19 lines
550 B
C++

#include "input_map.h"
int main()
{
InputPadMap map;
InputRaw raw = {};
XBOX_GAMEPAD out;
InputBindings b = {};
uint8_t down[INPUT_KEY_COUNT] = {};
xbox_InputMap_PadMapDefaults(&map);
raw.src[INPUT_SRC_SOUTH] = 32767;
xbox_InputMap_PadMap(&map, &raw, &out);
if (out.bAnalogButtons[XBOX_BUTTON_A] != 255)
return 1;
xbox_InputMap_BindingsParse(&b, INPUT_START, "space");
down[XBOX_VK_SPACE] = 1;
xbox_InputMap_KeysResolve(&b, down, &out);
return out.wButtons == XBOX_GAMEPAD_START ? 0 : 1;
}