Minor cleanup for SDL style
This commit is contained in:
1 parent
2e8bd8f1f3
commit
7fce9f3fd0
1 file changed
+22
-22
@@ -641,8 +641,9 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
if (nCode < 0 || nCode != HC_ACTION) {
|
if (nCode < 0 || nCode != HC_ACTION) {
|
||||||
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
return CallNextHookEx(NULL, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hookData->scanCode == 0x21d) {
|
if (hookData->scanCode == 0x21d) {
|
||||||
// Skip fake LCtrl when RAlt is pressed
|
/* Skip fake LCtrl when RAlt is pressed */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -700,36 +701,35 @@ WIN_KeyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam)
|
|||||||
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
#endif /*!defined(__XBOXONE__) && !defined(__XBOXSERIES__)*/
|
||||||
|
|
||||||
|
|
||||||
// Return 1 if spruious LCtrl is pressed
|
/* Return SDL_TRUE if spurious LCtrl is pressed. LCtrl is sent when RAltGR is pressed. */
|
||||||
// LCtrl is sent when RAltGR is pressed
|
static SDL_bool SkipAltGrLeftControl(WPARAM wParam, LPARAM lParam)
|
||||||
int skip_bad_lcrtl(WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
{
|
||||||
MSG next_msg;
|
MSG next_msg;
|
||||||
DWORD msg_time;
|
DWORD msg_time;
|
||||||
if (wParam != VK_CONTROL) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
// Is this an extended key (i.e. right key)?
|
|
||||||
if (lParam & 0x01000000)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
// Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only
|
if (wParam != VK_CONTROL) {
|
||||||
// want the RALT message, so we try to see if the next message
|
return SDL_FALSE;
|
||||||
// is a RALT message. In that case, this is a false LCTRL!
|
}
|
||||||
|
|
||||||
|
/* Is this an extended key (i.e. right key)? */
|
||||||
|
if (lParam & 0x01000000) {
|
||||||
|
return SDL_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Here is a trick: "Alt Gr" sends LCTRL, then RALT. We only
|
||||||
|
want the RALT message, so we try to see if the next message
|
||||||
|
is a RALT message. In that case, this is a false LCTRL! */
|
||||||
msg_time = GetMessageTime();
|
msg_time = GetMessageTime();
|
||||||
if (PeekMessage(&next_msg, NULL, 0, 0, PM_NOREMOVE)) {
|
if (PeekMessage(&next_msg, NULL, 0, 0, PM_NOREMOVE)) {
|
||||||
if (next_msg.message == WM_KEYDOWN ||
|
if (next_msg.message == WM_KEYDOWN ||
|
||||||
next_msg.message == WM_SYSKEYDOWN) {
|
next_msg.message == WM_SYSKEYDOWN) {
|
||||||
if (next_msg.wParam == VK_MENU &&
|
if (next_msg.wParam == VK_MENU && (next_msg.lParam & 0x01000000) && next_msg.time == msg_time) {
|
||||||
(next_msg.lParam & 0x01000000) &&
|
/* Next message is a RALT down message, which means that this is NOT a proper LCTRL message! */
|
||||||
next_msg.time == msg_time) {
|
return SDL_TRUE;
|
||||||
// Next message is a RALT down message, which
|
|
||||||
// means that this is NOT a proper LCTRL message!
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
LRESULT CALLBACK
|
LRESULT CALLBACK
|
||||||
@@ -1049,7 +1049,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
|
SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
|
||||||
const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
|
const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
|
||||||
|
|
||||||
if (skip_bad_lcrtl(wParam, lParam)) {
|
if (SkipAltGrLeftControl(wParam, lParam)) {
|
||||||
returnCode = 0;
|
returnCode = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1076,7 +1076,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||||||
SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
|
SDL_Scancode code = WindowsScanCodeToSDLScanCode(lParam, wParam);
|
||||||
const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
|
const Uint8 *keyboardState = SDL_GetKeyboardState(NULL);
|
||||||
|
|
||||||
if (skip_bad_lcrtl(wParam, lParam)) {
|
if (SkipAltGrLeftControl(wParam, lParam)) {
|
||||||
returnCode = 0;
|
returnCode = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user