Windows: Mapped VK_SNAPSHOT to KEY_SYSRQ and added workaround to a windows bug where WM_KEYDOWN is never generated for VK_SNAPSHOT

This commit is contained in:
Elias Naur 2007-07-29 19:43:36 +00:00
parent 659a1cf4c7
commit 7a49d5ce8f
3 changed files with 16 additions and 2 deletions

View File

@ -706,7 +706,17 @@ final class WindowsDisplay implements DisplayImplementation {
return true;
case WM_SYSKEYDOWN: /* Fall through */
case WM_SYSKEYUP: /* Fall through */
case WM_KEYUP: /* Fall through */
case WM_KEYUP:
// SysRq apparently only generates WM_KEYUP, so we'll fake a WM_KEYDOWN
if (wParam == WindowsKeycodes.VK_SNAPSHOT && keyboard != null &&
!keyboard.isKeyDown(org.lwjgl.input.Keyboard.KEY_SYSRQ)) {
// Set key state to pressed
long fake_lparam = lParam & ~(1 << 31);
// Set key previous state to released
fake_lparam = fake_lparam & ~(1 << 30);
handleKeyButton(wParam, fake_lparam, millis);
}
/* Fall through */
case WM_KEYDOWN:
handleKeyButton(wParam, lParam, millis);
return false;

View File

@ -74,6 +74,10 @@ final class WindowsKeyboard {
public void destroy() {
}
boolean isKeyDown(int lwjgl_keycode) {
return key_down_buffer[lwjgl_keycode] == 1;
}
public void grab(boolean grab) {
if(grab) {
if (!grabbed) {

View File

@ -534,7 +534,7 @@ final class WindowsKeycodes {
return Keyboard.KEY_NUMPADCOMMA;
case VK_DIVIDE:
return Keyboard.KEY_DIVIDE;
case VK_PRINT:
case VK_SNAPSHOT:
return Keyboard.KEY_SYSRQ;
case VK_RMENU:
return Keyboard.KEY_RMENU;