jfedor2 / hid-remapper

USB input remapping dongle
Other
1.07k stars 125 forks source link

Remapper WebUI unsuable when pairing Bluetooth Game controller #95

Open HVR88 opened 11 months ago

HVR88 commented 11 months ago

Testing with macOS 14.1 (latest RC), webUI running in current version of Chrome.

Testing hardware Remapper on BT nrf52840 board Remapper on Single Pico board

XBOX One Controller

Release r2023-10-18

On BT board: After successfully pairing the BT game controller, the mouse cursor begins to move continuously down-left.

This occurs even when there are no mappings and the check-boxes for "Unmapped inputs passthrough on layer" are all disabled.

While the mouse cursor is moving, behavior from clicking buttons on the controller also perform unexpected/odd actions.

The UI/computer are unusable as this is happening because the system mouse can't be used and trying to navigate the webUI with keyboard it's still not possible to make necessary selections.

Regression/Previous Remapper Release 2023-10-11

When previously testing the wired Pico version, un-checking all the Passthrough boxes seemed to solve the issue.

HVR88 commented 11 months ago

So I got the problem to happen on the Pico board that's still flashed with the r2023-10-11 firmware while using the current WebUI. And then I got it to go away on both boards, DOH!

By loading/saving the configuration to the board again the mouse stopped moving and I'm able to monitor all button presses and axis movements without them affecting the OS/System. Weird that saving the first time didn't do the same thing?

jfedor2 commented 11 months ago

The issue is caused by the fact that mouse cursor movement uses the same usages in USB HID as the left analog stick on a game controller (Bluetooth uses the same standard). Specifically it's caused by the fact that while mouse movement is represented by a signed value (zero meaning no movement), analog sticks are typically represented by an unsigned 0-255 value with 128 being the neutral position (or 0-65535 with 32768 being the neutral position). So if you connect a game controller with passthrough enabled, it results in the mouse cursor quickly going down-right. Wired Xbox controllers are an exception here as they use a signed value with -32768-32767 range and 0 being neutral. An additional issue here is that even if you disconnect the device, HID Remapper remembers the last input state.

Normally a computer distinguishes between these usages by looking at the top level collections they are in (mouse or gamepad), but HID Remapper (currently) ignores those.

HVR88 commented 11 months ago

Thank you for the detailed description. I'll keep an eye on this as I continue to test to see if I ever get into a situation again where disabling Passthrough doesn't work.