mirror of
https://github.com/glfw/glfw.git
synced 2026-01-11 15:23:17 +01:00
Add lock key modifier bits input mode
This adds the GLFW_MOD_CAPS_LOCK and GLFW_MOD_NUM_LOCK modifier bits. Set the GLFW_LOCK_KEY_MODS input mode to enable these for all callbacks that receive modifier bits. Fixes #946.
This commit is contained in:
@@ -244,6 +244,10 @@ static const char* get_mods_name(int mods)
|
||||
strcat(name, " alt");
|
||||
if (mods & GLFW_MOD_SUPER)
|
||||
strcat(name, " super");
|
||||
if (mods & GLFW_MOD_CAPS_LOCK)
|
||||
strcat(name, " capslock-on");
|
||||
if (mods & GLFW_MOD_NUM_LOCK)
|
||||
strcat(name, " numlock-on");
|
||||
|
||||
return name;
|
||||
}
|
||||
@@ -400,6 +404,15 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||
printf("(( closing %s ))\n", slot->closeable ? "enabled" : "disabled");
|
||||
break;
|
||||
}
|
||||
|
||||
case GLFW_KEY_L:
|
||||
{
|
||||
const int state = glfwGetInputMode(window, GLFW_LOCK_KEY_MODS);
|
||||
glfwSetInputMode(window, GLFW_LOCK_KEY_MODS, !state);
|
||||
|
||||
printf("(( lock key mods %s ))\n", !state ? "enabled" : "disabled");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user