Skip to content

Conversation

Haruka-127
Copy link

Summary of Changes

  1. Fixed unrecognized \/_ key
    In Japanese keyboard environments, Moonlight was unable to detect input from the key immediately to the left of the right Shift (the \/_ key). This update ensures that those scancodes are now correctly recognized and processed.

  2. Corrected inverted Hankaku/Zenkaku key events
    On Japanese keyboards, the key immediately to the left of 1 (the Hankaku/Zenkaku key) was generating its PRESSED and RELEASE events in reverse. We’ve added logic to invert those two event states so that PRESSED and RELEASE are reported correctly.

Note: It’s not yet known whether these changes might conflict with other non-Japanese keyboard layouts.


Test Environment

  • Client: Windows 11 24H2, Moonlight on Surface Go 4 (built-in keyboard)
  • Server: Sunshine v2025.122.141614 on Windows 11 24H2

KEY_ACTION_DOWN,
modifiers,
shouldNotConvertToScanCodeOnServer ? SS_KBE_FLAG_NON_NORMALIZED : 0);
m_KeysDown.insert(keyCode);
Copy link
Member

@cgutman cgutman Jul 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like it might be a broader SDL bug. Can you try one of the SDL test apps (ex: testgles2) with SDL_EVENT_LOGGING=1 environment variable set and see if you get reversed up/down events there too?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the issue lies in the fact that, on Japanese keyboards, when the Hankaku/Zenkaku (half-width/full-width) key is pressed, the OS issues a virtual key code that behaves differently from standard keys — it sends a "true" (released) event and immediately follows it with a "false" (pressed) event. (Scan code 41)

Here are the keyboard inputs obtained using a keylogger.

Datetime Virtual Key Code Scan Code Extended Key Flag Injected Flag Context Code Transition State Flag Timestamp Extra Info Virtual Key Name Display Name
07/06 12:02:44.407 65 30 False False False False 298892765 0 VK_A A key
07/06 12:02:44.551 65 30 False False False True 298892921 0 VK_A A key
07/06 12:02:44.947 66 48 False False False False 298893312 0 VK_B B key
07/06 12:02:45.038 66 48 False False False True 298893406 0 VK_B B key
07/06 12:02:46.342 67 46 False False False False 298894703 0 VK_C C key
07/06 12:02:46.431 67 46 False False False True 298894796 0 VK_C C key
07/06 12:02:47.435 244 41 False False False True 298895796 0 VK_OEM_ENLW OEM specific
07/06 12:02:47.437 243 41 False False False False 298895796 0 VK_OEM_AUTO OEM specific

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants