https://github.com/unbit/foohid.git
-
到 recovery mode disable kext
- a. 重開機, cmd + R 進 Recovery mode
- b. 打開 terminal: util -> terminal
- c. $ csrutil disable
- d. $ csrutil enable --without kext
-
下載專案,編完 foohid.text 放到 /Library/Extensions
-
$ sudo kextload /Library/Extensions/foohid.kext
$ pip3 install pyobjc
$ python3 setup.py install
- 在 foohid.c 實作 subscribe
- python 層設定 callback 到 C
- 不要在 C 層呼叫 CFRunLoopRun, 這樣會卡住 python thread
- 透過 pyobjc,在 python 呼叫底層 CFRunLoop
$ python3 test_mouse.py
Python wrapper for the foohid OSX driver. Compatible with Python 2 and 3.
https://github.com/unbit/foohid
import foohid
foohid.create('your new device', report_descriptor, serial_number, vendor_id, device_id)
foohid.destroy('your new device')
foohid.send('your new device', hid_message)
foohid.list()
test_mouse.py -> creates a virtual mouse and randomly moves it (your cursor will move too ;)
test_joypad.py -> creates a virtual joypad and randomly moves left and right axis (run a game with joypad support to check it)
test_keyboard.py -> creates a virtual keyboard and presses the "a" key
test_list.py -> tests listing feature
Currently, there is a bug in the original foohid package where the userclient is not properly terminated. If the code is run repeatedly, this sometimes results in a "unable to open it_unbit_foohid service" error. If this happens, unload and remove the kernel extension:
$ sudo kextunload /Library/Extensions/foohid.kext
$ sudo rm -rf /System/Library/Extensions/foohid.kext
Then reinstall the kernel extension: https://github.com/unbit/foohid/releases/latest (no restart required)