一直在想办法用自己的机械键盘,而不是买一个新的,于是终于在今天重新发现了一个库可以用来支持一些通用的HID的Repo,最后发现自己的键盘也是支持的。
USB报告描述符(Report Descriptor)是HID设备中的一个描述符,它是比较复杂的一个描述符。
在https://github.com/thefloweringash/iousbhiddriver-descriptor-override这个repo里对这个项目的描述是:
This OS X kernel extension provides a method for overriding a HID descriptor and ignoring the descriptor provided by the device. This is useful when the HID descriptor returned by a HID device is invalid or incorrect.
Mac OS X的内核扩展提供了用于覆盖一个HID描述,而忽略由所述装置提供的描述符的方法。当由HID设备返回的HID描述符无效或不正确的,这是很有用的。
于是项目中写了这样的两个问题——为什么一些键盘不支持Mac OS
HID 描述符具有通过同时指定立即用法的列表,以及一系列用途的重叠。这将导致OS X的同时发送用法时,在重叠范围内的键被按下。这里使用的解决方案是将项目分成两个独立的项:一个用于直接列表和其它的范围。
所以上文中说的项目只是修改了HID描述符。
我们可以编译代码来重新获得我们的驱动,也可以直接下载。。
安装完需要重启
下载地址: https://thefloweringash.com/iousbhiddriver-descriptor-override/downloads/
gem install bundler
bundle install --without scan
注意: 构建需要用到xcode
xcodebuild
sudo cp -r build/Release/IOUSBHIDDriverDescriptorOverride.kext \
/System/Library/Extensions
sudo kextutil \
/System/Library/Extensions/IOUSBHIDDriverDescriptorOverride.kext
一开始进入了一个思维误区,以为我的键盘需要自己获取描述符,后面重新插拔了键盘才发现原来是可以工作的。
执行
ioreg -p IOUSB -c IOUSBDevice | grep -e class -e idVendor -e idProduct -e bcdDevice
最后会返回我们的键盘和鼠标的一些属性
+-o USB Keyboard@14100000 <class IOUSBDevice, id 0x10000101e, registered, matched, active, busy 0 (212 ms), retain 36>
| "idProduct" = 359
| "bcdDevice" = 272
| "idVendor" = 1241
+-o G9x Laser Mouse@14500000 <class IOUSBDevice, id 0x100001050, registered, matched, active, busy 0 (170 ms), retain 27>
"idProduct" = 49254
"bcdDevice" = 22530
"idVendor" = 1133
(PS: Let's enjoy typing)
围观我的Github Idea墙, 也许,你会遇到心仪的项目