WhiteMagic / JoystickGremlin

A tool for configuring and managing joystick devices.
http://whitemagic.github.io/JoystickGremlin/
GNU General Public License v3.0
313 stars 45 forks source link

Fail to recognice XBOX controller on Bluetooth #455

Open lscheffler opened 1 year ago

lscheffler commented 1 year ago

I do not know if this is related to #347 .

New Device: XBOX ELITE 2 controller

The error started on my comp today. I can turn the error on off in turning my XBOX controller on / off. All other devices are running. In special, it happens when the controller is connected via Bluetooth. So I have

This is a dump of the messagebox showing the error - that what the log shows too.

---------------------------
Error
---------------------------
Uncaught exception:
Traceback (most recent call last):
   File "joystick_gremlin.py", line 1269, in <module>
   File "gremlin\joystick_handling.py", line 203, in joystick_devices_initialization
   File "dill\__init__.py", line 538, in get_device_information_by_index
   File "dill\__init__.py", line 357, in __init__
 UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe4 in position 42: invalid continuation byte

---------------------------
OK   
---------------------------

This error is followed by the Failed to execute script messagebox.

Let me know if I can provide additional information.

WhiteMagic commented 1 year ago

This sounds like the controller gets a name that contains odd/invalid UTF8 characters when connected via Bluetooth.

lscheffler commented 1 year ago

It's a common MS XBOX Elite 2 Controller Nothing fancy (except, MS ....)

Anything I can provide / check?

The name I see in the BT list in the registry does not hold char 0xE4, and is shorter then 42 signs Name and LEName in HKLM\SYSTEM\CurrentControlSet\Services\BTHPORT\Parameters\Devices are just 24 byte RegBinary) followed by 0x00

akors commented 1 year ago

Similar error happens to me:

grafik

My Controller is a Xbox Wireless Controller M.

My Windows Locale is set to de;Deutsch

akors commented 1 year ago

Would it break anything to just

https://github.com/WhiteMagic/JoystickGremlin/blob/54cf26ac7b3b8f3d4c3807e5af3f7ebb36be9125/dill/__init__.py#L357


- self.name = data.name.decode("utf-8")
+ self.name = data.name.decode("utf-8", errors="ignore")
WhiteMagic commented 1 year ago

Unknown without trying it out. I suspect that it might result in empty strings which could become problematic if places expect them to be non-zero. Also this won't fix the issue but merely hide it. Somewhere something isn't consistent enough with UTF and causes that problem, so fixing that would be the actual solution.

lscheffler commented 1 year ago

In general you are right.
But you agree that Microsoft will hardly change something because a third party tool fails? The error renders Joystick Gremlin useless if the XBOX ELITE 2 controller is connected via bluetooth. If there is a string, or a generic device xx is a minor problem. All my choice is now using the controller via USB, because else nothing works as expected.

akors commented 2 weeks ago

Would it break anything to just

https://github.com/WhiteMagic/JoystickGremlin/blob/54cf26ac7b3b8f3d4c3807e5af3f7ebb36be9125/dill/__init__.py#L357

- self.name = data.name.decode("utf-8")
+ self.name = data.name.decode("utf-8", errors="ignore")

I have FINALLY managed to build Joystick Gremlin with this patch (not so easy considering the age of the dependencies), and I can confirm that it does not crash anymore.