Skip to content

Commit b6f2637

Browse files
committed
update example application
1 parent a0bf03d commit b6f2637

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

bin/evtest.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from sys import argv, exit
1010
from select import select
11-
from evdev import ecodes, InputDevice, list_devices
11+
from evdev import ecodes, InputDevice, list_devices, AbsInfo
1212

1313

1414
usage = 'usage: evtest <device> [<type> <value>]'
@@ -35,13 +35,6 @@ def select_device():
3535
return devices[int(choice)]
3636

3737

38-
def print_capabilities(dev):
39-
for type, codes in dev.capabilities().items():
40-
print('Type {} {}'.format(ecodes.ecodes[type], type))
41-
for name, value in codes:
42-
print(' Code {:<4} {}'.format(value, name))
43-
44-
4538
def print_event(e):
4639
if e.type == ecodes.EV_SYN:
4740
if e.code == ecodes.SYN_MT_REPORT:
@@ -74,8 +67,16 @@ def print_event(e):
7467
print('Device name: {.name}'.format(device))
7568
print('Device info: {.info}'.format(device))
7669

77-
cap = device.capabilities(verbose=True).keys()
78-
print('Device capabilities: {}'.format(' '.join(i[0] for i in cap)))
70+
print('Device capabilities:')
71+
for type, codes in device.capabilities(verbose=True).items():
72+
print(' Type {} {}:'.format(*type))
73+
for i in codes:
74+
if isinstance(i[1], AbsInfo):
75+
print(' Code {:<4} {}:'.format(*i[0]))
76+
print(' {}'.format(i[1]))
77+
else:
78+
print(' Code {:<4} {}'.format(*i))
79+
print('')
7980

8081
print('Listening for events ...\n')
8182
while True:

0 commit comments

Comments
 (0)