/dev/input/event* 的格式
位于 /dev/input/event*
中的字符设备的“格式”是什么?
换句话说,如何解码字符流?如果有一个 Python 示例将不胜感激。
What is the "format" of the character devices located in /dev/input/event*
?
In other words, how can I decode the character stream? A Python example would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
一个简单而原始的阅读器可以使用以下命令完成:
A simple and raw reader can be just done using:
格式在
Documentation/input/input.txt
文件。基本上,您从文件中读取以下形式的结构:type
和code
是linux/input.h
中定义的值。例如,类型可能是
EV_REL
表示鼠标的相对力矩,或EV_KEY
表示按键,
code
是按键代码,或者REL_X
或ABS_X
表示按键老鼠。
The format is described in the
Documentation/input/input.txt
file in the Linux source. Basically, you read structs of the following form from the file:type
andcode
are values defined inlinux/input.h
. For example,type might be
EV_REL
for relative moment of a mouse, orEV_KEY
fora keypress, and
code
is the keycode, orREL_X
orABS_X
for amouse.
就在 Input.py 模块。您还需要 event.py< /a> 模块。
Right here in the Input.py module. You'll also need the event.py module.
python-evdev 包提供到事件设备接口的绑定。一个简短的用法示例是:
请记住,与迄今为止提到的非常方便的纯 Pythonic 模块不同, evdev 包含 C 扩展。构建它们需要安装 Python 开发和内核头文件。
The python-evdev package provides bindings to the event device interface. A short usage example would be:
Keep in mind that, unlike the very convenient, purely Pythonic modules mentioned so far, evdev contains C extensions. Building them requires having your Python development and kernel headers installed.
数据采用
input_event
结构的形式;请参阅 http://www .thelinuxdaily.com/2010/05/grab-raw-keyboard-input-from-event-device-node-devinputevent/ C 示例。结构定义位于(例如) http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/include/linux/input.h?v=2.6.11.8。请注意,在读取设备信息之前,您需要使用一系列 ioctl 调用来获取设备信息。The data is in the form of
input_event
structures; see http://www.thelinuxdaily.com/2010/05/grab-raw-keyboard-input-from-event-device-node-devinputevent/ for a C example. The struct definition is at (for example) http://www.cs.fsu.edu/~baker/devices/lxr/http/source/linux/include/linux/input.h?v=2.6.11.8. Note that you will need to use a bunch ofioctl
calls to get information on the device before reading from it.