Open jf-mgd opened 8 years ago
Sorry for the delay in replying. Thanks so much for this work. I will test and commit it as soon as I can.
I had the same problem. @jf-mgd commit work fine. To not change the module code I did the following:
import inputs
inputs.EVENT_MAP = list(inputs.EVENT_MAP)
inputs.EVENT_MAP[1] = ('type_codes', list((value, key) for key, value in inputs.EVENT_TYPES))
inputs.EVENT_MAP = tuple(inputs.EVENT_MAP)
I got the same issue.
The connected devices are read using inputs.DeviceManager() in a loop and presented as list to the user on a UI. This way it is assured that all newly connected devices are picked up and disconnected devices are removed from that list as well.
When the user selects a device, i added a verification if the device is still avalable, just to be sure. But when calling inputs.DeviceManager() again and verify if the selected device is still amongst the list of connected devices, which is, the events from that device seem to be screwed up.
Using the following test code to try to enable "after launch" joystick connection:
I have the following crash when I connect a new xbox controller:
And indeed,
inputs.DeviceManager.codes['type_codes']
is empty on consecutives calls toinputs.DeviceManager.
constructors (it only contains values the first time constructor is called).