Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Simple HID OSX Application

I am getting started with coding for HID devices. I got started with reading Apple documents and sample code. The code provided are terribly outdated that it doesn't even open in Xcode8.

Download Sample Code from Apple

I need help in finding a sample project / snippet for getting started with HID Services! Open a handle, read and write reports to device, Listen to reports generated by device in a run loop.

like image 475
matt007 Avatar asked Dec 20 '25 06:12

matt007


2 Answers

OS X/macOS's HID stack is called IOHIDFamily, and much of it is open source. This includes kernel and userspace components. You can find the code for various different OS X/macOS releases at

https://opensource.apple.com/

For 10.12.2 (latest code released at time of writing) you can browse the IOHIDFamily code here:

https://opensource.apple.com/source/IOHIDFamily/IOHIDFamily-870.31.1/

or download it as a zip file here:

https://opensource.apple.com/tarballs/IOHIDFamily/IOHIDFamily-870.31.1.tar.gz

The "tools" directory contains some userspace sample/test code which might help with what you're trying to do.

As for sample code not being updated, documentation being incomplete/outdated/missing, and provided code requiring a lot of effort to build: welcome to Mac systems & driver development. That's unfortunately how it is. I've been doing OS X kernel/driver work for 7 years, and while some things get easier with experience, downloading code from Apple and building it still feels like playing the lottery.

like image 55
pmdj Avatar answered Dec 21 '25 21:12

pmdj


There are many ways to start your development:

  1. Build from scratch with c lib: https://github.com/libusb/hidapi

  2. Follow HID Driver documentation from Apple: https://developer.apple.com/documentation/hiddriverkit Resource reference:

  • Communicate between Client and User: https://developer.apple.com/documentation/driverkit/communicating_between_a_driverkit_extension_and_a_client_app
  • StylusHIDDriver: https://developer.apple.com/documentation/hiddriverkit/handling_stylus_input_from_a_human_interface_device
  1. Reference to some of GitHub resource like: https://github.com/astarasikov/osxhidtouch

As I aware, seem number 2 is the best way to develop your driver. But number 3 also a great place to start your development.

like image 24
thanhthuc nguyen Avatar answered Dec 21 '25 21:12

thanhthuc nguyen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!