8
8
9
9
from sys import argv , exit
10
10
from select import select
11
- from evdev import ecodes , InputDevice , list_devices
11
+ from evdev import ecodes , InputDevice , list_devices , AbsInfo
12
12
13
13
14
14
usage = 'usage: evtest <device> [<type> <value>]'
@@ -35,13 +35,6 @@ def select_device():
35
35
return devices [int (choice )]
36
36
37
37
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
-
45
38
def print_event (e ):
46
39
if e .type == ecodes .EV_SYN :
47
40
if e .code == ecodes .SYN_MT_REPORT :
@@ -74,8 +67,16 @@ def print_event(e):
74
67
print ('Device name: {.name}' .format (device ))
75
68
print ('Device info: {.info}' .format (device ))
76
69
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 ('' )
79
80
80
81
print ('Listening for events ...\n ' )
81
82
while True :
0 commit comments