mirror of
https://github.com/glfw/glfw.git
synced 2024-11-25 22:14:34 +00:00
Added support for right control key.
This commit is contained in:
parent
7f470065fc
commit
a1d5fc039d
@ -39,15 +39,14 @@ static void usage(void)
|
|||||||
printf("Usage: clipboard [-h]\n");
|
printf("Usage: clipboard [-h]\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static GLboolean control_is_down(void)
|
||||||
|
{
|
||||||
|
return glfwGetKey(GLFW_KEY_LEFT_CONTROL) ||
|
||||||
|
glfwGetKey(GLFW_KEY_RIGHT_CONTROL);
|
||||||
|
}
|
||||||
|
|
||||||
static void key_callback(GLFWwindow window, int key, int action)
|
static void key_callback(GLFWwindow window, int key, int action)
|
||||||
{
|
{
|
||||||
static int control = GL_FALSE;
|
|
||||||
if (key == GLFW_KEY_LEFT_CONTROL)
|
|
||||||
{
|
|
||||||
control = (action == GLFW_PRESS);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (action != GLFW_PRESS)
|
if (action != GLFW_PRESS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -57,7 +56,7 @@ static void key_callback(GLFWwindow window, int key, int action)
|
|||||||
glfwCloseWindow(window);
|
glfwCloseWindow(window);
|
||||||
break;
|
break;
|
||||||
case GLFW_KEY_V:
|
case GLFW_KEY_V:
|
||||||
if (control)
|
if (control_is_down())
|
||||||
{
|
{
|
||||||
char buffer[4096];
|
char buffer[4096];
|
||||||
size_t size;
|
size_t size;
|
||||||
@ -71,7 +70,7 @@ static void key_callback(GLFWwindow window, int key, int action)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GLFW_KEY_C:
|
case GLFW_KEY_C:
|
||||||
if (control)
|
if (control_is_down())
|
||||||
{
|
{
|
||||||
glfwSetClipboardData("Hello GLFW World!", sizeof("Hello GLFW World!"),
|
glfwSetClipboardData("Hello GLFW World!", sizeof("Hello GLFW World!"),
|
||||||
GLFW_CLIPBOARD_FORMAT_STRING);
|
GLFW_CLIPBOARD_FORMAT_STRING);
|
||||||
|
Loading…
Reference in New Issue
Block a user