Compare commits
3 Commits
73aadeb9da
...
11186d3e79
Author | SHA1 | Date | |
---|---|---|---|
11186d3e79 | |||
9b85670fc2 | |||
b607466efc |
|
@ -69,8 +69,13 @@ def convert_keycode_to_name(code):
|
||||||
def eat_events(dev):
|
def eat_events(dev):
|
||||||
'''Consume and ignore events on a device until there are none.'''
|
'''Consume and ignore events on a device until there are none.'''
|
||||||
|
|
||||||
while dev.read_one() is not None:
|
while True:
|
||||||
pass
|
try:
|
||||||
|
event = dev.read_one()
|
||||||
|
if event is None:
|
||||||
|
return
|
||||||
|
except Exception, e:
|
||||||
|
return
|
||||||
|
|
||||||
def get_next_pressed_button_name(dev):
|
def get_next_pressed_button_name(dev):
|
||||||
'''Wait for the next button press and report its xboxdrv name.'''
|
'''Wait for the next button press and report its xboxdrv name.'''
|
||||||
|
@ -97,9 +102,9 @@ def get_next_maxed_axis(dev, mappings):
|
||||||
absinfo = dict(dev.capabilities()[evdev.ecodes.EV_ABS])[event.code]
|
absinfo = dict(dev.capabilities()[evdev.ecodes.EV_ABS])[event.code]
|
||||||
axis = evdev.ecodes.ABS[event.code]
|
axis = evdev.ecodes.ABS[event.code]
|
||||||
# ... and if the min or max has been reached, return it.
|
# ... and if the min or max has been reached, return it.
|
||||||
if event.value == absinfo.min:
|
if event.value <= absinfo.min + 20:
|
||||||
return 'min', axis
|
return 'min', axis
|
||||||
elif event.value == absinfo.max:
|
elif event.value >= absinfo.max - 20:
|
||||||
return 'max', axis
|
return 'max', axis
|
||||||
|
|
||||||
def ask_user_for_keymap(dev):
|
def ask_user_for_keymap(dev):
|
||||||
|
|
|
@ -28,6 +28,7 @@ def list_active_evdev():
|
||||||
r,w,x = select.select(devices, [], [])
|
r,w,x = select.select(devices, [], [])
|
||||||
for fd in r:
|
for fd in r:
|
||||||
for event in list(devices[fd].read())[:1]:
|
for event in list(devices[fd].read())[:1]:
|
||||||
|
if event.type == evdev.ecodes.EV_KEY:
|
||||||
output.append(devices[fd].fn)
|
output.append(devices[fd].fn)
|
||||||
anyInput = True
|
anyInput = True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user