evdev 1.6.1__tar.gz → 1.7.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. {evdev-1.6.1 → evdev-1.7.1}/MANIFEST.in +0 -3
  2. evdev-1.7.1/PKG-INFO +76 -0
  3. evdev-1.7.1/README.md +27 -0
  4. {evdev-1.6.1 → evdev-1.7.1}/evdev/__init__.py +2 -2
  5. {evdev-1.6.1 → evdev-1.7.1}/evdev/device.py +66 -69
  6. {evdev-1.6.1 → evdev-1.7.1}/evdev/ecodes.py +6 -8
  7. {evdev-1.6.1 → evdev-1.7.1}/evdev/eventio.py +21 -20
  8. {evdev-1.6.1 → evdev-1.7.1}/evdev/eventio_async.py +10 -8
  9. {evdev-1.6.1 → evdev-1.7.1}/evdev/events.py +33 -38
  10. {evdev-1.6.1 → evdev-1.7.1}/evdev/evtest.py +39 -42
  11. {evdev-1.6.1 → evdev-1.7.1}/evdev/ff.py +68 -66
  12. {evdev-1.6.1 → evdev-1.7.1}/evdev/genecodes.py +18 -16
  13. {evdev-1.6.1 → evdev-1.7.1}/evdev/input.c +9 -9
  14. {evdev-1.6.1 → evdev-1.7.1}/evdev/uinput.c +41 -16
  15. {evdev-1.6.1 → evdev-1.7.1}/evdev/uinput.py +147 -50
  16. {evdev-1.6.1 → evdev-1.7.1}/evdev/util.py +16 -18
  17. evdev-1.7.1/evdev.egg-info/PKG-INFO +76 -0
  18. {evdev-1.6.1 → evdev-1.7.1}/evdev.egg-info/SOURCES.txt +6 -3
  19. evdev-1.7.1/pyproject.toml +51 -0
  20. evdev-1.7.1/setup.cfg +4 -0
  21. evdev-1.7.1/setup.py +106 -0
  22. evdev-1.7.1/tests/test_ecodes.py +31 -0
  23. evdev-1.7.1/tests/test_events.py +27 -0
  24. evdev-1.7.1/tests/test_uinput.py +116 -0
  25. evdev-1.7.1/tests/test_util.py +21 -0
  26. evdev-1.6.1/PKG-INFO +0 -48
  27. evdev-1.6.1/README.rst +0 -24
  28. evdev-1.6.1/evdev.egg-info/PKG-INFO +0 -48
  29. evdev-1.6.1/evdev.egg-info/zip-safe +0 -1
  30. evdev-1.6.1/setup.cfg +0 -18
  31. evdev-1.6.1/setup.py +0 -147
  32. {evdev-1.6.1 → evdev-1.7.1}/LICENSE +0 -0
  33. {evdev-1.6.1 → evdev-1.7.1}/evdev.egg-info/dependency_links.txt +0 -0
  34. {evdev-1.6.1 → evdev-1.7.1}/evdev.egg-info/top_level.txt +0 -0
@@ -1,6 +1,3 @@
1
- include README.rst
2
- include LICENSE
3
-
4
1
  # The _ecodes extension module source file needs to be generated against the
5
2
  # evdev headers of the running kernel. Refer to the 'build_ecodes' distutils
6
3
  # command in setup.py.
