windows: handle the Pause key sequence for raw keyboard input
This commit is contained in:
@@ -635,18 +635,31 @@ static void WIN_HandleRawKeyboardInput(Uint64 timestamp, SDL_WindowData *data, H
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8 state = (rawkeyboard->Flags & RI_KEY_BREAK) ? SDL_RELEASED : SDL_PRESSED;
|
if (rawkeyboard->Flags & RI_KEY_E1) {
|
||||||
Uint16 scanCode = rawkeyboard->MakeCode;
|
// First key in a Ctrl+{key} sequence
|
||||||
if (rawkeyboard->Flags & RI_KEY_E0) {
|
data->videodata->pending_E1_key_sequence = SDL_TRUE;
|
||||||
scanCode |= (0xE0 << 8);
|
return;
|
||||||
} else if (rawkeyboard->Flags & RI_KEY_E1) {
|
|
||||||
scanCode |= (0xE1 << 8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pack scan code into one byte to make the index
|
Uint8 state = (rawkeyboard->Flags & RI_KEY_BREAK) ? SDL_RELEASED : SDL_PRESSED;
|
||||||
Uint8 index = LOBYTE(scanCode) | (HIBYTE(scanCode) ? 0x80 : 0x00);
|
SDL_Scancode code;
|
||||||
SDL_Scancode code = windows_scancode_table[index];
|
if (data->videodata->pending_E1_key_sequence) {
|
||||||
|
if (rawkeyboard->MakeCode == 0x45) {
|
||||||
|
// Ctrl+NumLock == Pause
|
||||||
|
code = SDL_SCANCODE_PAUSE;
|
||||||
|
} else {
|
||||||
|
// Ctrl+ScrollLock == Break (no SDL scancode?)
|
||||||
|
code = SDL_SCANCODE_UNKNOWN;
|
||||||
|
}
|
||||||
|
data->videodata->pending_E1_key_sequence = SDL_FALSE;
|
||||||
|
} else {
|
||||||
|
// The code is in the lower 7 bits, the high bit is set for the E0 prefix
|
||||||
|
Uint8 index = (Uint8)rawkeyboard->MakeCode;
|
||||||
|
if (rawkeyboard->Flags & RI_KEY_E0) {
|
||||||
|
index |= 0x80;
|
||||||
|
}
|
||||||
|
code = windows_scancode_table[index];
|
||||||
|
}
|
||||||
SDL_SendKeyboardKey(timestamp, keyboardID, state, code);
|
SDL_SendKeyboardKey(timestamp, keyboardID, state, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -408,6 +408,7 @@ struct SDL_VideoData
|
|||||||
|
|
||||||
SDL_bool raw_mouse_enabled;
|
SDL_bool raw_mouse_enabled;
|
||||||
SDL_bool raw_keyboard_enabled;
|
SDL_bool raw_keyboard_enabled;
|
||||||
|
SDL_bool pending_E1_key_sequence;
|
||||||
SDL_bool raw_input_enabled;
|
SDL_bool raw_input_enabled;
|
||||||
|
|
||||||
#ifndef SDL_DISABLE_WINDOWS_IME
|
#ifndef SDL_DISABLE_WINDOWS_IME
|
||||||
|
|||||||
Reference in New Issue
Block a user