如果不是系统键盘,如何连接蓝牙键盘?

How can I connect a bluetooth keyboard without it being a system keyboard?

我想将蓝牙键盘连接到我的电脑,但我不想将它用作普通的 HID 设备(所以如果我按键,字符不会打字)。是否可以在 Python 中看到确切按下了哪些键?
(我想给每个键分配功能)

我在 Ubuntu 并且正在使用 Python 3。 编辑: 转到设备 -> 信息 -> UUID 显示:

00001000-0000-1000-8000-00805f9b34fb ServiceDiscoveryServerServiceClassID 00001124-0000-1000-8000-00805f9b34fb Human Interface Device Service (HID) 00001200-0000-1000-8000-00805f9b34fb PnP Information

所以我认为是HID键盘。

默认情况下bluetoothd会将蓝牙HID设备移交给内核。

您可以通过

禁用此行为
  1. 重建 BlueZ 并禁用 hid and/or hog 配置文件
  2. 在没有 input 插件的情况下启动 bluetoothd

https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/README#n198

中有更多关于使用 --disable-hid--disable-hog 重建的详细信息

要删除输入插件,然后修改 /lib/systemd/system/bluetooth.service,以便在 ExecStart 行添加 --noplugin=input。例如:

ExecStart=/usr/lib/bluetooth/bluetoothd --noplugin=input

明确地说,以上将禁用系统正在使用的所有蓝牙 HID 设备。

如果您保留它以便 BlueZ 将 HID 设备交给系统,那么它将在 /dev/input/ 中创建一个条目。您可以访问有关使用 python-evdev 库按下哪些键的信息。更多信息请访问:https://python-evdev.readthedocs.io/