evdev-1.7.1/PKG-INFO ADDED
@@ -0,0 +1,76 @@
1
+ Metadata-Version: 2.1
2
+ Name: evdev
3
+ Version: 1.7.1
4
+ Summary: Bindings to the Linux input handling subsystem
5
+ Author-email: Georgi Valkov <georgi.t.valkov@gmail.com>
6
+ Maintainer-email: Tobi <proxima@sezanzeb.de>
7
+ License: Copyright (c) 2012-2023 Georgi Valkov. All rights reserved.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions are
11
+ met:
12
+
13
+ 1. Redistributions of source code must retain the above copyright
14
+ notice, this list of conditions and the following disclaimer.
15
+
16
+ 2. Redistributions in binary form must reproduce the above copyright
17
+ notice, this list of conditions and the following disclaimer in
18
+ the documentation and/or other materials provided with the
19
+ distribution.
20
+
21
+ 3. Neither the name of author nor the names of its contributors may
22
+ be used to endorse or promote products derived from this software
23
+ without specific prior written permission.
24
+
25
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
29
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
+
37
+ Project-URL: Homepage, https://github.com/gvalkov/python-evdev
38
+ Keywords: evdev,input,uinput
39
+ Classifier: Development Status :: 5 - Production/Stable
40
+ Classifier: Programming Language :: Python :: 3
41
+ Classifier: Operating System :: POSIX :: Linux
42
+ Classifier: Intended Audience :: Developers
43
+ Classifier: Topic :: Software Development :: Libraries
44
+ Classifier: License :: OSI Approved :: BSD License
45
+ Classifier: Programming Language :: Python :: Implementation :: CPython
46
+ Requires-Python: >=3.6
47
+ Description-Content-Type: text/markdown
48
+ License-File: LICENSE
49
+
50
+ # evdev
51
+
52
+ <p>
53
+ <a href="https://pypi.python.org/pypi/evdev"><img alt="pypi version" src="https://img.shields.io/pypi/v/evdev.svg"></a>
54
+ <a href="https://github.com/gvalkov/python-evdev/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/pypi/l/evdev"></a>
55
+ </p>
56
+
57
+ This package provides bindings to the generic input event interface in Linux.
58
+ The *evdev* interface serves the purpose of passing events generated in the
59
+ kernel directly to userspace through character devices that are typically
60
+ located in `/dev/input/`.
61
+
62
+ This package also comes with bindings to *uinput*, the userspace input
63
+ subsystem. *Uinput* allows userspace programs to create and handle input devices
64
+ that can inject events directly into the input subsystem.
65
+
66
+ ***Documentation:***
67
+ https://python-evdev.readthedocs.io/en/latest/
68
+
69
+ ***Development:***
70
+ https://github.com/gvalkov/python-evdev
71
+
72
+ ***Package:***
73
+ https://pypi.python.org/pypi/evdev
74
+
75
+ ***Changelog:***
76
+ https://python-evdev.readthedocs.io/en/latest/changelog.html
evdev-1.7.1/README.md ADDED
@@ -0,0 +1,27 @@
1
+ # evdev
2
+
3
+ <p>
4
+ <a href="https://pypi.python.org/pypi/evdev"><img alt="pypi version" src="https://img.shields.io/pypi/v/evdev.svg"></a>
5
+ <a href="https://github.com/gvalkov/python-evdev/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/pypi/l/evdev"></a>
6
+ </p>
7
+
8
+ This package provides bindings to the generic input event interface in Linux.
9
+ The *evdev* interface serves the purpose of passing events generated in the
10
+ kernel directly to userspace through character devices that are typically
11
+ located in `/dev/input/`.
12
+
13
+ This package also comes with bindings to *uinput*, the userspace input
14
+ subsystem. *Uinput* allows userspace programs to create and handle input devices
15
+ that can inject events directly into the input subsystem.
16
+
17
+ ***Documentation:***
18
+ https://python-evdev.readthedocs.io/en/latest/
19
+
20
+ ***Development:***
21
+ https://github.com/gvalkov/python-evdev
22
+
23
+ ***Package:***
24
+ https://pypi.python.org/pypi/evdev
25
+
26
+ ***Changelog:***
27
+ https://python-evdev.readthedocs.io/en/latest/changelog.html
@@ -1,6 +1,6 @@
1
- #--------------------------------------------------------------------------
1
+ # --------------------------------------------------------------------------
2
2
  # Gather everything into a single, convenient namespace.
3
- #--------------------------------------------------------------------------
3
+ # --------------------------------------------------------------------------
4
4
 
5
5
  from evdev.device import DeviceInfo, InputDevice, AbsInfo, EvdevError
6
6
  from evdev.events import InputEvent, KeyEvent, RelEvent, SynEvent, AbsEvent, event_factory
@@ -14,19 +14,16 @@ except ImportError:
14
14
  from evdev.eventio import EventIO, EvdevError
15
15
 
16
16
 
17
- #--------------------------------------------------------------------------
18
- _AbsInfo = collections.namedtuple(
19
- 'AbsInfo', ['value', 'min', 'max', 'fuzz', 'flat', 'resolution'])
17
+ # --------------------------------------------------------------------------
18
+ _AbsInfo = collections.namedtuple("AbsInfo", ["value", "min", "max", "fuzz", "flat", "resolution"])
20
19
 
