KeyCode -> KeyboardKey because X11 conflict;

This commit is contained in:
bjornbytes 2020-10-25 13:11:46 -06:00 committed by bjorn
parent 40c403dfb6
commit 94e7bafe47
7 changed files with 16 additions and 16 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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

View File

@ -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];
}

View File

@ -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,

View File

@ -189,7 +189,7 @@ bool lovrPlatformIsMouseDown(MouseButton button) {
return false;
}
bool lovrPlatformIsKeyDown(KeyCode key) {
bool lovrPlatformIsKeyDown(KeyboardKey key) {
return false;
}