summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-10-03 21:12:22 -0500
committersanine <sanine.not@pm.me>2022-10-03 21:12:22 -0500
commitc4241b7cc97e9b0a341d54f2a4d172500c1d5399 (patch)
tree7a9d53c14d31fcc6deffd910a0604f51524faf2a /src
parent99574e9e679208d629884b924424ed8a54423920 (diff)
add window.getKey
Diffstat (limited to 'src')
-rw-r--r--src/gl/window.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/gl/window.c b/src/gl/window.c
index 04302e7..db807f6 100644
--- a/src/gl/window.c
+++ b/src/gl/window.c
@@ -28,6 +28,7 @@ int window_poll_events(lua_State *L);
int window_swap_buffers(lua_State *L);
int window_set_framebuffer_size_callback(lua_State *L);
int window_get_time(lua_State *L);
+int window_get_key(lua_State *L);
static const char *window_tname = "window";
@@ -58,9 +59,17 @@ void setup_window(lua_State *L, int honey_index)
hs_str_cfunc("swapBuffers", window_swap_buffers),
hs_str_cfunc("setFramebufferSizeCallback", window_set_framebuffer_size_callback),
hs_str_cfunc("getTime", window_get_time),
+ hs_str_cfunc("getKey", window_get_key),
hs_str_tbl("hintType", hint_types),
hs_str_tbl("profileType", profile_types),
+
+ /* key states */
+ hs_str_int("PRESS", GLFW_PRESS),
+ hs_str_int("RELEASE", GLFW_RELEASE),
+
+ /* key buttons */
+ hs_str_int("KEY_ESCAPE", GLFW_KEY_ESCAPE),
);
lua_setfield(L, honey_index, "window");
}
@@ -172,3 +181,12 @@ int window_get_time(lua_State *L)
lua_pushnumber(L, glfwGetTime());
return 1;
}
+
+
+int window_get_key(lua_State *L)
+{
+ GLFWwindow **win = luaL_checkudata(L, 1, window_tname);
+ int key = luaL_checkinteger(L, 2);
+ lua_pushinteger(L, glfwGetKey(*win, key));
+ return 1;
+}