games-on-whales / wolf

Stream virtual desktops and games running in Docker
https://games-on-whales.github.io/wolf/stable/
MIT License
292 stars 20 forks source link

Dev-Input-Protocol Testing - Nintendo Pro Controllers incorrect mapping #56

Closed shymian closed 4 months ago

shymian commented 5 months ago

Per discussion, here is the testing of the mapping issues I am seeing using a Nintendo Pro Controller (8BitDo Pro 2 in Switch mode)

Wolf image used for testing ghcr.io/games-on-whales/wolf:dev-input-protocol

Host machine sees this device as: Input device ID: bus 0x3 vendor 0x57e product 0x2009 version 0x8111 Input device name: "Nintendo Switch Pro Controller"

Virtual Device created by Wolf Input device ID: bus 0x3 vendor 0x57e product 0x2009 version 0xab00 Input device name: "Wolf Nintendo (virtual) pad"

General mapping issues:

Full list of mapping testing

| Physical Button | Yuzu Mapped To | When Pressed Appears As | Yuzu Should Be | Linux EventCode (Host) | Status?   |
|-----------------+----------------+-------------------------+----------------+------------------------+-----------|
| L-Stick Up      | Axis 1+        | L-Stick Up              | Axis 1+        | Event code 1 (ABS_Y)S- | OK        |
| L-Stick Down    | Axis 1-        | L-Down                  | Axis 1-        | +                      | OK        |
| L-Stick Left    | Axis 0-        | L-Left                  | Axis 0-        | EC 0 (ABS_X)         - | OK        |
| L-Stick Right   | Axis 0+        | L-Right                 | Axis 0+        | +                      | OK        |
| L-Stick Pressed | Button 12      | Minus                   | Button 7       | EC 317 (BTN_THUMBL)    | Needs fix |
| R-Stick Up      | Axis 3+        | R-Up                    | Axis 3+        | EC 4 (ABS_RY)        - | OK        |
| R-Stick Down    | Axis 3-        | R-Down                  | Axis 3-        | +                      | OK        |
| R-Stick Left    | Axis 2-        | No response             | Axis 2-        | EC 3 (ABS_RX)        - | Needs fix |
| R-Stick Right   | Axis 2+        | No response             | Axis 2+        | +                      | Needs fix |
| R-Stick Pressed | Button 13      | Plus                    | Button 8       | EC 318 (BTN_THUMBR)    | Needs fix |
| D-Pad Up        | Hat Up         | D-Up                    | Button 11      | EC 17 (ABS_HAT0Y) -1   | OK        |
| D-Pad Down      | Hat Down       | D-Down                  | Button 12      | EC 17 (ABS_HAT0Y)  1   | OK        |
| D-Pad Left      | Hat Left       | D-Left                  | Button 13      | EC 16 (ABS_HAT0X) -1   | OK        |
| D-Pad Right     | Hat Right      | D-Right                 | Button 14      | EC 16 (ABS_HAT0x)  1   | OK        |
| Plus            | Button 10      | L-Trigger               | Button 6       | EC 315 (BTN_START)     | Needs fix |
| Minus           | Button 9       | R-Bumper                | Button 4       | EC 314 (BTN_SELECT)    | Needs fix |
| Home            | Button 11      | R-Trigger               | Button 5       | EC 316 (BTN_MODE)      | Needs fix |
| Capture         | Button 4       | NA (nothing)            | Button 15      | EC 309 (BTN_Z)         | Missing   |
| A               | Button 1       | B                       | Button 1       | EC 305 (BTN_EAST)      | Needs fix |
| B               | Button 0       | A                       | Button 0       | EC 304 (BTN_SOUTH)     | Needs fix |
| X               | Button 2       | X                       | Button 3       | EC 307 (BTN_NORTH)     | OK        |
| Y               | Button 3       | Y                       | Button 2       | EC 308 (BTN_WEST)      | OK        |
| L (Bumper)      | Button 5       | Capture                 | Button 9       | EC 310 (BTN_TL)        | Needs fix |
| R (Bumper)      | Button 6       | L-Bumper                | Button 10      | EC 311 (BTN_TR)        | Needs fix |
| ZL (Trigger)    | Button 7       | R-Stick Right           | Axis 4         | EC 312 (BTN_TL2)       | Needs fix |
| ZR (Trigger)    | Button 8       | No response             | Axis 5         | EC 313 (BTN_TR2)       | Needs fix |
| Motion          | ?              |                         |                |                        |           |
| Vibration       | ?              |                         |                | 80,81,88,89,90,96      |           |

Other notes Reviewing event codes between the host device and virtual device (via evtest) appear generally the same. So I'm a bit confused as to why the mappings are off when used within applications. Is it possible Moonlight is changing these mappings? I'm not familiar enough where to look within the code to check this.

Additionally, evtest reports lots of L-Stick movement within the virtual device even though no activity is taking place on the physical device. This at times appears as chaotic movement on screen.

Let me know if any clarification is needed.

shymian commented 5 months ago

Here's a comparison of the host device vs virtual device. Both running on the same machine as part of testing.

