Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library doesn't work when USB controller is plugged in while Python is running #87

Open
geajack opened this issue Mar 20, 2020 · 1 comment

Comments

@geajack
Copy link

geajack commented Mar 20, 2020

I have a generic USB gamepad (non X-Box). If I plug it in before starting the Python interpreter, then get_gamepad() works as expected. However, if I start the Python interpreter and then run get_gamepad(), I get an UnpluggedError.

Based on what I saw in another ticket here, I tried to "refresh" the devices by calling DeviceManager(), but then I get:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jack/.local/lib/python3.7/site-packages/inputs.py", line 3188, in __init__
    self._post_init()
  File "/home/jack/.local/lib/python3.7/site-packages/inputs.py", line 3200, in _post_init
    self._find_leds()
  File "/home/jack/.local/lib/python3.7/site-packages/inputs.py", line 3359, in _find_leds
    self._parse_led_path(path)
  File "/home/jack/.local/lib/python3.7/site-packages/inputs.py", line 3366, in _parse_led_path
    self.leds.append(SystemLED(self, path, name))
  File "/home/jack/.local/lib/python3.7/site-packages/inputs.py", line 3082, in __init__
    super(SystemLED, self).__init__(manager, path, name)
  File "/home/jack/.local/lib/python3.7/site-packages/inputs.py", line 3003, in __init__
    self._post_init()
  File "/home/jack/.local/lib/python3.7/site-packages/inputs.py", line 3086, in _post_init
    self._led_type_code = self.manager.get_typecode('LED')
  File "/home/jack/.local/lib/python3.7/site-packages/inputs.py", line 3421, in get_typecode
    return self.codes['type_codes'][name]
KeyError: 'LED'

And get_gamepad() continues to exhibit the same unexpected behavior.

I'm doing this on a Lenovo Yoga C930 with Ubuntu 19.10.

@AndriyBench
Copy link

Hey, did you ever figure this out? Im running into a simmilar issue where I have a program that can parse xbox controller input. If I plug in the Xbox controller and start the program, the controller will be recongnized but if I start the program and then plug in the controller the controller will not be recognized. I have a seperate "start" button that tells the program to kick off the xbox listening thread, which calls "events = get_gamepad()" command. I have a feeling this issue might be happening because of how the get_gamepad lib is getting initialized.... "from inputs import get_gamepad"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants