Genymobile / Genymobile/scrcpy

Right Shift key does not work with UHID keyboard (`-K`) since scrcpy 4.0

Open
#6,983 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C
Stars
150k
Forks
13.8k
Avg merge
4d 13h
Merged PRs (30d)
2

Description

Environment

  • OS: Windows 11
  • Scrcpy version: 4.0 and later
  • Installation method: Windows release
  • Device model: Galaxy Tab S11 Ultra
  • Android version: 16
  • Keyboard: K995p
  • **Keyboard layout:**Korean / US

Describe the bug

When using scrcpy with UHID keyboard mode (-K / --keyboard=uhid), the Right Shift key does not work as a Shift modifier, while the Left Shift key works correctly.

This appears to be a regression introduced in scrcpy 4.0. The same PC, keyboard, and Android device worked correctly with scrcpy versions before 4.0.

Since scrcpy 4.0 migrated from SDL2 to SDL3, this might be related to SDL3 keyboard/scancode handling, but I have not confirmed the root cause.

Steps to reproduce
  1. Start scrcpy with UHID keyboard mode and verbose logging:
scrcpy -K -Vverbose
  1. Hold Left Shift and press some keys.
  2. Release Left Shift.
  3. Hold Right Shift and press the same keys.
Expected behavior

Both Shift keys should work as Shift modifiers.

For UHID keyboard input, I would expect:

  • Left Shift: HID scancode 0xe1, modifier 0x02
  • Right Shift: HID scancode 0xe5, modifier 0x20
Actual behavior

Left Shift works correctly. For example, while holding Left Shift:

VERBOSE: keys[51] = true
VERBOSE: hid keyboard: key down scancode=51 (81) mod=02
VERBOSE: input: UHID input [1] 02 00 51 00 00 00 00 00
VERBOSE: keys[51] = false
VERBOSE: hid keyboard: key up   scancode=51 (81) mod=02
VERBOSE: input: UHID input [1] 02 00 00 00 00 00 00 00
VERBOSE: keys[52] = true
VERBOSE: hid keyboard: key down scancode=52 (82) mod=02
VERBOSE: input: UHID input [1] 02 00 52 00 00 00 00 00
VERBOSE: keys[52] = false
VERBOSE: hid keyboard: key up   scancode=52 (82) mod=02
VERBOSE: input: UHID input [1] 02 00 00 00 00 00 00 00
VERBOSE: hid keyboard: key up   scancode=e1 (225) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00

Without Shift, the same keys correctly use mod=00:

VERBOSE: keys[51] = true
VERBOSE: hid keyboard: key down scancode=51 (81) mod=00
VERBOSE: input: UHID input [1] 00 00 51 00 00 00 00 00
VERBOSE: keys[51] = false
VERBOSE: hid keyboard: key up   scancode=51 (81) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00
VERBOSE: keys[52] = true
VERBOSE: hid keyboard: key down scancode=52 (82) mod=00
VERBOSE: input: UHID input [1] 00 00 52 00 00 00 00 00
VERBOSE: keys[52] = false
VERBOSE: hid keyboard: key up   scancode=52 (82) mod=00
VERBOSE: input: UHID input [1] 00 00 00 00 00 00 00 00

However, when I press Right Shift, it does not work as a Shift modifier.

In particular, I do not see the expected Right Shift HID scancode:

scancode=e5 (229)

or the expected Right Shift modifier:

mod=20

in the verbose output.

The issue is reproducible with scrcpy 4.0 and later, while the same setup works correctly with versions before 4.0.

Could this be a regression related to the SDL2 → SDL3 migration in scrcpy 4.0, possibly in the keyboard event/scancode handling?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with scrcpy -K -Vverbose and inspect the keyboard event and HID scancode handling involved in the SDL2-to-SDL3 migration. Compare scrcpy 4.0 with a pre-4.0 version to identify why Right Shift does not produce scancode e5 or modifier 20; done means both Shift keys produce the expected UHID behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
desktop
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.