How to write usb touchscreen driver kext in os x 10.9?

可紊 提交于 2019-12-30 11:48:25

问题


I want to write a usb touchscreen kext for usb touch screen . I have read the Kernel Extension Programming Topics and the I/O Kit Fundamentals etc, My question is, 1 . how to get the input report messages from touch screen ? 2 . how to post the coordinate info to system ?

I have no idea, anybody help?


回答1:


It depends on the hardware; moreover, this question is quite broad - you'll need to be more specific in your question to get more specific answers. I'll try to provide a broad overview:

A touchscreen has 2 parts:

  1. Output: showing the image coming from the computer on the display
  2. Input: the touch events to feed back into the computer

As you haven't asked about (1) at all, I assume your device just plugs into a display port on the Mac and is already displaying correctly. If not, you'll want to look into the IOFramebuffer API.

For (2) - Pretty much all USB input devices are HID devices of some form. If you're new to HID in general, you'll probably want to read and understand the USB HID specification and related documentation as you'll be using that information throughout.

OSX already comes with comprehensive support for the standard HID device classes such as keyboards, mice, touchpads, graphics tablets, etc. If your device claims to be any kind of HID device, OSX should already be detecting it and attaching its generic HID driver to it. You should see a IOUSBHIDDriver instance in the I/O Registry (eg. using Apple's IORegistryExplorer tool, or ioreg on the command line).

I'd also expect your device to conform to HID's absolute pointing device profile, so at least single touches should already be working properly. If it's a multitouch device, or you need other extra features, you'll probably want to implement a IOUSBHIDDriver subclass that generates or converts the necessary multitouch events.

If your device for some reason isn't already a HID USB device, you'll need to write a custom USB driver for it, and convert the events coming from it into HID events, as the HID events are passed directly into userspace and processed there. You can actually write USB drivers and generate HID events from userspace, so you might be able to avoid writing any kernel code at all if you prefer.

Apple provides some documentation on HID:

  • The HID Class Device Interface Guide covers some general concepts and the userspace interfaces.
  • The Kernel Framework Reference has API documentation for the various IOHID* classes in the kernel.

If you're going to be writing your own kernel HID device driver, your best bet is probably the IOHIDFamily source code. You can probably also find some open source examples around the web.

Apple's USB mailing lists is probably also worth checking, both for the archives and if you have questions. The darwin-kernel and darwin-drivers lists are also relevant.



来源:https://stackoverflow.com/questions/20850456/how-to-write-usb-touchscreen-driver-kext-in-os-x-10-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!