21
- _KbdInfo = collections.namedtuple(
22
- 'KbdInfo', ['repeat', 'delay'])
20
+ _KbdInfo = collections.namedtuple("KbdInfo", ["repeat", "delay"])
23
21
 
24
- _DeviceInfo = collections.namedtuple(
25
- 'DeviceInfo', ['bustype', 'vendor', 'product', 'version'])
22
+ _DeviceInfo = collections.namedtuple("DeviceInfo", ["bustype", "vendor", "product", "version"])
26
23
 
27
24
 
28
25
  class AbsInfo(_AbsInfo):
29
- '''Absolute axis information.
26
+ """Absolute axis information.
30
27
 
31
28
  A ``namedtuple`` used for storing absolute axis information -
32
29
  corresponds to the ``input_absinfo`` struct:
@@ -62,14 +59,14 @@ class AbsInfo(_AbsInfo):
62
59
  The input core does not clamp reported values to the ``[minimum,
63
60
  maximum]`` limits, such task is left to userspace.
64
61
 
65
- '''
62
+ """
66
63
 
67
64
  def __str__(self):
68
- return 'val {}, min {}, max {}, fuzz {}, flat {}, res {}'.format(*self)
65
+ return "val {}, min {}, max {}, fuzz {}, flat {}, res {}".format(*self)
69
66
 
70
67
 
71
68
  class KbdInfo(_KbdInfo):
72
- '''Keyboard repeat rate.
69
+ """Keyboard repeat rate.
73
70
 
74
71
  Attributes
75
72
  ----------
@@ -79,45 +76,44 @@ class KbdInfo(_KbdInfo):
79
76
  delay
80
77
  Amount of time that a key must be depressed before it will start
81
78
  to repeat (in milliseconds).
82
- '''
79
+ """
83
80
 
84
81
  def __str__(self):
85
- return 'repeat {}, delay {}'.format(*self)
82
+ return "repeat {}, delay {}".format(*self)
86
83
 
87
84
 
88
85
  class DeviceInfo(_DeviceInfo):
89
- '''
86
+ """
90
87
  Attributes
91
88
  ----------
92
89
  bustype
93
90
  vendor
94
91
  product
95
92
  version
96
- '''
93
+ """
97
94
 
98
95
  def __str__(self):
99
- msg = 'bus: {:04x}, vendor {:04x}, product {:04x}, version {:04x}'
96
+ msg = "bus: {:04x}, vendor {:04x}, product {:04x}, version {:04x}"
100
97
  return msg.format(*self)
101
98
 
102
99
 
103
100
  class InputDevice(EventIO):
104
- '''
101
+ """
105
102
  A linux input device from which input events can be read.
106
- '''
103
+ """
107
104
 
108
- __slots__ = ('path', 'fd', 'info', 'name', 'phys', 'uniq', '_rawcapabilities',
109
- 'version', 'ff_effects_count')
105
+ __slots__ = ("path", "fd", "info", "name", "phys", "uniq", "_rawcapabilities", "version", "ff_effects_count")
110
106
 
111
107
  def __init__(self, dev):
112
- '''
108
+ """
113
109
  Arguments
114
110
  ---------
115
111
  dev : str|bytes|PathLike
116
112
  Path to input device
