Skip to content

Commit

Permalink
Windows: discard standalone Windows key presses
Browse files Browse the repository at this point in the history
  • Loading branch information
magiblot committed Oct 21, 2024
1 parent bfca212 commit 714eb0b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
9 changes: 5 additions & 4 deletions source/platform/win32con.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,14 @@ bool getWin32Key(const KEY_EVENT_RECORD &KeyEvent, TEvent &ev, InputState &state
kbScrollState | kbNumState | kbCapsState | kbEnhanced
);

if (ev.keyDown.textLength)
if (ev.keyDown.textLength != 0)
{
ev.keyDown.charScan.charCode = CpTranslator::fromUtf8(ev.keyDown.getText());
if (KeyEvent.wVirtualKeyCode == VK_MENU)
// This is enabled when pasting certain characters, and it confuses
// applications. Clear it.
ev.keyDown.charScan.scanCode = 0;
if (!ev.keyDown.charScan.charCode || ev.keyDown.keyCode <= kbCtrlZ)
if (ev.keyDown.charScan.charCode == '\0' || ev.keyDown.keyCode <= kbCtrlZ)
// If the character cannot be represented in the current codepage,
// or if it would accidentally trigger a Ctrl+Key combination,
// make the whole keyCode zero to avoid side effects.
Expand All @@ -435,8 +435,9 @@ bool getWin32Key(const KEY_EVENT_RECORD &KeyEvent, TEvent &ev, InputState &state

if ( ev.keyDown.keyCode == 0x2A00 || ev.keyDown.keyCode == 0x1D00 ||
ev.keyDown.keyCode == 0x3600 || ev.keyDown.keyCode == 0x3800 ||
ev.keyDown.keyCode == 0x3A00 )
// Discard standalone Shift, Ctrl, Alt, Caps Lock keys.
ev.keyDown.keyCode == 0x3A00 || ev.keyDown.keyCode == 0x5B00 ||
ev.keyDown.keyCode == 0x5C00 )
// Discard standalone Shift, Ctrl, Alt, Caps Lock, Windows keys.
ev.keyDown.keyCode = kbNoKey;
else if (ev.keyDown.controlKeyState & kbRightAlt)
{
Expand Down
5 changes: 3 additions & 2 deletions source/tvision/hardwrvr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,9 @@ BOOL THardwareInfo::getKeyEvent( TEvent& event )

if( event.keyDown.keyCode == 0x2A00 || event.keyDown.keyCode == 0x1D00 ||
event.keyDown.keyCode == 0x3600 || event.keyDown.keyCode == 0x3800 ||
event.keyDown.keyCode == 0x3A00 )
// Discard standalone Shift, Ctrl, Alt, Caps Lock keys.
event.keyDown.keyCode == 0x3A00 || event.keyDown.keyCode == 0x5B00 ||
event.keyDown.keyCode == 0x5C00 )
// Discard standalone Shift, Ctrl, Alt, Caps Lock, Windows keys.
event.keyDown.keyCode = kbNoKey;
else if( event.keyDown.controlKeyState & kbRightAlt )
{
Expand Down

0 comments on commit 714eb0b

Please sign in to comment.