-
Notifications
You must be signed in to change notification settings - Fork 88
Open
Labels
Description
Using the following test code to try to enable "after launch" joystick connection:
# -*- coding: windows-1252 -*-
import inputs
from time import sleep
from traceback import print_exc
try:
while 1:
# Wait for a joystick to be connected
print "Please connect a joystick..."
while 1:
try:
inputs.devices = inputs.DeviceManager() # Rescan OS for joystick.
inputs.get_gamepad()
break
except inputs.UnpluggedError:
sleep(1.0 / 30.0)
# Print connected device name
print(inputs.devices.gamepads[0])
# While joystick is connected
try:
while 1:
try:
events = inputs.get_gamepad()
for event in events:
print(event.ev_type, event.code, event.state)
except inputs.UnknownEventType:
pass
except inputs.UnpluggedError:
print("Joystick unplugged!")
except:
print_exc()I have the following crash when I connect a new xbox controller:
File "D:\projets\tests\lib\site-packages\inputs.py", line 2713, in get_gamepad
return gamepad.read()
File "D:\projets\tests\lib\site-packages\inputs.py", line 2101, in read
return next(iter(self))
File "D:\projets\tests\lib\site-packages\inputs.py", line 2192, in __iter__
self.__check_state()
File "D:\projets\tests\lib\site-packages\inputs.py", line 2205, in __check_state
self.__handle_changed_state(state)
File "D:\projets\tests\lib\site-packages\inputs.py", line 2270, in __handle_changed_state
events.extend(self.__get_axis_events(state, timeval))
File "D:\projets\tests\lib\site-packages\inputs.py", line 2304, in __get_axis_events
events = self.__emulate_axis(axis_changes, timeval)
File "D:\projets\tests\lib\site-packages\inputs.py", line 2316, in __emulate_axis
timeval=timeval)
File "D:\projets\tests\lib\site-packages\inputs.py", line 2229, in create_event_object
event_type)
UnknownEventType: ("We don't know what kind of event a %s is.", 'Absolute')And indeed, inputs.DeviceManager.codes['type_codes'] is empty on consecutives calls to inputs.DeviceManager. constructors (it only contains values the first time constructor is called).