[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

@@ -448,10 +448,10 @@ void app_handleWheelMotion(double motion)
void app_handleKeyPressInternal(int sc)
{
if (sc == KEY_LEFTSHIFT)
if (sc == LG_KEY_LEFTSHIFT)
atomic_fetch_or_explicit(&g_state.keyModifiers,
KEY_MODIFIER_LEFT_SHIFT, memory_order_acq_rel);
else if (sc == KEY_RIGHTSHIFT)
else if (sc == LG_KEY_RIGHTSHIFT)
atomic_fetch_or_explicit(&g_state.keyModifiers,
KEY_MODIFIER_RIGHT_SHIFT, memory_order_acq_rel);
@@ -481,9 +481,9 @@ void app_handleKeyPressInternal(int sc)
{
unsigned modifiers = atomic_load_explicit(
&g_state.keyModifiers, memory_order_acquire);
if (g_params.escapeKey == KEY_LEFTSHIFT)
if (g_params.escapeKey == LG_KEY_LEFTSHIFT)
modifiers &= ~(unsigned)KEY_MODIFIER_LEFT_SHIFT;
else if (g_params.escapeKey == KEY_RIGHTSHIFT)
else if (g_params.escapeKey == LG_KEY_RIGHTSHIFT)
modifiers &= ~(unsigned)KEY_MODIFIER_RIGHT_SHIFT;
const bool shift = modifiers != 0;
if (!repeat)
@@ -508,12 +508,12 @@ void app_handleKeyPressInternal(int sc)
if (app_isOverlayMode())
{
if (sc == KEY_ESC)
if (sc == LG_KEY_ESC)
app_setOverlay(false);
else
{
if (linux_to_imgui[sc])
ImGuiIO_AddKeyEvent(g_state.io, linux_to_imgui[sc], true);
if (lg_keycode_to_imgui[sc])
ImGuiIO_AddKeyEvent(g_state.io, lg_keycode_to_imgui[sc], true);
}
return;
}
@@ -521,7 +521,7 @@ void app_handleKeyPressInternal(int sc)
if (!core_inputEnabled())
return;
if (g_params.ignoreWindowsKeys && (sc == KEY_LEFTMETA || sc == KEY_RIGHTMETA))
if (g_params.ignoreWindowsKeys && (sc == LG_KEY_LEFTMETA || sc == LG_KEY_RIGHTMETA))
return;
if (!lgInput_keyDown(sc))
@@ -530,10 +530,10 @@ void app_handleKeyPressInternal(int sc)
void app_handleKeyReleaseInternal(int sc)
{
if (sc == KEY_LEFTSHIFT)
if (sc == LG_KEY_LEFTSHIFT)
atomic_fetch_and_explicit(&g_state.keyModifiers,
~(unsigned)KEY_MODIFIER_LEFT_SHIFT, memory_order_acq_rel);
else if (sc == KEY_RIGHTSHIFT)
else if (sc == LG_KEY_RIGHTSHIFT)
atomic_fetch_and_explicit(&g_state.keyModifiers,
~(unsigned)KEY_MODIFIER_RIGHT_SHIFT, memory_order_acq_rel);
@@ -559,15 +559,15 @@ void app_handleKeyReleaseInternal(int sc)
if (app_isOverlayMode())
{
if (linux_to_imgui[sc])
ImGuiIO_AddKeyEvent(g_state.io, linux_to_imgui[sc], false);
if (lg_keycode_to_imgui[sc])
ImGuiIO_AddKeyEvent(g_state.io, lg_keycode_to_imgui[sc], false);
return;
}
if (!core_inputEnabled())
return;
if (g_params.ignoreWindowsKeys && (sc == KEY_LEFTMETA || sc == KEY_RIGHTMETA))
if (g_params.ignoreWindowsKeys && (sc == LG_KEY_LEFTMETA || sc == LG_KEY_RIGHTMETA))
return;
if (!lgInput_keyUp(sc))
@@ -623,9 +623,9 @@ void app_handleInputResetInternal(bool keyboard, bool pointer)
if (keyboard)
{
for(int key = 0; key < KEY_MAX; ++key)
if (linux_to_imgui[key])
ImGuiIO_AddKeyEvent(g_state.io, linux_to_imgui[key], false);
for(int key = 0; key < LG_KEY_MAX; ++key)
if (lg_keycode_to_imgui[key])
ImGuiIO_AddKeyEvent(g_state.io, lg_keycode_to_imgui[key], false);
g_state.modCtrl = false;
g_state.modShift = false;
@@ -909,7 +909,7 @@ KeybindHandle app_registerKeybind(int sc, KeybindFn callback, void * opaque,
return NULL;
}
if (sc <= KEY_RESERVED || sc >= KEY_MAX || !linux_to_display[sc])
if (sc <= LG_KEY_RESERVED || sc >= LG_KEY_MAX || !lg_keycode_to_display[sc])
{
DEBUG_ERROR("invalid keybind keycode: %d", sc);
return NULL;

View File

@@ -353,7 +353,7 @@ static struct Option options[] =
.description = "Specify the escape/menu key to use (use \"help\" to see valid values)",
.shortopt = 'm',
.type = OPTION_TYPE_INT,
.value.x_int = KEY_SCROLLLOCK,
.value.x_int = LG_KEY_SCROLLLOCK,
.parser = optScancodeParse,
.getValues = optScancodeValues,
.validator = optScancodeValidate,
@@ -896,16 +896,16 @@ static StringList optScancodeValues(struct Option * opt)
return NULL;
// this typecast is safe as the stringlist doesn't own the values
for(unsigned int i = 0; i < KEY_MAX; ++i)
if (linux_to_str[i])
stringlist_push(sl, (char *)linux_to_str[i]);
for(unsigned int i = 0; i < LG_KEY_MAX; ++i)
if (lg_keycode_to_name[i])
stringlist_push(sl, (char *)lg_keycode_to_name[i]);
return sl;
}
static bool optScancodeValidate(struct Option * opt, const char ** error)
{
if (opt->value.x_int >= 0 && opt->value.x_int < KEY_MAX)
if (opt->value.x_int >= 0 && opt->value.x_int < LG_KEY_MAX)
return true;
*error = "Out of range";
@@ -914,12 +914,12 @@ static bool optScancodeValidate(struct Option * opt, const char ** error)
static bool optScancodeParse(struct Option * opt, const char * str)
{
for(unsigned int i = 0; i < KEY_MAX; ++i)
for(unsigned int i = 0; i < LG_KEY_MAX; ++i)
{
if (!linux_to_str[i])
if (!lg_keycode_to_name[i])
continue;
if (strcasecmp(linux_to_str[i], str) == 0)
if (strcasecmp(lg_keycode_to_name[i], str) == 0)
{
opt->value.x_int = i;
return true;
@@ -939,7 +939,7 @@ static char * optScancodeToString(struct Option * opt)
{
char * str;
alloc_sprintf(&str, "%d = %s", opt->value.x_int,
linux_to_str[opt->value.x_int]);
lg_keycode_to_name[opt->value.x_int]);
return str;
}

View File

@@ -1149,9 +1149,9 @@ void core_resetOverlayInputState(void)
g_state.io->MouseDown[ImGuiMouseButton_Left ] = false;
g_state.io->MouseDown[ImGuiMouseButton_Right ] = false;
g_state.io->MouseDown[ImGuiMouseButton_Middle] = false;
for(int key = 0; key < KEY_MAX; key++)
if (linux_to_imgui[key])
ImGuiIO_AddKeyEvent(g_state.io, linux_to_imgui[key], false);
for(int key = 0; key < LG_KEY_MAX; key++)
if (lg_keycode_to_imgui[key])
ImGuiIO_AddKeyEvent(g_state.io, lg_keycode_to_imgui[key], false);
}
void core_updateOverlayState(void)

View File

@@ -55,6 +55,11 @@
#define EVDEV_WHEEL_LIMIT 64
#define EVDEV_GUEST_LEDS_VALID UINT8_C(0x80)
_Static_assert((int)LG_KEY_RESERVED == KEY_RESERVED,
"Looking Glass and evdev reserved keycodes differ");
_Static_assert((int)LG_KEY_MAX == KEY_MAX,
"Looking Glass and evdev maximum keycodes differ");
enum EvdevGrabReason
{
EVDEV_GRAB_KEYBOARD = 1 << 0,

View File

@@ -22,8 +22,8 @@
#include "common/debug.h"
#include "common/locking.h"
#include "input/keycodes.h"
#include <linux/input.h>
#include <stdatomic.h>
struct InputBinding
@@ -60,7 +60,7 @@ static struct
bool desiredKeyboardLEDsValid;
uint8_t desiredKeyboardLEDs;
_Atomic(bool) keys[KEY_MAX];
_Atomic(bool) keys[LG_KEY_MAX];
_Atomic(uint32_t) buttons;
}
l_input;
@@ -160,7 +160,7 @@ static void dispatchAvailability(void)
static void releaseKeysNL(void)
{
for (int key = 0; key < KEY_MAX; ++key)
for (int key = 0; key < LG_KEY_MAX; ++key)
if (atomic_exchange_explicit(&l_input.keys[key], false,
memory_order_relaxed) && l_input.active.ops)
l_input.active.ops->keyUp(l_input.active.opaque, key);
@@ -189,7 +189,7 @@ static void resetActiveNL(void)
static void clearStateNL(void)
{
for (int key = 0; key < KEY_MAX; ++key)
for (int key = 0; key < LG_KEY_MAX; ++key)
atomic_store_explicit(&l_input.keys[key], false, memory_order_relaxed);
atomic_store_explicit(&l_input.buttons, 0, memory_order_relaxed);
@@ -337,7 +337,7 @@ void lgInput_init(void)
l_input.desiredKeyboardLEDsValid = false;
l_input.desiredKeyboardLEDs = 0;
for (int key = 0; key < KEY_MAX; ++key)
for (int key = 0; key < LG_KEY_MAX; ++key)
atomic_init(&l_input.keys[key], false);
atomic_init(&l_input.buttons, 0);
@@ -531,7 +531,7 @@ void lgInput_setAvailabilityListener(
bool lgInput_keyDown(int key)
{
if (key < 0 || key >= KEY_MAX)
if (key < 0 || key >= LG_KEY_MAX)
return false;
LG_LOCK_SHARED(l_input.activeLock);
@@ -552,7 +552,7 @@ bool lgInput_keyDown(int key)
bool lgInput_keyUp(int key)
{
if (key < 0 || key >= KEY_MAX)
if (key < 0 || key >= LG_KEY_MAX)
return false;
LG_LOCK_SHARED(l_input.activeLock);

File diff suppressed because it is too large Load Diff

View File

@@ -21,17 +21,18 @@
#ifndef _H_LG_KB_
#define _H_LG_KB_
#include <linux/input.h>
#include <stdint.h>
#include "input/keycodes.h"
#define PS2_MUTE 0xE020
#define PS2_VOLUME_UP 0xE030
#define PS2_VOLUME_DOWN 0xE02E
extern const uint32_t linux_to_ps2[KEY_MAX];
extern const uint8_t linux_to_hid[KEY_MAX];
extern const char * linux_to_str[KEY_MAX];
extern const char * linux_to_display[KEY_MAX];
extern const int linux_to_imgui[KEY_MAX];
extern const uint32_t lg_keycode_to_ps2 [LG_KEY_MAX];
extern const uint8_t lg_keycode_to_hid [LG_KEY_MAX];
extern const char * lg_keycode_to_name [LG_KEY_MAX];
extern const char * lg_keycode_to_display[LG_KEY_MAX];
extern const int lg_keycode_to_imgui [LG_KEY_MAX];
#endif

View File

@@ -20,152 +20,152 @@
#include "kb.h"
const uint8_t linux_to_hid[KEY_MAX] =
const uint8_t lg_keycode_to_hid[LG_KEY_MAX] =
{
[KEY_ESC] = 41,
[KEY_1] = 30,
[KEY_2] = 31,
[KEY_3] = 32,
[KEY_4] = 33,
[KEY_5] = 34,
[KEY_6] = 35,
[KEY_7] = 36,
[KEY_8] = 37,
[KEY_9] = 38,
[KEY_0] = 39,
[KEY_MINUS] = 45,
[KEY_EQUAL] = 46,
[KEY_BACKSPACE] = 42,
[KEY_TAB] = 43,
[KEY_Q] = 20,
[KEY_W] = 26,
[KEY_E] = 8,
[KEY_R] = 21,
[KEY_T] = 23,
[KEY_Y] = 28,
[KEY_U] = 24,
[KEY_I] = 12,
[KEY_O] = 18,
[KEY_P] = 19,
[KEY_LEFTBRACE] = 47,
[KEY_RIGHTBRACE] = 48,
[KEY_ENTER] = 40,
[KEY_LEFTCTRL] = 224,
[KEY_A] = 4,
[KEY_S] = 22,
[KEY_D] = 7,
[KEY_F] = 9,
[KEY_G] = 10,
[KEY_H] = 11,
[KEY_J] = 13,
[KEY_K] = 14,
[KEY_L] = 15,
[KEY_SEMICOLON] = 51,
[KEY_APOSTROPHE] = 52,
[KEY_GRAVE] = 53,
[KEY_LEFTSHIFT] = 225,
[KEY_BACKSLASH] = 49,
[KEY_Z] = 29,
[KEY_X] = 27,
[KEY_C] = 6,
[KEY_V] = 25,
[KEY_B] = 5,
[KEY_N] = 17,
[KEY_M] = 16,
[KEY_COMMA] = 54,
[KEY_DOT] = 55,
[KEY_SLASH] = 56,
[KEY_RIGHTSHIFT] = 229,
[KEY_KPASTERISK] = 85,
[KEY_LEFTALT] = 226,
[KEY_SPACE] = 44,
[KEY_CAPSLOCK] = 57,
[KEY_F1] = 58,
[KEY_F2] = 59,
[KEY_F3] = 60,
[KEY_F4] = 61,
[KEY_F5] = 62,
[KEY_F6] = 63,
[KEY_F7] = 64,
[KEY_F8] = 65,
[KEY_F9] = 66,
[KEY_F10] = 67,
[KEY_NUMLOCK] = 83,
[KEY_SCROLLLOCK] = 71,
[KEY_KP7] = 95,
[KEY_KP8] = 96,
[KEY_KP9] = 97,
[KEY_KPMINUS] = 86,
[KEY_KP4] = 92,
[KEY_KP5] = 93,
[KEY_KP6] = 94,
[KEY_KPPLUS] = 87,
[KEY_KP1] = 89,
[KEY_KP2] = 90,
[KEY_KP3] = 91,
[KEY_KP0] = 98,
[KEY_KPDOT] = 99,
[KEY_102ND] = 100,
[KEY_F11] = 68,
[KEY_F12] = 69,
[KEY_RO] = 135,
[KEY_HENKAN] = 138,
[KEY_KATAKANAHIRAGANA] = 136,
[KEY_MUHENKAN] = 139,
[KEY_KPENTER] = 88,
[KEY_RIGHTCTRL] = 228,
[KEY_KPSLASH] = 84,
[KEY_SYSRQ] = 70,
[KEY_RIGHTALT] = 230,
[KEY_HOME] = 74,
[KEY_UP] = 82,
[KEY_PAGEUP] = 75,
[KEY_LEFT] = 80,
[KEY_RIGHT] = 79,
[KEY_END] = 77,
[KEY_DOWN] = 81,
[KEY_PAGEDOWN] = 78,
[KEY_INSERT] = 73,
[KEY_DELETE] = 76,
[KEY_KPEQUAL] = 103,
[KEY_PAUSE] = 72,
[KEY_KPCOMMA] = 133,
[KEY_HANGEUL] = 144,
[KEY_HANJA] = 145,
[KEY_YEN] = 137,
[KEY_LEFTMETA] = 227,
[KEY_RIGHTMETA] = 231,
[KEY_COMPOSE] = 101,
[KEY_POWER] = 102,
[KEY_F13] = 104,
[KEY_F14] = 105,
[KEY_F15] = 106,
[KEY_F16] = 107,
[KEY_F17] = 108,
[KEY_F18] = 109,
[KEY_F19] = 110,
[KEY_F20] = 111,
[KEY_F21] = 112,
[KEY_F22] = 113,
[KEY_F23] = 114,
[KEY_F24] = 115,
[KEY_OPEN] = 116,
[KEY_HELP] = 117,
[KEY_MENU] = 118,
[KEY_FRONT] = 119,
[KEY_AGAIN] = 121,
[KEY_UNDO] = 122,
[KEY_CUT] = 123,
[KEY_COPY] = 124,
[KEY_PASTE] = 125,
[KEY_KPJPCOMMA] = 140,
[KEY_KATAKANA] = 146,
[KEY_HIRAGANA] = 147,
[KEY_ZENKAKUHANKAKU] = 148,
[KEY_KPLEFTPAREN] = 182,
[KEY_KPRIGHTPAREN] = 183,
[KEY_PRINT] = 70,
[KEY_MUTE] = 127,
[KEY_VOLUMEUP] = 128,
[KEY_VOLUMEDOWN] = 129,
[LG_KEY_ESC] = 41,
[LG_KEY_1] = 30,
[LG_KEY_2] = 31,
[LG_KEY_3] = 32,
[LG_KEY_4] = 33,
[LG_KEY_5] = 34,
[LG_KEY_6] = 35,
[LG_KEY_7] = 36,
[LG_KEY_8] = 37,
[LG_KEY_9] = 38,
[LG_KEY_0] = 39,
[LG_KEY_MINUS] = 45,
[LG_KEY_EQUAL] = 46,
[LG_KEY_BACKSPACE] = 42,
[LG_KEY_TAB] = 43,
[LG_KEY_Q] = 20,
[LG_KEY_W] = 26,
[LG_KEY_E] = 8,
[LG_KEY_R] = 21,
[LG_KEY_T] = 23,
[LG_KEY_Y] = 28,
[LG_KEY_U] = 24,
[LG_KEY_I] = 12,
[LG_KEY_O] = 18,
[LG_KEY_P] = 19,
[LG_KEY_LEFTBRACE] = 47,
[LG_KEY_RIGHTBRACE] = 48,
[LG_KEY_ENTER] = 40,
[LG_KEY_LEFTCTRL] = 224,
[LG_KEY_A] = 4,
[LG_KEY_S] = 22,
[LG_KEY_D] = 7,
[LG_KEY_F] = 9,
[LG_KEY_G] = 10,
[LG_KEY_H] = 11,
[LG_KEY_J] = 13,
[LG_KEY_K] = 14,
[LG_KEY_L] = 15,
[LG_KEY_SEMICOLON] = 51,
[LG_KEY_APOSTROPHE] = 52,
[LG_KEY_GRAVE] = 53,
[LG_KEY_LEFTSHIFT] = 225,
[LG_KEY_BACKSLASH] = 49,
[LG_KEY_Z] = 29,
[LG_KEY_X] = 27,
[LG_KEY_C] = 6,
[LG_KEY_V] = 25,
[LG_KEY_B] = 5,
[LG_KEY_N] = 17,
[LG_KEY_M] = 16,
[LG_KEY_COMMA] = 54,
[LG_KEY_DOT] = 55,
[LG_KEY_SLASH] = 56,
[LG_KEY_RIGHTSHIFT] = 229,
[LG_KEY_KPASTERISK] = 85,
[LG_KEY_LEFTALT] = 226,
[LG_KEY_SPACE] = 44,
[LG_KEY_CAPSLOCK] = 57,
[LG_KEY_F1] = 58,
[LG_KEY_F2] = 59,
[LG_KEY_F3] = 60,
[LG_KEY_F4] = 61,
[LG_KEY_F5] = 62,
[LG_KEY_F6] = 63,
[LG_KEY_F7] = 64,
[LG_KEY_F8] = 65,
[LG_KEY_F9] = 66,
[LG_KEY_F10] = 67,
[LG_KEY_NUMLOCK] = 83,
[LG_KEY_SCROLLLOCK] = 71,
[LG_KEY_KP7] = 95,
[LG_KEY_KP8] = 96,
[LG_KEY_KP9] = 97,
[LG_KEY_KPMINUS] = 86,
[LG_KEY_KP4] = 92,
[LG_KEY_KP5] = 93,
[LG_KEY_KP6] = 94,
[LG_KEY_KPPLUS] = 87,
[LG_KEY_KP1] = 89,
[LG_KEY_KP2] = 90,
[LG_KEY_KP3] = 91,
[LG_KEY_KP0] = 98,
[LG_KEY_KPDOT] = 99,
[LG_KEY_102ND] = 100,
[LG_KEY_F11] = 68,
[LG_KEY_F12] = 69,
[LG_KEY_RO] = 135,
[LG_KEY_HENKAN] = 138,
[LG_KEY_KATAKANAHIRAGANA] = 136,
[LG_KEY_MUHENKAN] = 139,
[LG_KEY_KPENTER] = 88,
[LG_KEY_RIGHTCTRL] = 228,
[LG_KEY_KPSLASH] = 84,
[LG_KEY_SYSRQ] = 70,
[LG_KEY_RIGHTALT] = 230,
[LG_KEY_HOME] = 74,
[LG_KEY_UP] = 82,
[LG_KEY_PAGEUP] = 75,
[LG_KEY_LEFT] = 80,
[LG_KEY_RIGHT] = 79,
[LG_KEY_END] = 77,
[LG_KEY_DOWN] = 81,
[LG_KEY_PAGEDOWN] = 78,
[LG_KEY_INSERT] = 73,
[LG_KEY_DELETE] = 76,
[LG_KEY_KPEQUAL] = 103,
[LG_KEY_PAUSE] = 72,
[LG_KEY_KPCOMMA] = 133,
[LG_KEY_HANGEUL] = 144,
[LG_KEY_HANJA] = 145,
[LG_KEY_YEN] = 137,
[LG_KEY_LEFTMETA] = 227,
[LG_KEY_RIGHTMETA] = 231,
[LG_KEY_COMPOSE] = 101,
[LG_KEY_POWER] = 102,
[LG_KEY_F13] = 104,
[LG_KEY_F14] = 105,
[LG_KEY_F15] = 106,
[LG_KEY_F16] = 107,
[LG_KEY_F17] = 108,
[LG_KEY_F18] = 109,
[LG_KEY_F19] = 110,
[LG_KEY_F20] = 111,
[LG_KEY_F21] = 112,
[LG_KEY_F22] = 113,
[LG_KEY_F23] = 114,
[LG_KEY_F24] = 115,
[LG_KEY_OPEN] = 116,
[LG_KEY_HELP] = 117,
[LG_KEY_MENU] = 118,
[LG_KEY_FRONT] = 119,
[LG_KEY_AGAIN] = 121,
[LG_KEY_UNDO] = 122,
[LG_KEY_CUT] = 123,
[LG_KEY_COPY] = 124,
[LG_KEY_PASTE] = 125,
[LG_KEY_KPJPCOMMA] = 140,
[LG_KEY_KATAKANA] = 146,
[LG_KEY_HIRAGANA] = 147,
[LG_KEY_ZENKAKUHANKAKU] = 148,
[LG_KEY_KPLEFTPAREN] = 182,
[LG_KEY_KPRIGHTPAREN] = 183,
[LG_KEY_PRINT] = 70,
[LG_KEY_MUTE] = 127,
[LG_KEY_VOLUMEUP] = 128,
[LG_KEY_VOLUMEDOWN] = 129,
};

View File

@@ -103,13 +103,13 @@ static void bind_mouseSens(int sc, void * opaque)
static void bind_ctrlAltFn(int sc, void * opaque)
{
lgInput_keyDown(KEY_LEFTCTRL);
lgInput_keyDown(KEY_LEFTALT);
lgInput_keyDown(LG_KEY_LEFTCTRL);
lgInput_keyDown(LG_KEY_LEFTALT);
lgInput_keyDown(sc);
lgInput_keyUp(sc);
lgInput_keyUp(KEY_LEFTALT);
lgInput_keyUp(KEY_LEFTCTRL);
lgInput_keyUp(LG_KEY_LEFTALT);
lgInput_keyUp(LG_KEY_LEFTCTRL);
}
static void bind_passthrough(int sc, void * opaque)
@@ -152,22 +152,22 @@ static void bind_setGuestRes(int sc, void * opaque)
void keybind_commonRegister(void)
{
app_registerKeybind(KEY_F, bind_fullscreen , NULL,
app_registerKeybind(LG_KEY_F, bind_fullscreen , NULL,
"Full screen toggle");
app_registerKeybind(KEY_V, bind_video , NULL,
app_registerKeybind(LG_KEY_V, bind_video , NULL,
"Video stream toggle");
KeybindHandle rotate = app_registerKeybind(KEY_R, bind_rotate, NULL,
KeybindHandle rotate = app_registerKeybind(LG_KEY_R, bind_rotate, NULL,
"Rotate the output clockwise by 90° increments");
if (rotate)
{
rotate->shiftCallback = bind_forceRecovery;
rotate->shiftDescription = "Force guest display recovery";
}
app_registerKeybind(KEY_Q, bind_quit , NULL,
app_registerKeybind(LG_KEY_Q, bind_quit , NULL,
"Quit");
app_registerKeybind(KEY_O, bind_toggleOverlay, NULL,
app_registerKeybind(LG_KEY_O, bind_toggleOverlay, NULL,
"Toggle overlay");
app_registerKeybind(KEY_EQUAL, bind_setGuestRes, NULL,
app_registerKeybind(LG_KEY_EQUAL, bind_setGuestRes, NULL,
"Set guest resolution to match window size");
}
@@ -198,32 +198,32 @@ void keybind_inputRegister(void)
static bool firstTime = true;
if (firstTime)
{
app_registerKeybind(KEY_I, bind_input, NULL,
app_registerKeybind(LG_KEY_I, bind_input, NULL,
"Keyboard & mouse toggle");
app_registerKeybind(KEY_INSERT, bind_mouseSens, (void *) true,
app_registerKeybind(LG_KEY_INSERT, bind_mouseSens, (void *) true,
"Increase mouse sensitivity in capture mode");
app_registerKeybind(KEY_DELETE, bind_mouseSens, (void *) false,
app_registerKeybind(LG_KEY_DELETE, bind_mouseSens, (void *) false,
"Decrease mouse sensitivity in capture mode");
app_registerKeybind(KEY_UP, bind_toggleKey, (void *) KEY_VOLUMEUP,
app_registerKeybind(LG_KEY_UP, bind_toggleKey, (void *) LG_KEY_VOLUMEUP,
"Send volume up to the guest");
app_registerKeybind(KEY_DOWN, bind_toggleKey, (void *) KEY_VOLUMEDOWN,
app_registerKeybind(LG_KEY_DOWN, bind_toggleKey, (void *) LG_KEY_VOLUMEDOWN,
"Send volume down to the guest");
app_registerKeybind(KEY_M, bind_toggleKey, (void *) KEY_MUTE,
app_registerKeybind(LG_KEY_M, bind_toggleKey, (void *) LG_KEY_MUTE,
"Send mute to the guest");
app_registerKeybind(KEY_LEFTMETA, bind_passthrough, NULL,
app_registerKeybind(LG_KEY_LEFTMETA, bind_passthrough, NULL,
"Send LWin to the guest");
app_registerKeybind(KEY_RIGHTMETA, bind_passthrough, NULL,
app_registerKeybind(LG_KEY_RIGHTMETA, bind_passthrough, NULL,
"Send RWin to the guest");
#if ENABLE_AUDIO
if (lgAudio_supportsRecord())
{
app_registerKeybind(KEY_E, lgAudio_recordToggleKeybind, NULL,
app_registerKeybind(LG_KEY_E, lgAudio_recordToggleKeybind, NULL,
"Toggle audio recording");
app_registerKeybind(KEY_C, bind_toggleMicDefault, NULL,
app_registerKeybind(LG_KEY_C, bind_toggleMicDefault, NULL,
"Cycle audio recording default");
}
#endif
@@ -241,29 +241,29 @@ void keybind_inputRegister(void)
/* register OS based keybinds */
if (app_guestIsLinux())
{
handles[handleCount++] = app_registerKeybind(KEY_F1, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F1, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F1 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F2, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F2, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F2 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F3, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F3, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F3 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F4, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F4, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F4 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F5, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F5, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F5 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F6, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F6, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F6 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F7, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F7, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F7 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F8, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F8, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F8 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F9, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F9, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F9 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F10, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F10, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F10 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F11, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F11, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F11 to the guest");
handles[handleCount++] = app_registerKeybind(KEY_F12, bind_ctrlAltFn, NULL,
handles[handleCount++] = app_registerKeybind(LG_KEY_F12, bind_ctrlAltFn, NULL,
"Send Ctrl+Alt+F12 to the guest");
}
}

View File

@@ -37,7 +37,6 @@
#include <math.h>
#include <stdlib.h>
#include <stdatomic.h>
#include <linux/input.h>
#include "common/array.h"
#include "common/debug.h"

View File

@@ -20,7 +20,8 @@
#include <stdbool.h>
#include <stdatomic.h>
#include <linux/input.h>
#include "input/keycodes.h"
#include "dynamic/displayservers.h"
#include "dynamic/renderers.h"
@@ -130,8 +131,8 @@ struct AppState
bool escapeActive;
uint64_t escapeTime;
int escapeAction;
bool escapeKeys[KEY_MAX];
bool escapeShiftKeys[KEY_MAX];
bool escapeKeys[LG_KEY_MAX];
bool escapeShiftKeys[LG_KEY_MAX];
atomic_uint keyModifiers;
bool escapeHelp;
struct ll * bindings;

View File

@@ -53,7 +53,7 @@ static void fps_earlyInit(void)
static bool fps_init(void ** udata, const void * params)
{
app_registerKeybind(KEY_D, showFPSKeybind, NULL, "FPS display toggle");
app_registerKeybind(LG_KEY_D, showFPSKeybind, NULL, "FPS display toggle");
showFPS = option_get_bool("win", "showFPS");
return true;
}

View File

@@ -162,7 +162,7 @@ static bool graphs_init(void ** udata, const void * params)
}
app_overlayConfigRegister("Performance Metrics", configCallback, NULL);
app_registerKeybind(KEY_T, showTimingKeybind, NULL,
app_registerKeybind(LG_KEY_T, showTimingKeybind, NULL,
"Show frame timing information");
return true;
}

View File

@@ -57,7 +57,7 @@ static int help_render(void * udata, bool interactive, struct Rect * windowRects
if (igBeginTable("Help", 2, 0, (ImVec2) { 0.0f, 0.0f }, 0.0f))
{
char escapeLabel[8];
const char * escapeName = linux_to_display[g_params.escapeKey];
const char * escapeName = lg_keycode_to_display[g_params.escapeKey];
if (g_state.ds->getKeyLabel(
g_params.escapeKey, escapeLabel, sizeof(escapeLabel)))
escapeName = escapeLabel;
@@ -74,7 +74,7 @@ static int help_render(void * udata, bool interactive, struct Rect * windowRects
continue;
char keyLabel[8];
const char * keyName = linux_to_display[handle->sc];
const char * keyName = lg_keycode_to_display[handle->sc];
if (g_state.ds->getKeyLabel(handle->sc, keyLabel, sizeof(keyLabel)))
keyName = keyLabel;