|
7 | 7 | from evdev.events import InputEvent
|
8 | 8 |
|
9 | 9 |
|
10 |
| -class DeviceInfo(object): |
11 |
| - __slots__ = 'bustype', 'product', 'vendor', 'version' |
12 |
| - |
13 |
| - def __init__(self, bustype, vendor, product, version): |
14 |
| - self.bustype = bustype |
15 |
| - self.vendor = vendor |
16 |
| - self.product = product |
17 |
| - self.version = version |
18 |
| - |
19 |
| - def __str__(self): |
20 |
| - msg = 'bus: {:04x}, product {:04x}, vendor {:04x}, version {:04x}' |
21 |
| - return msg.format(self.bustype, self.product, self.vendor, self.version) |
22 |
| - |
23 |
| - def __repr__(s): |
24 |
| - msg = (s.__class__.__name__, s.bustype, s.vendor, s.product, s.version) |
25 |
| - return '{}({:04x}, {:04x}, {:04x}, {:04x})'.format(*msg) |
26 |
| - |
27 |
| - def __eq__(self, o): |
28 |
| - return self.bustype == o.bustype \ |
29 |
| - and self.vendor == o.vendor \ |
30 |
| - and self.product == o.product \ |
31 |
| - and self.version == o.version |
32 |
| - |
33 |
| - |
34 | 10 | _AbsInfo = namedtuple('AbsInfo', ['value', 'min', 'max', 'fuzz', 'flat', 'resolution'])
|
35 | 11 | _KbdInfo = namedtuple('KbdInfo', ['repeat', 'delay'])
|
| 12 | +_DeviceInfo = namedtuple('DeviceInfo', ['bustype', 'product', 'vendor', 'version']) |
36 | 13 |
|
37 | 14 |
|
38 | 15 | class AbsInfo(_AbsInfo):
|
@@ -89,6 +66,12 @@ def __str__(self):
|
89 | 66 | return 'repeat {}, delay {}'.format(*self)
|
90 | 67 |
|
91 | 68 |
|
| 69 | +class DeviceInfo(_DeviceInfo): |
| 70 | + def __str__(self): |
| 71 | + msg = 'bus: {:04x}, product {:04x}, vendor {:04x}, version {:04x}' |
| 72 | + return msg.format(*self) |
| 73 | + |
| 74 | + |
92 | 75 | class InputDevice(object):
|
93 | 76 | '''
|
94 | 77 | A linux input device from which input events can be read.
|
|
0 commit comments