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:
Camilla Löwy
2017-11-29 20:42:37 +01:00
parent fd72eb917e
commit 0e8c4ea7ce
12 changed files with 107 additions and 10 deletions

View File

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