[Issue]: Sony Bluetooth keyboard with PlayStation keys shows up on the host as a second DualSense

Open
#1,636 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
android, java

Research direction

Start by reading ControllerHandler.sendControllerArrival() and tracing how Android input devices are classified and mapped to controller buttons. Reproduce with a Sony N1158 keyboard and a DualSense paired to a Shield, then check whether the keyboard is announced as a controller and whether its PlayStation keys map as described. Done means the keyboard no longer creates an unwanted controller, or its buttons map correctly if it is supported as one.

Written by the indexing model from the issue text.

Description

Describe the bug

I have a Sony wireless keyboard (model N1158) paired to my Shield. Besides the normal keys it has the PlayStation face buttons and a d-pad printed on some keys. The first time I press one of those keys during a stream, Moonlight announces a new controller of type PS with capabilities 0x00. The host creates a virtual DualSense for it, so Steam lists two DualSense controllers with the same artwork and there is no way to tell which one is the real pad. I only use the keyboard as a keyboard, so this extra pad just causes confusion.

Most of the PlayStation keys on that pad also arrive as a different button. This is what Steam showed for each key.

Key on the keyboard Button seen on the host
Triangle Square
Square Cross
Cross Circle
Circle Cross
L1 Triangle
L2 L1
R1 Cross
R2 R1
L3 Create (Select)
R3 Options (Start)
Select left trigger
Start right trigger

The keyboard's normal arrow keys do nothing on the pad, while its d-pad keys move it.

As far as I can tell from ControllerHandler.sendControllerArrival(), the controller type is picked from the vendor ID alone, so any Sony device that Android reports with gamepad buttons becomes a PS controller. The capabilities are 0x00 because the keyboard has no trigger axes.

It would help if Moonlight either ignored devices like this one, which are keyboards first and have no analog sticks, or offered a way to exclude a device from being sent as a controller. If they are meant to work as controllers, the face buttons should map to the buttons printed on the keys.

Steps to reproduce
  1. Pair a Sony wireless keyboard with PlayStation keys (model N1158) and a real controller (I use a DualSense) to the Shield.
  2. Start a stream with Steam Big Picture.
  3. Press one of the keyboard's PlayStation face-button or d-pad keys.
  4. Open Steam's controller settings. A second DualSense is listed, and it reacts only to the keyboard.
Affected games

Steam Big Picture. The extra controller is created on the host as soon as the key is pressed, so it is not specific to a game.

Other Moonlight clients

Not tested. I only have the Shield as a client.

Moonlight adjusted settings

Yes

Moonlight adjusted settings (please complete the following information)

Mostly video and audio settings. The built-in USB gamepad driver is off. The keyboard and the DualSense are both connected over Bluetooth.

Moonlight default settings

Not tested.

Gamepad-related connection issue

No. No gamepads are connected to the host directly.

Gamepad-related input issue

Not applicable. The real gamepad works, the problem is the extra controller.

Gamepad-related streaming issue

Not tested with html5gamepad.com, but the host log shows the extra controller arriving from the client (below).

Android version

Android 11

Device model

NVIDIA Shield TV Pro

Server PC OS version

Debian 13, streaming host Wolf (games-on-whales/wolf) in Docker

Server PC GeForce Experience version

Not applicable, the host is Wolf on Linux.

Server PC Nvidia GPU driver version

595.91.07

Server PC antivirus and firewall software

None

Relevant log output

Host log at the moment the extra controller appeared. Controller 0 is the real DualSense and controller 1 an Xbox pad.

16:29:52 [INPUT] CONTROLLER_ARRIVAL controller 0 type 2 capabilities 0x01 button flags 0x00f7ff00 (held pads: [])
16:31:24 [INPUT] CONTROLLER_ARRIVAL controller 1 type 1 capabilities 0x03 button flags 0x00f7ff00 (held pads: [0])
16:40:18 [INPUT] CONTROLLER_ARRIVAL controller 2 type 2 capabilities 0x00 button flags 0x00f7ff00 (held pads: [0, 1])
16:40:18 [INPUT] active_gamepad_mask changed 0x0003 -> 0x0007 (packet for controller 2, held pads: [0, 1, 2])

To be sure it is the keyboard, I counted the bytes read from each virtual pad's input device on the host. With the real DualSense switched off and only the keyboard's PlayStation keys pressed, only the pad created for controller 2 received input. While I used only the real DualSense, controller 2 received nothing.

Additional context

Moonlight for Android v12.2. The host is Wolf, which creates a virtual DualSense for every PS controller the client announces, so the extra controller is fully visible to games.

Dominant language
C
Stars
7.5k
Forks
1.8k
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

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.

More from moonlight-stream/moonlight-android

All issues in moonlight-stream/moonlight-android

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.