diff --git a/src/api/l_event.c b/src/api/l_event.c index d5dd2b21..47613f32 100644 --- a/src/api/l_event.c +++ b/src/api/l_event.c @@ -21,7 +21,7 @@ StringEntry lovrEventType[] = { { 0 } }; -StringEntry lovrKeyCode[] = { +StringEntry lovrKeyboardKey[] = { [KEY_A] = ENTRY("a"), [KEY_B] = ENTRY("b"), [KEY_C] = ENTRY("c"), @@ -205,13 +205,13 @@ static int nextEvent(lua_State* L) { return 3; case EVENT_KEYPRESSED: - luax_pushenum(L, KeyCode, event.data.key.code); + luax_pushenum(L, KeyboardKey, event.data.key.code); lua_pushinteger(L, event.data.key.scancode); lua_pushboolean(L, event.data.key.repeat); return 4; case EVENT_KEYRELEASED: - luax_pushenum(L, KeyCode, event.data.key.code); + luax_pushenum(L, KeyboardKey, event.data.key.code); lua_pushinteger(L, event.data.key.scancode); return 3; diff --git a/src/core/os.h b/src/core/os.h index bd26d53d..add5c14f 100644 --- a/src/core/os.h +++ b/src/core/os.h @@ -122,7 +122,7 @@ typedef enum { KEY_NUM_LOCK, KEY_COUNT -} KeyCode; +} KeyboardKey; typedef enum { BUTTON_PRESSED, @@ -133,7 +133,7 @@ typedef void (*quitCallback)(void); typedef void (*windowFocusCallback)(bool focused); typedef void (*windowResizeCallback)(int width, int height); typedef void (*mouseButtonCallback)(MouseButton button, ButtonAction action); -typedef void (*keyboardCallback)(ButtonAction action, KeyCode key, uint32_t scancode, bool repeat); +typedef void (*keyboardCallback)(ButtonAction action, KeyboardKey key, uint32_t scancode, bool repeat); typedef void (*textCallback)(uint32_t codepoint); bool lovrPlatformInit(void); @@ -165,4 +165,4 @@ void lovrPlatformOnTextEvent(textCallback callback); void lovrPlatformGetMousePosition(double* x, double* y); void lovrPlatformSetMouseMode(MouseMode mode); bool lovrPlatformIsMouseDown(MouseButton button); -bool lovrPlatformIsKeyDown(KeyCode key); +bool lovrPlatformIsKeyDown(KeyboardKey key); diff --git a/src/core/os_android.c b/src/core/os_android.c index c22bfc05..e1846264 100644 --- a/src/core/os_android.c +++ b/src/core/os_android.c @@ -42,7 +42,7 @@ static int32_t onInputEvent(struct android_app* app, AInputEvent* event) { default: return 0; } - KeyCode key; + KeyboardKey key; switch (AKeyEvent_getKeyCode(event)) { case AKEYCODE_A: key = KEY_A; break; case AKEYCODE_B: key = KEY_B; break; @@ -466,7 +466,7 @@ bool lovrPlatformIsMouseDown(MouseButton button) { return false; } -bool lovrPlatformIsKeyDown(KeyCode key) { +bool lovrPlatformIsKeyDown(KeyboardKey key) { return false; } diff --git a/src/core/os_glfw.h b/src/core/os_glfw.h index 1d786724..b3be66a1 100644 --- a/src/core/os_glfw.h +++ b/src/core/os_glfw.h @@ -53,7 +53,7 @@ static void onMouseButton(GLFWwindow* window, int b, int a, int mods) { static void onKeyboardEvent(GLFWwindow* window, int k, int scancode, int a, int mods) { if (glfwState.onKeyboardEvent) { - KeyCode key; + KeyboardKey key; switch (k) { case GLFW_KEY_A: key = KEY_A; break; case GLFW_KEY_B: key = KEY_B; break; @@ -167,7 +167,7 @@ static int convertMouseButton(MouseButton button) { } } -static int convertKeyCode(KeyCode key) { +static int convertKey(KeyboardKey key) { switch (key) { case KEY_W: return GLFW_KEY_W; case KEY_A: return GLFW_KEY_A; @@ -332,8 +332,8 @@ bool lovrPlatformIsMouseDown(MouseButton button) { return glfwState.window ? glfwGetMouseButton(glfwState.window, convertMouseButton(button)) == GLFW_PRESS : false; } -bool lovrPlatformIsKeyDown(KeyCode key) { - return glfwState.window ? glfwGetKey(glfwState.window, convertKeyCode(key)) == GLFW_PRESS : false; +bool lovrPlatformIsKeyDown(KeyboardKey key) { + return glfwState.window ? glfwGetKey(glfwState.window, convertKey(key)) == GLFW_PRESS : false; } #ifdef _WIN32 diff --git a/src/core/os_web.c b/src/core/os_web.c index fd97888f..e7048ada 100644 --- a/src/core/os_web.c +++ b/src/core/os_web.c @@ -89,7 +89,7 @@ static EM_BOOL onMouseMove(int type, const EmscriptenMouseEvent* data, void* use } static EM_BOOL onKeyEvent(int type, const EmscriptenKeyboardEvent* data, void* userdata) { - KeyCode key; + KeyboardKey key; DOM_PK_CODE_TYPE scancode = emscripten_compute_dom_pk_code(data->code); switch (scancode) { case DOM_PK_ESCAPE: key = KEY_ESCAPE; break; @@ -359,6 +359,6 @@ bool lovrPlatformIsMouseDown(MouseButton button) { return state.mouseMap[button]; } -bool lovrPlatformIsKeyDown(KeyCode key) { +bool lovrPlatformIsKeyDown(KeyboardKey key) { return state.keyMap[key]; } diff --git a/src/modules/event/event.c b/src/modules/event/event.c index c6d94c7a..8f678d70 100644 --- a/src/modules/event/event.c +++ b/src/modules/event/event.c @@ -14,7 +14,7 @@ static struct { size_t head; } state; -static void onKeyboardEvent(ButtonAction action, KeyCode key, uint32_t scancode, bool repeat) { +static void onKeyboardEvent(ButtonAction action, KeyboardKey key, uint32_t scancode, bool repeat) { lovrEventPush((Event) { .type = action == BUTTON_PRESSED ? EVENT_KEYPRESSED : EVENT_KEYRELEASED, .data.key.code = key, diff --git a/src/modules/headset/headset_pico.c b/src/modules/headset/headset_pico.c index 56612505..7d45eb93 100644 --- a/src/modules/headset/headset_pico.c +++ b/src/modules/headset/headset_pico.c @@ -189,7 +189,7 @@ bool lovrPlatformIsMouseDown(MouseButton button) { return false; } -bool lovrPlatformIsKeyDown(KeyCode key) { +bool lovrPlatformIsKeyDown(KeyboardKey key) { return false; }