117
- '''
113
+ """
118
114
 
119
115
  #: Path to input device.
120
- self.path = dev if not hasattr(dev, '__fspath__') else dev.__fspath__()
116
+ self.path = dev if not hasattr(dev, "__fspath__") else dev.__fspath__()
121
117
 
122
118
  # Certain operations are possible only when the device is opened in
123
119
  # read-write mode.
@@ -141,7 +137,7 @@ class InputDevice(EventIO):
141
137
  #: The physical topology of the device.
142
138
  self.phys = info_res[5]
143
139
 
144
- #: The unique address of the device.
140
+ #: The unique identifier of the device.
145
141
  self.uniq = info_res[6]
146
142
 
147
143
  #: The evdev protocol version.
@@ -154,7 +150,7 @@ class InputDevice(EventIO):
154
150
  self.ff_effects_count = _input.ioctl_EVIOCGEFFECTS(self.fd)
155
151
 
156
152
  def __del__(self):
157
- if hasattr(self, 'fd') and self.fd is not None:
153
+ if hasattr(self, "fd") and self.fd is not None:
158
154
  try:
159
155
  self.close()
160
156
  except (OSError, ImportError, AttributeError):
@@ -163,8 +159,8 @@ class InputDevice(EventIO):
163
159
  def _capabilities(self, absinfo=True):
164
160
  res = {}
165
161
 
166
- for etype, ecodes in self._rawcapabilities.items():
167
- for code in ecodes:
162
+ for etype, _ecodes in self._rawcapabilities.items():
163
+ for code in _ecodes:
168
164
  l = res.setdefault(etype, [])
169
165
  if isinstance(code, tuple):
170
166
  if absinfo:
@@ -179,7 +175,7 @@ class InputDevice(EventIO):
179
175
  return res
180
176
 
181
177
  def capabilities(self, verbose=False, absinfo=True):
182
- '''
178
+ """
183
179
  Return the event types that this device supports as a mapping of
184
180
  supported event types to lists of handled event codes.
185
181
 
@@ -216,7 +212,7 @@ class InputDevice(EventIO):
216
212
  { ('EV_ABS', 3): [ (('ABS_X', 0), AbsInfo(min=0, max=255, fuzz=0, flat=0)),
217
213
  (('ABS_Y', 1), AbsInfo(min=0, max=255, fuzz=0, flat=0)) ]}
218
214
 
219
- '''
215
+ """
220
216
 
221
217
  if verbose:
222
218
  return dict(util.resolve_ecodes_dict(self._capabilities(absinfo)))
@@ -224,7 +220,7 @@ class InputDevice(EventIO):
224
220
  return self._capabilities(absinfo)
225
221
 
226
222
  def input_props(self, verbose=False):
227
- '''
223
+ """
228
224
  Get device properties and quirks.
229
225
 
230
226
  Example
@@ -237,7 +233,7 @@ class InputDevice(EventIO):
237
233
 
238
234
  [('INPUT_PROP_POINTER', 0), ('INPUT_PROP_POINTING_STICK', 5)]
239
235
 
240
- '''
236
+ """
241
237
  props = _input.ioctl_EVIOCGPROP(self.fd)
242
238
  if verbose:
243
239
  return util.resolve_ecodes(ecodes.INPUT_PROP, props)
@@ -245,7 +241,7 @@ class InputDevice(EventIO):
245
241
  return props
246
242
 
247
243
  def leds(self, verbose=False):
248
- '''
244
+ """
249
245
  Return currently set LED keys.
250
246
 
251
247
  Example
@@ -258,7 +254,7 @@ class InputDevice(EventIO):
258
254
 
259
255
  [('LED_NUML', 0), ('LED_CAPSL', 1), ('LED_MISC', 8), ('LED_MAIL', 9)]
260
256
 
261
- '''
257
+ """
262
258
  leds = _input.ioctl_EVIOCG_bits(self.fd, ecodes.EV_LED)
263
259
  if verbose:
264
260
  return util.resolve_ecodes(ecodes.LED, leds)
@@ -266,29 +262,28 @@ class InputDevice(EventIO):
266
262
  return leds
267
263
 
268
264
  def set_led(self, led_num, value):
269
- '''
265
+ """
270
266
  Set the state of the selected LED.
271
267
 
272
268
  Example
273
269
  -------
274
270
  >>> device.set_led(ecodes.LED_NUML, 1)
275
- '''
271
+ """
276
272
  self.write(ecodes.EV_LED, led_num, value)
277
273
 
278
274
  def __eq__(self, other):
279
- '''
275
+ """
280
276
  Two devices are equal if their :data:`info` attributes are equal.
281
- '''
282
- return isinstance(other, self.__class__) and self.info == other.info \
283
- and self.path == other.path
277
+ """
278
+ return isinstance(other, self.__class__) and self.info == other.info and self.path == other.path
284
279
 
285
280
  def __str__(self):
286
- msg = 'device {}, name "{}", phys "{}"'
287
- return msg.format(self.path, self.name, self.phys)
281
+ msg = 'device {}, name "{}", phys "{}", uniq "{}"'
282
+ return msg.format(self.path, self.name, self.phys, self.uniq or "")
288
283
 
289
284
  def __repr__(self):
290
285
  msg = (self.__class__.__name__, self.path)
291
- return '{}({!r})'.format(*msg)
286
+ return "{}({!r})".format(*msg)
292
287
 
293
288
  def __fspath__(self):
294
289
  return self.path
@@ -302,63 +297,63 @@ class InputDevice(EventIO):
302
297
  self.fd = -1
303
298
 
304
299
  def grab(self):
305
- '''
300
+ """
306
301
  Grab input device using ``EVIOCGRAB`` - other applications will
