laoyur

买了个索尼 BRH10 蓝牙遥控器,已经跟树莓派配对完成,请问如何能响应它的按键事件

  •  
  •   laoyur · Apr 1, 2018 · 5723 views
    This topic created in 2965 days ago, the information mentioned may be changed or developed.

    索尼 BRH10,长相如下👇

    主要看中这货有上下左右方向键,它跟 Android 手机连接后,可以当一个简单的遥控器使用,已经测试 OK。

    现在我想在树莓派上写个程序,来响应它的各按键。

    目前已经完成配对:

    [bluetooth]# info 30:A8:xx:xx:xx:xx
    Device 30:A8:xx:xx:xx:xx
    	Name: BRH10
    	Alias: BRH10
    	Class: 0x240404
    	Icon: audio-card
    	Paired: yes
    	Trusted: yes
    	Blocked: no
    	Connected: yes
    	LegacyPairing: yes
    	UUID: Headset                   (00001108-0000-1000-8000-00805f9b34fb)
    	UUID: Handsfree                 (0000111e-0000-1000-8000-00805f9b34fb)
    	UUID: Human Interface Device... (00001124-0000-1000-8000-00805f9b34fb)
    	UUID: PnP Information           (00001200-0000-1000-8000-00805f9b34fb)
    	UUID: Vendor specific           (8e780633-3c51-11e1-8d8d-001cc4d601d8)
    	Modalias: usb:v0FCEpF0FAd0100
    [bluetooth]# 
    
    

    一开始以为各按键会产生键盘事件,所以用了以下代码来测试:

    from curtsies import Input
    
    def main():
        with Input(keynames='curses') as input_generator:
            for e in input_generator:
                print(repr(e))
    
    if __name__ == '__main__':
        main()
    

    结果完全没反应。

    又想通过 pybluez 的 BluetoothSocket 来连接它,但不知道该用 L2CAP 还是 RFCOMM 协议,每个都瞎折腾了一番,还是没有头绪。

    所以想请懂行的朋友指点下,给个大概的方向即可,我再自己去研究,谢谢了!

    laoyur
        1
    laoyur  
    OP
       Apr 1, 2018
    解决了,的确会产生键盘事件,只是上面那段代码不起作用罢了
    后来找到这篇博客: https://pandara.xyz/2016/06/10/raspberry_pi_3/
    测试 OK
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3867 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 04:29 · PVG 12:29 · LAX 21:29 · JFK 00:29
    ♥ Do have faith in what you're doing.