我用的是lirc for python。这工作得很好,但是我遗漏了一个函数:在我的测试中,当一个按钮被按下时,只会发送一个代码。现在,我想打印一个代码,同时按键。换句话说,一个功能应该通过"key down“启动,通过"key up”停止。只使用lirc.nextcode()是行不通的,因为只捕获了"key down“事件。
那么,有什么技巧可以用来检测python的"key up“吗?
发布于 2016-08-08 01:17:08
lirc中没有这样的功能。想一想:来自遥控器的红外信号要么被接收到,要么没有,没有keyup事件,甚至没有keydown事件。
您必须编写自己的key up和key down事件。看看如何创建配置文件,特别是关于delay的部分:http://www.lirc.org/html/configure.html以每秒发送多个事件的方式进行配置。
然后,将lirc置于非阻塞模式(参见https://github.com/tompreston/python-lirc)。然后,您可以在lirc.nextcode()上循环,如果它没有返回任何事件或返回一个不同键的事件,您就有了key up事件。
发布于 2016-10-20 17:31:49
实际上,lircd有--release选项,可以生成合成的发布事件,请参阅http://lirc.org/html/lircd.html的手册页
还有lircd-uinput附加组件,它为内核提供lirc按键事件。这些事件在/dev/input设备上可用,并带有重复和释放事件。请参阅http://lirc.org/html/lircd-uinput.html上的lircd-uinput手册页。
发布于 2020-10-25 00:45:52
你可以在这里查看我的答案:LIRC - How to use as keyboard command?
基本上,您可以编辑lircd-uinput.service来为您添加release事件。可能有一种方法可以以编程方式添加release事件,但我不知道如何做到这一点。让服务来做它是非常响应性的,并且在我的应用程序中工作得很好。
sudo nano /lib/systemd/system/lircd-uinput.service
####find this line####
ExecStart=/usr/sbin/lircd-uinput
####change to#########
ExecStart=/usr/sbin/lircd-uinput --add-release-events
#then reload/restart all the lircd services...https://stackoverflow.com/questions/38816306
复制相似问题