307
302
  be unable to receive events until the device is released. Only
308
303
  one process can hold a ``EVIOCGRAB`` on a device.
309
304
 
310
305
  Warning
311
306
  -------
312
- Grabbing an already grabbed device will raise an ``IOError``.
313
- '''
307
+ Grabbing an already grabbed device will raise an ``OSError``.
308
+ """
314
309
 
315
310
  _input.ioctl_EVIOCGRAB(self.fd, 1)
316
311
 
317
312
  def ungrab(self):
318
- '''
313
+ """
319
314
  Release device if it has been already grabbed (uses `EVIOCGRAB`).
320
315
 
321
316
  Warning
322
317
  -------
323
318
  Releasing an already released device will raise an
324
- ``IOError('Invalid argument')``.
325
- '''
319
+ ``OSError('Invalid argument')``.
320
+ """
326
321
 
327
322
  _input.ioctl_EVIOCGRAB(self.fd, 0)
328
323
 
329
324
  @contextlib.contextmanager
330
325
  def grab_context(self):
331
- '''
326
+ """
332
327
  A context manager for the duration of which only the current
333
328
  process will be able to receive events from the device.
334
- '''
329
+ """
335
330
  self.grab()
336
331
  yield
337
332
  self.ungrab()
338
333
 
339
334
  def upload_effect(self, effect):
340
- '''
335
+ """
341
336
  Upload a force feedback effect to a force feedback device.
342
- '''
337
+ """
343
338
 
344
339
  data = memoryview(effect).tobytes()
345
340
  ff_id = _input.upload_effect(self.fd, data)
346
341
  return ff_id
347
342
 
348
343
  def erase_effect(self, ff_id):
349
- '''
344
+ """
350
345
  Erase a force effect from a force feedback device. This also
351
346
  stops the effect.
352
- '''
347
+ """
353
348
 
354
349
  _input.erase_effect(self.fd, ff_id)
355
350
 
356
351
  @property
357
352
  def repeat(self):
358
- '''
353
+ """
359
354
  Get or set the keyboard repeat rate (in characters per
360
355
  minute) and delay (in milliseconds).
361
- '''
356
+ """
362
357
 
363
358
  return KbdInfo(*_input.ioctl_EVIOCGREP(self.fd))
364
359
 
@@ -367,7 +362,7 @@ class InputDevice(EventIO):
367
362
  return _input.ioctl_EVIOCSREP(self.fd, *value)
368
363
 
369
364
  def active_keys(self, verbose=False):
370
- '''
365
+ """
371
366
  Return currently active keys.
372
367
 
373
368
  Example
@@ -382,7 +377,7 @@ class InputDevice(EventIO):
382
377
 
383
378
  [('KEY_ESC', 1), ('KEY_LEFTSHIFT', 42)]
384
379
 
385
- '''
380
+ """
386
381
  active_keys = _input.ioctl_EVIOCG_bits(self.fd, ecodes.EV_KEY)
387
382
  if verbose:
388
383
  return util.resolve_ecodes(ecodes.KEY, active_keys)
@@ -391,12 +386,12 @@ class InputDevice(EventIO):
391
386
 
392
387
  @property
393
388
  def fn(self):
394
- msg = 'Please use {0}.path instead of {0}.fn'.format(self.__class__.__name__)
389
+ msg = "Please use {0}.path instead of {0}.fn".format(self.__class__.__name__)
395
390
  warnings.warn(msg, DeprecationWarning, stacklevel=2)
396
391
  return self.path
397
392
 
398
393
  def absinfo(self, axis_num):
399
- '''
394
+ """
400
395
  Return current :class:`AbsInfo` for input device axis
401
396
 
402
397
  Arguments
@@ -408,11 +403,11 @@ class InputDevice(EventIO):
408
403
  -------
409
404
  >>> device.absinfo(ecodes.ABS_X)
410
405
  AbsInfo(value=1501, min=-32768, max=32767, fuzz=0, flat=128, resolution=0)
411
- '''
406
+ """
412
407
  return AbsInfo(*_input.ioctl_EVIOCGABS(self.fd, axis_num))
