mirror of
https://github.com/glfw/glfw.git
synced 2026-09-17 22:32:50 +00:00
Added scancode to key callback.
This commit is contained in:
+1
-1
@@ -74,7 +74,7 @@ static void cursor_position_callback(GLFWwindow* window, double x, double y)
|
||||
cursor_y = y;
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
|
||||
set_swap_interval(window, 1 - swap_interval);
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ static void error_callback(int error, const char* description)
|
||||
fprintf(stderr, "Error: %s\n", description);
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (action != GLFW_PRESS)
|
||||
return;
|
||||
|
||||
+4
-2
@@ -172,6 +172,7 @@ static const char* get_key_name(int key)
|
||||
case GLFW_KEY_LEFT_SUPER: return "LEFT SUPER";
|
||||
case GLFW_KEY_RIGHT_SUPER: return "RIGHT SUPER";
|
||||
case GLFW_KEY_MENU: return "MENU";
|
||||
case GLFW_KEY_UNKNOWN: return "UNKNOWN";
|
||||
|
||||
default: return NULL;
|
||||
}
|
||||
@@ -339,11 +340,12 @@ static void scroll_callback(GLFWwindow* window, double x, double y)
|
||||
printf("%08x at %0.3f: Scroll: %0.3f %0.3f\n", counter++, glfwGetTime(), x, y);
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
const char* name = get_key_name(key);
|
||||
|
||||
printf("%08x at %0.3f: Key 0x%04x", counter++, glfwGetTime(), key);
|
||||
printf("%08x at %0.3f: Key 0x%04x Scancode 0x%04x",
|
||||
counter++, glfwGetTime(), key, scancode);
|
||||
|
||||
if (name)
|
||||
printf(" (%s)", name);
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (action != GLFW_PRESS)
|
||||
return;
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ static void error_callback(int error, const char* description)
|
||||
fprintf(stderr, "Error: %s\n", description);
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (action != GLFW_PRESS)
|
||||
return;
|
||||
|
||||
+1
-1
@@ -45,7 +45,7 @@ static void error_callback(int error, const char* description)
|
||||
fprintf(stderr, "Error: %s\n", description);
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
printf("%0.2f Key %s\n",
|
||||
glfwGetTime(),
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (key == GLFW_KEY_ESCAPE)
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ static void cursor_position_callback(GLFWwindow* window, double x, double y)
|
||||
cursor_y = y;
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
switch (key)
|
||||
{
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ static void window_close_callback(GLFWwindow* window)
|
||||
printf("Close callback triggered\n");
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (action != GLFW_PRESS)
|
||||
return;
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ static void error_callback(int error, const char* description)
|
||||
fprintf(stderr, "Error: %s\n", description);
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (action == GLFW_PRESS && key == GLFW_KEY_ESCAPE)
|
||||
glfwSetWindowShouldClose(window, GL_TRUE);
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
glViewport(0, 0, width, height);
|
||||
}
|
||||
|
||||
static void key_callback(GLFWwindow* window, int key, int action, int mods)
|
||||
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
|
||||
{
|
||||
if (key == GLFW_KEY_SPACE && action == GLFW_PRESS)
|
||||
set_swap_interval(window, 1 - swap_interval);
|
||||
|
||||
Reference in New Issue
Block a user