scrcpy icon indicating copy to clipboard operation
scrcpy copied to clipboard

My game doesn't detect a keyboard from scrcpy

Open KarimAkra opened this issue 1 month ago • 3 comments

When running our game (Friday Night Funkin') and using scrcpy the game doesn't find that there's a keyboard connected at all The input works fine which is great but some keyboard-specific logic doesn't get executed because of this issue

I don't think it's an issue with scrcpy itself but rather an issue with how our game is handling keyboard detection so I wonder if we can get any help on how we can patch this up on our end

We tried using this to check out if we have a keyboard connected

context.getResources().getConfiguration().keyboard > 1;

It works for keyboard connected directly via bluetooth or USB but it doesn't seem to account to the scrcpy hid keyboard device

Any help we can get would be appreciated 🙏

KarimAkra avatar Nov 18 '25 19:11 KarimAkra

The issue isn’t with scrcpy itself — it does expose a virtual HID keyboard, but with how Android reports keyboard presence to apps.

context.getResources().getConfiguration().keyboard > 1 ^ only reflects built-in vs. physical hardware keyboards detected at the framework level. Scrcpy’s HID keyboard does not register as a hardware keyboard in the Android configuration, so the system configuration value never changes.

That's why USB/Bluetooth keyboards is detected, while scrcpy keyboard is not detected, even though key events are delivered correctly. Android never updates Configuration.keyboard for synthetic HID devices.

devbutlazy avatar Nov 22 '25 13:11 devbutlazy

The issue isn’t with scrcpy itself — it does expose a virtual HID keyboard, but with how Android reports keyboard presence to apps.

I'm aware of that since we can receive input key codes just fine, I always assumed that the issue is with the method we have set for detecting the connected keyboards rather than scrcpy misbehaving

That's why USB/Bluetooth keyboards is detected, while scrcpy keyboard is not detected, even though key events are delivered correctly. Android never updates Configuration.keyboard for synthetic HID devices. Are you aware of any other methods that would work for virtual HID devices like scrcpy's that we could use to solve our issue? key codes inputs get sent from scrcpy just fine but our game still has some logic that depends on wether we see a keyboard device is connected or not

KarimAkra avatar Nov 24 '25 13:11 KarimAkra

Yeah, for virtual HID devices like scrcpy's, Configuration.keyboard and Configuration.hardKeyboardHidden will never update because Android only flips those flags for hardware-attached keyboards recognized by the InputManager HAL layer.

Scrcpy's HID keyboard injects events at the Input subsystem level, but it does not register a "physical keyboard" with the framework, so anything that reads from Configuration or DeviceConfig will always think "no keyboard".

devbutlazy avatar Nov 24 '25 16:11 devbutlazy