1111 <strong >Links</strong ><br />
1212 <ul >
1313 <li ><a href =" #news" title =" Jump to News" >News</a ></li >
14- <li ><a href =" search.html" title =" Jump to Search" >Search</a ></li >
15- <li ><a href =" #quick-start" title =" Jump to quick start" >Quick Start</a ></li >
16- <li ><a href =" apidoc.html" title =" Jump to API reference" >API Reference</a ></li >
14+ <li ><a href =" search.html" title =" Jump to Search" >Search</a ></li >
15+ <li ><a href =" #quick-start" title =" Jump to quick start" >Quick Start</a ></li >
16+ <li ><a href =" tutorial.html" title =" Jump to turorial page" >Tutorial</a ></li >
17+ <li ><a href =" apidoc.html" title =" Jump to API reference" >API Reference</a ></li >
1718 <li ><a href =" https://github.com/gvalkov/python-evdev" title =" Jump to Github" >Github</a ></li >
1819 </ul >
1920 <!--
@@ -50,15 +51,17 @@ movement or a tap on a touchscreen.
5051Quick Start
5152-----------
5253
53- **Installing: **
54+ Installing:
55+ ^^^^^^^^^^^
5456
55- The following GNU/Linux distributions have *python-evdev * in their repositories:
57+ The following GNU/Linux distributions have *python-evdev * in their package
58+ repositories:
5659
5760.. raw :: html
5861
5962 <div style =" margin :1em ;" >
6063 <a href =" https://aur.archlinux.org/packages/python-evdev/" ><img height =" 40px" src =" _static/pacifica-icon-set/distributor-logo-archlinux.png" ></a >
61- <a href =" http://packages.ubuntu.com/saucy /python-evdev" > <img height =" 40px" src =" _static/pacifica-icon-set/distributor-logo-ubuntu.png" ></a >
64+ <a href =" http://packages.ubuntu.com/wily /python-evdev" > <img height =" 40px" src =" _static/pacifica-icon-set/distributor-logo-ubuntu.png" ></a >
6265 <!--
6366 <a href=""><img height="40px" src="_static/pacifica-icon-set/distributor-logo-raspbian.png"></a>
6467 <a href=""><img height="40px" src="_static/pacifica-icon-set/distributor-logo-fedora.png"></a>
@@ -68,10 +71,10 @@ The following GNU/Linux distributions have *python-evdev* in their repositories:
6871 -- !>
6972 </div>
7073
71- The latest stable version of *python-evdev* can be installed from
72- pypi_, provided that you have gcc/clang, pip_ and the Python and Linux
73- development headers installed on your system. Installing them is
74- distribution specific and usually falls in one of these categories:
74+ The latest stable version of *python-evdev* can be installed from pypi_,
75+ provided that you have gcc/clang, pip_ and the Python and Linux development
76+ headers installed on your system. Installing them is distribution specific and
77+ typically falls in one of the following categories:
7578
7679On a Debian compatible OS:
7780
@@ -99,31 +102,33 @@ Installing *python-evdev* with pip_:
99102
100103 $ sudo pip install evdev
101104
102- **Listing accessible event devices:**
105+ Listing accessible event devices:
106+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103107
104108::
105109
106- >>> from evdev import InputDevice, list_devices
110+ >>> import evdev
107111
108- >>> devices = [InputDevice(fn) for fn in list_devices()]
109- >>> for dev in devices:
110- ... print(dev .fn, dev .name, dev .phys)
112+ >>> devices = [evdev. InputDevice(fn) for fn in evdev. list_devices()]
113+ >>> for device in devices:
114+ ... print(device .fn, device .name, device .phys)
111115 /dev/input/event1 Dell Dell USB Keyboard usb-0000:00:12.1-2/input0
112116 /dev/input/event0 Dell USB Optical Mouse usb-0000:00:12.0-2/input0
113117
114118
115- **Reading events from a device:**
119+ Reading events from a device:
120+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
116121
117122::
118123
119- >>> from evdev import InputDevice, categorize, ecodes
124+ >>> import evdev
120125
121- >>> dev = InputDevice('/dev/input/event1')
122- >>> print(dev )
126+ >>> device = evdev. InputDevice('/dev/input/event1')
127+ >>> print(device )
123128 device /dev/input/event1, name "Dell Dell USB Keyboard", phys "usb-0000:00:12.1-2/input0"
124129
125- >>> for event in dev .read_loop():
126- ... if event.type == ecodes.EV_KEY:
130+ >>> for event in device .read_loop():
131+ ... if event.type == evdev. ecodes.EV_KEY:
127132 ... print(categorize(event))
128133 ... # pressing 'a' and holding 'space'
129134 key event at 1337016188.396030, 30 (KEY_A), down
@@ -132,7 +137,27 @@ Installing *python-evdev* with pip_:
132137 key event at 1337016190.275396, 57 (KEY_SPACE), hold
133138 key event at 1337016190.284160, 57 (KEY_SPACE), up
134139
135- **Accessing evdev constants:**
140+ Reading events using async/await:
141+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
142+
143+ *Python-evdev* proudly supports the new `async/await`_ syntax in Python 3.5:
144+
145+ ::
146+
147+ import asyncio, evdev
148+
149+ async def print_events(device):
150+ async for event in device.read_iter():
151+ print(device.fn, evdev.categorize(event), sep=': ')
152+
153+ device = evdev.InputDevice('/dev/input/event4')
154+ asyncio.ensure_future(print_events(device))
155+
156+ loop = asyncio.get_event_loop()
157+ loop.run_forever()
158+
159+ Accessing evdev constants:
160+ ^^^^^^^^^^^^^^^^^^^^^^^^^^
136161
137162::
138163
@@ -147,7 +172,18 @@ Installing *python-evdev* with pip_:
147172 >>> ecodes.KEY[152] # a single value may correspond to multiple codes
148173 ... ['KEY_COFFEE', 'KEY_SCREENLOCK']
149174
150- **Further information:**
175+ Listing and monitoring input devices:
176+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
177+
178+ The *python-evdev* package also comes with a small command-line program for
179+ listing and monitoring input devices:
180+
181+ .. code-block:: bash
182+
183+ $ python -m evdev.evtest
184+
185+ More information:
186+ ^^^^^^^^^^^^^^^^^
151187
152188- Read the full :doc:`tutorial <tutorial>`.
153189
@@ -175,6 +211,14 @@ Installing *python-evdev* with pip_:
175211
176212 - :class:`SynEvent <evdev.events.SynEvent>`
177213
214+ * :mod:`eventio <evdev.eventio>`
215+
216+ - :class:`EventIO <evdev.eventio.EventIO>`
217+
218+ * :mod:`eventio_async <evdev.eventio_async>`
219+
220+ - :class:`EventIO <evdev.eventio_async.EventIO>`
221+
178222 * :mod:`util <evdev.util>`
179223
180224 - :class:`list_devices() <evdev.util.list_devices>`
196240----
197241.. include:: news.rst
198242
199- See :doc:`changelog <changelog>` for a full list of changes.
243+ Please refer to the :doc:`changelog <changelog>` for a full list of changes.
200244
201245
202246License
@@ -212,4 +256,5 @@ The :mod:`evdev` package is released under the terms of the `Revised BSD License
212256.. _pypi: http://pypi.python.org/pypi/evdev
213257.. _github: https://github.com/gvalkov/python-evdev
214258.. _pip: http://pip.readthedocs.org/en/latest/installing.html
215- .. _example: https://github.com/gvalkov/python-evdev/tree/master/bin
259+ .. _example: https://github.com/gvalkov/python-evdev/tree/master/examples
260+ .. _`async/await`: https://docs.python.org/3/library/asyncio-task.html
0 commit comments