| Host Device                                                         | Virtual Device                                                      |
| Input driver version is 1.0.1                                       | Input driver version is 1.0.1                                       |
| Input device ID: bus 0x3 vendor 0x57e product 0x2009 version 0x8111 | Input device ID: bus 0x3 vendor 0x57e product 0x2009 version 0xab00 |
| Input device name: "Nintendo Switch Pro Controller"                 | Input device name: "Wolf Nintendo (virtual) pad"                    |
|---------------------------------------------------------------------+---------------------------------------------------------------------|
| Supported events:                                                   | Supported events:                                                   |
| Event type 0 (EV_SYN)                                               | Event type 0 (EV_SYN)                                               |
| Event type 1 (EV_KEY)                                               | Event type 1 (EV_KEY)                                               |
| Event code 304 (BTN_SOUTH)                                          | Event code 304 (BTN_SOUTH)                                          |
| Event code 305 (BTN_EAST)                                           | Event code 305 (BTN_EAST)                                           |
| Event code 307 (BTN_NORTH)                                          | Event code 307 (BTN_NORTH)                                          |
| Event code 308 (BTN_WEST)                                           | Event code 308 (BTN_WEST)                                           |
| Event code 309 (BTN_Z)                                              |                                                                     |
| Event code 310 (BTN_TL)                                             | Event code 310 (BTN_TL)                                             |
| Event code 311 (BTN_TR)                                             | Event code 311 (BTN_TR)                                             |
| Event code 312 (BTN_TL2)                                            |                                                                     |
| Event code 313 (BTN_TR2)                                            |                                                                     |
| Event code 314 (BTN_SELECT)                                         | Event code 314 (BTN_SELECT)                                         |
| Event code 315 (BTN_START)                                          | Event code 315 (BTN_START)                                          |
| Event code 316 (BTN_MODE)                                           | Event code 316 (BTN_MODE)                                           |
| Event code 317 (BTN_THUMBL)                                         | Event code 317 (BTN_THUMBL)                                         |
| Event code 318 (BTN_THUMBR)                                         | Event code 318 (BTN_THUMBR)                                         |
|                                                                     |                                                                     |
| Event type 3 (EV_ABS)                                               | Event type 3 (EV_ABS)                                               |
| Event code 0 (ABS_X)                                                | Value   -224                                                        |
| Value     96                                                        | Min   -32768                                                        |
| Min   -32767                                                        | Max    32767                                                        |
| Max    32767                                                        | Fuzz      16                                                        |
| Fuzz     250                                                        | Flat     128                                                        |
| Flat     500                                                        | Value   5702                                                        |
| Event code 1 (ABS_Y)                                                | Min   -32768                                                        |
| Value   -366                                                        | Max    32767                                                        |
| Min   -32767                                                        | Fuzz      16                                                        |
| Max    32767                                                        | Flat     128                                                        |
| Fuzz     250                                                        | Event code 2 (ABS_Z)                                                |
| Flat     500                                                        | Value      0                                                        |
| Event code 3 (ABS_RX)                                               | Min        0                                                        |
| Value     96                                                        | Max      255                                                        |
| Min   -32767                                                        | Value      0                                                        |
| Max    32767                                                        | Min   -32768                                                        |
| Fuzz     250                                                        | Max    32767                                                        |
| Flat     500                                                        | Fuzz      16                                                        |
| Event code 4 (ABS_RY)                                               | Flat     128                                                        |
| Value   -366                                                        | Value      0                                                        |
| Min   -32767                                                        | Min   -32768                                                        |
| Max    32767                                                        | Max    32767                                                        |
| Fuzz     250                                                        | Fuzz      16                                                        |
| Flat     500                                                        | Flat     128                                                        |
|                                                                     | Event code 5 (ABS_RZ)                                               |
|                                                                     | Value      0                                                        |
|                                                                     | Min        0                                                        |
|                                                                     | Max      255                                                        |
|                                                                     |                                                                     |
| Event code 16 (ABS_HAT0X)                                           | Event code 16 (ABS_HAT0X)                                           |
| Value      0                                                        | Value      0                                                        |
| Min       -1                                                        | Min       -1                                                        |
| Max        1                                                        | Max        1                                                        |
| Event code 17 (ABS_HAT0Y)                                           | Event code 17 (ABS_HAT0Y)                                           |
| Value      0                                                        | Value      0                                                        |
| Min       -1                                                        | Min       -1                                                        |
| Max        1                                                        | Max        1                                                        |
| Event type 21 (EV_FF)                                               | Event type 21 (EV_FF)                                               |
| Event code 80 (FF_RUMBLE)                                           | Event code 80 (FF_RUMBLE)                                           |
| Event code 81 (FF_PERIODIC)                                         | Event code 81 (FF_PERIODIC)                                         |
|                                                                     | Event code 82 (FF_CONSTANT)                                         |
|                                                                     | Event code 87 (FF_RAMP)                                             |
| Event code 88 (FF_SQUARE)                                           |                                                                     |
| Event code 89 (FF_TRIANGLE)                                         |                                                                     |
| Event code 90 (FF_SINE)                                             | Event code 90 (FF_SINE)                                             |
| Event code 96 (FF_GAIN)                                             | Event code 96 (FF_GAIN)                                             |
|                                                                     |                                                                     |

Edit: updated formatted and correctly layout of rumble events

shymian commented 5 months ago

The following now worked correctly on initial connection: Minus (Select) Plus (Start) Home L-Bumper R-Bumper

Still incorrect: A/B are still reversed Pressing the B button (physical button south) shows as BTN_EAST in evtest for the wolf virtual controller Pressing the A button (physical button east) show as BTN_SOUTH in evtest No input from L/R-Triggers shows as ABS_Z and ABS_RZ rather than BTN_TL2 / BTN_TR2 No input from Capture button (BTN_Z) ~R-Stick has no horizontal movement by default~ R stick works in Pegasus, not in Yuzu. So might be a mapping issue. R stick shows correct ABS_RX / ABS_RY in evtest when input is provided

Sticks show immediate phantom input after the first time touching them. evtest shows lots of small inputs back and forth on the sticks even when not touching them. Fuzz on host is 250, while virtual device is 16. Flat is 500 on host, and 128 in virtual. Not quite sure what they settings do, but might play into it?

Edit: typo and more detail