[client] input: add platform-neutral keycodes

This commit is contained in:
Geoffrey McRae
2026-09-12 10:12:18 +10:00
parent 382f35e503
commit 7ea69f3d1c
26 changed files with 1412 additions and 1000 deletions

View File

@@ -83,9 +83,9 @@ struct LGMPInputLockKey
static const struct LGMPInputLockKey LOCK_KEYS[] =
{
{ KEY_NUMLOCK, LG_KEYBOARD_LED_NUM_LOCK },
{ KEY_CAPSLOCK, LG_KEYBOARD_LED_CAPS_LOCK },
{ KEY_SCROLLLOCK, LG_KEYBOARD_LED_SCROLL_LOCK },
{ LG_KEY_NUMLOCK, LG_KEYBOARD_LED_NUM_LOCK },
{ LG_KEY_CAPSLOCK, LG_KEYBOARD_LED_CAPS_LOCK },
{ LG_KEY_SCROLLLOCK, LG_KEYBOARD_LED_SCROLL_LOCK },
};
static const uint8_t LOCK_LED_MASK =
@@ -715,7 +715,7 @@ static void recordKeyboardToggle(LGMPInput * input, int key)
static bool queueKeyboardTap(LGMPInput * input,
const struct LGMPInputLockKey * lockKey, bool * wake)
{
const uint8_t usage = linux_to_hid[lockKey->key];
const uint8_t usage = lg_keycode_to_hid[lockKey->key];
if (!usage || input->keyState[usage] || !claim(input, wake))
return false;
@@ -858,7 +858,7 @@ static bool restoreInputState(LGMPInput * input, bool * wake)
if (keyboardHeld)
for (size_t i = 0; i < sizeof(LOCK_KEYS) / sizeof(*LOCK_KEYS); ++i)
{
const uint8_t usage = linux_to_hid[LOCK_KEYS[i].key];
const uint8_t usage = lg_keycode_to_hid[LOCK_KEYS[i].key];
if (usage && input->keyState[usage])
recordKeyboardToggle(input, LOCK_KEYS[i].key);
}
@@ -1723,10 +1723,10 @@ static bool buildKeyboardPayload(const LGMPInput * input,
static bool updateKey(void * opaque, int key, bool pressed)
{
if (key < 0 || key >= KEY_MAX)
if (key < 0 || key >= LG_KEY_MAX)
return false;
const uint8_t usage = linux_to_hid[key];
const uint8_t usage = lg_keycode_to_hid[key];
if (!usage)
return true;

View File

@@ -81,7 +81,7 @@ static void spiceSetStatusListener(void * opaque,
static bool spiceKeyDown(void * opaque, int key)
{
SpiceInput * input = opaque;
const uint32_t ps2 = linux_to_ps2[key];
const uint32_t ps2 = lg_keycode_to_ps2[key];
LG_LOCK(input->stateLock);
const bool result = input->available &&
@@ -93,7 +93,7 @@ static bool spiceKeyDown(void * opaque, int key)
static bool spiceKeyUp(void * opaque, int key)
{
SpiceInput * input = opaque;
const uint32_t ps2 = linux_to_ps2[key];
const uint32_t ps2 = lg_keycode_to_ps2[key];
LG_LOCK(input->stateLock);
const bool result = !ps2 || purespice_keyUp(ps2);