413
408
 
414
409
  def set_absinfo(self, axis_num, value=None, min=None, max=None, fuzz=None, flat=None, resolution=None):
415
- '''
410
+ """
416
411
  Update :class:`AbsInfo` values. Only specified values will be overwritten.
417
412
 
418
413
  Arguments
@@ -427,13 +422,15 @@ class InputDevice(EventIO):
427
422
  You can also unpack AbsInfo tuple that will overwrite all values
428
423
 
429
424
  >>> device.set_absinfo(ecodes.ABS_Y, *AbsInfo(0, -2000, 2000, 0, 15, 0))
430
- '''
425
+ """
431
426
 
432
427
  cur_absinfo = self.absinfo(axis_num)
433
- new_absinfo = AbsInfo(value if value is not None else cur_absinfo.value,
434
- min if min is not None else cur_absinfo.min,
435
- max if max is not None else cur_absinfo.max,
436
- fuzz if fuzz is not None else cur_absinfo.fuzz,
437
- flat if flat is not None else cur_absinfo.flat,
438
- resolution if resolution is not None else cur_absinfo.resolution)
428
+ new_absinfo = AbsInfo(
429
+ value if value is not None else cur_absinfo.value,
430
+ min if min is not None else cur_absinfo.min,
431
+ max if max is not None else cur_absinfo.max,
432
+ fuzz if fuzz is not None else cur_absinfo.fuzz,
433
+ flat if flat is not None else cur_absinfo.flat,
434
+ resolution if resolution is not None else cur_absinfo.resolution,
435
+ )
439
436
  _input.ioctl_EVIOCSABS(self.fd, axis_num, new_absinfo)
@@ -1,6 +1,4 @@
1
- # encoding: utf-8
2
-
3
- '''
1
+ """
4
2
  This modules exposes the integer constants defined in ``linux/input.h`` and
5
3
  ``linux/input-event-codes.h``.
6
4
 
@@ -38,7 +36,7 @@ codes. For example::
38
36
 
39
37
  >>> evdev.ecodes.FF[81]
40
38
  'FF_PERIODIC'
41
- '''
39
+ """
42
40
 
43
41
  from inspect import getmembers
44
42
  from evdev import _ecodes
@@ -47,8 +45,8 @@ from evdev import _ecodes
47
45
  #: Mapping of names to values.
48
46
  ecodes = {}
49
47
 
50
- prefixes = 'KEY ABS REL SW MSC LED BTN REP SND ID EV BUS SYN FF_STATUS FF INPUT_PROP'
51
- prev_prefix = ''
48
+ prefixes = "KEY ABS REL SW MSC LED BTN REP SND ID EV BUS SYN FF_STATUS FF INPUT_PROP"
49
+ prev_prefix = ""
52
50
  g = globals()
53
51
 
54
52
  # eg. code: 'REL_Z', val: 2
@@ -87,13 +85,13 @@ bytype = {
87
85
  _ecodes.EV_KEY: keys,
88
86
  _ecodes.EV_ABS: ABS,
89
87
  _ecodes.EV_REL: REL,
90
- _ecodes.EV_SW: SW,
88
+ _ecodes.EV_SW: SW,
91
89
  _ecodes.EV_MSC: MSC,
92
90
  _ecodes.EV_LED: LED,
93
91
  _ecodes.EV_REP: REP,
94
92
  _ecodes.EV_SND: SND,
95
93
  _ecodes.EV_SYN: SYN,
96
- _ecodes.EV_FF: FF,
94
+ _ecodes.EV_FF: FF,
97
95
  _ecodes.EV_FF_STATUS: FF_STATUS,
98
96
  }
99
97
 
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  import os
4
2
  import fcntl
5
3
  import select
@@ -8,13 +6,14 @@ import functools
8
6
  from evdev import _input, _uinput, ecodes, util
9
7
  from evdev.events import InputEvent
10
8
 
11
- #--------------------------------------------------------------------------
9
+
10
+ # --------------------------------------------------------------------------
12
11
  class EvdevError(Exception):
13
12
  pass
14
13
 
15
14
 
16
15
  class EventIO:
17
- '''
16
+ """
18
17
  Base class for reading and writing input events.
19
18
 
20
19
  This class is used by :class:`InputDevice` and :class:`UInput`.
@@ -26,20 +25,20 @@ class EventIO:
26
25
  - On, :class:`UInput` it used for writing user-generated events (e.g.
27
26
  key presses, mouse movements) and reading feedback events (e.g. leds,
28
27
  beeps).
29
- '''
28
+ """
30
29
 
