From 1ae9ce1e0a00bf6f8b7e719bf1ec6e73f111afcf Mon Sep 17 00:00:00 2001 From: SephiRok Date: Thu, 21 Feb 2013 18:39:22 +0100 Subject: [PATCH] Fixed print screen key input for all platforms. --- README.md | 1 + src/cocoa_window.m | 2 +- src/win32_window.c | 9 ++++++++- src/x11_init.c | 1 + tests/events.c | 1 + 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6d3aa89a..93605ea6 100644 --- a/README.md +++ b/README.md @@ -471,6 +471,7 @@ skills. * Riku Salminen * Sebastian Schuberth * Matt Sealey + * SephiRok * Steve Sexton * Dmitri Shuralyov * Daniel Skorupski diff --git a/src/cocoa_window.m b/src/cocoa_window.m index 38bb9380..9bb51c61 100644 --- a/src/cocoa_window.m +++ b/src/cocoa_window.m @@ -257,7 +257,7 @@ static int convertMacKeyCode(unsigned int macKeyCode) /* 66 */ -1, /* 67 */ GLFW_KEY_F11, /* 68 */ -1, - /* 69 */ GLFW_KEY_F13, + /* 69 */ GLFW_KEY_PRINT_SCREEN, /* 6a */ GLFW_KEY_F16, /* 6b */ GLFW_KEY_F14, /* 6c */ -1, diff --git a/src/win32_window.c b/src/win32_window.c index 2504061b..e11beecb 100644 --- a/src/win32_window.c +++ b/src/win32_window.c @@ -214,6 +214,7 @@ static int translateKey(WPARAM wParam, LPARAM lParam) case VK_F24: return GLFW_KEY_F24; case VK_NUMLOCK: return GLFW_KEY_NUM_LOCK; case VK_CAPITAL: return GLFW_KEY_CAPS_LOCK; + case VK_SNAPSHOT: return GLFW_KEY_PRINT_SCREEN; case VK_SCROLL: return GLFW_KEY_SCROLL_LOCK; case VK_PAUSE: return GLFW_KEY_PAUSE; case VK_LWIN: return GLFW_KEY_LEFT_SUPER; @@ -413,12 +414,18 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, case WM_KEYUP: case WM_SYSKEYUP: { - // Special trick: release both shift keys on SHIFT up event if (wParam == VK_SHIFT) { + // Special trick: release both shift keys on SHIFT up event _glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, GLFW_RELEASE); _glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, GLFW_RELEASE); } + else if (wParam == VK_SNAPSHOT) + { + // Key down is not reported for the print screen key + _glfwInputKey(window, GLFW_KEY_PRINT_SCREEN, GLFW_PRESS); + _glfwInputKey(window, GLFW_KEY_PRINT_SCREEN, GLFW_RELEASE); + } else _glfwInputKey(window, translateKey(wParam, lParam), GLFW_RELEASE); diff --git a/src/x11_init.c b/src/x11_init.c index 441f63e2..9f131851 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -92,6 +92,7 @@ static int keyCodeToGLFWKeyCode(int keyCode) case XK_Menu: return GLFW_KEY_MENU; case XK_Num_Lock: return GLFW_KEY_NUM_LOCK; case XK_Caps_Lock: return GLFW_KEY_CAPS_LOCK; + case XK_Print: return GLFW_KEY_PRINT_SCREEN; case XK_Scroll_Lock: return GLFW_KEY_SCROLL_LOCK; case XK_Pause: return GLFW_KEY_PAUSE; case XK_Delete: return GLFW_KEY_DELETE; diff --git a/tests/events.c b/tests/events.c index 530ea54b..f26b096e 100644 --- a/tests/events.c +++ b/tests/events.c @@ -163,6 +163,7 @@ static const char* get_key_name(int key) case GLFW_KEY_KP_DECIMAL: return "KEYPAD DECIMAL"; case GLFW_KEY_KP_EQUAL: return "KEYPAD EQUAL"; case GLFW_KEY_KP_ENTER: return "KEYPAD ENTER"; + case GLFW_KEY_PRINT_SCREEN: return "PRINT SCREEN"; case GLFW_KEY_NUM_LOCK: return "NUM LOCK"; case GLFW_KEY_CAPS_LOCK: return "CAPS LOCK"; case GLFW_KEY_SCROLL_LOCK: return "SCROLL LOCK";