31
30
  def fileno(self):
32
- '''
31
+ """
33
32
  Return the file descriptor to the open event device. This makes
34
33
  it possible to pass instances directly to :func:`select.select()` and
35
34
  :class:`asyncore.file_dispatcher`.
36
- '''
35
+ """
37
36
  return self.fd
38
37
 
39
38
  def read_loop(self):
40
- '''
39
+ """
41
40
  Enter an endless :func:`select.select()` loop that yields input events.
42
- '''
41
+ """
43
42
 
44
43
  while True:
45
44
  r, w, x = select.select([self.fd], [], [])
@@ -47,12 +46,12 @@ class EventIO:
47
46
  yield event
48
47
 
49
48
  def read_one(self):
50
- '''
49
+ """
51
50
  Read and return a single input event as an instance of
52
51
  :class:`InputEvent <evdev.events.InputEvent>`.
53
52
 
54
53
  Return ``None`` if there are no pending input events.
55
- '''
54
+ """
56
55
 
57
56
  # event -> (sec, usec, type, code, val)
58
57
  event = _input.device_read(self.fd)
@@ -61,11 +60,11 @@ class EventIO:
61
60
  return InputEvent(*event)
62
61
 
63
62
  def read(self):
64
- '''
63
+ """
65
64
  Read multiple input events from device. Return a generator object that
66
65
  yields :class:`InputEvent <evdev.events.InputEvent>` instances. Raises
67
66
  `BlockingIOError` if there are no available events at the moment.
68
- '''
67
+ """
69
68
 
70
69
  # events -> [(sec, usec, type, code, val), ...]
71
70
  events = _input.device_read_many(self.fd)
@@ -74,10 +73,11 @@ class EventIO:
74
73
  yield InputEvent(*event)
75
74
 
76
75
  def need_write(func):
77
- '''
76
+ """
78
77
  Decorator that raises :class:`EvdevError` if there is no write access to the
79
78
  input device.
80
- '''
79
+ """
80
+
81
81
  @functools.wraps(func)
82
82
  def wrapper(*args):
83
83
  fd = args[0].fd
@@ -85,10 +85,11 @@ class EventIO:
85
85
  return func(*args)
86
86
  msg = 'no write access to device "%s"' % args[0].path
87
87
  raise EvdevError(msg)
88
+
88
89
  return wrapper
89
90
 
90
91
  def write_event(self, event):
91
- '''
92
+ """
92
93
  Inject an input event into the input subsystem. Events are
93
94
  queued until a synchronization event is received.
94
95
 
@@ -103,16 +104,16 @@ class EventIO:
103
104
  -------
104
105
  >>> ev = InputEvent(1334414993, 274296, ecodes.EV_KEY, ecodes.KEY_A, 1)
105
106
  >>> ui.write_event(ev)
106
- '''
107
+ """
107
108
 
108
- if hasattr(event, 'event'):
109
+ if hasattr(event, "event"):
109
110
  event = event.event
110
111
 
111
112
  self.write(event.type, event.code, event.value)
112
113
 
113
114
  @need_write
114
115
  def write(self, etype, code, value):
115
- '''
116
+ """
116
117
  Inject an input event into the input subsystem. Events are
117
118
  queued until a synchronization event is received.
118
119
 
@@ -131,7 +132,7 @@ class EventIO:
131
132
  ---------
132
133
  >>> ui.write(e.EV_KEY, e.KEY_A, 1) # key A - down
133
134
  >>> ui.write(e.EV_KEY, e.KEY_A, 0) # key A - up
134
- '''
135
+ """
135
136
 
136
137
  _uinput.write(self.fd, etype, code, value)
137
138