How to write a custom USB Infrared Touch Screen driver for OS X? [duplicate]

冷暖自知 提交于 2020-01-07 00:05:36

问题


System details:

    OS X 10.9.1 (13B42)

USB Infrared Touch Screen details:

Low Speed device @ 3 (0x14400000): .............................................   Composite device from unknown vendor
    Port Information:   0x101a
           Not Captive
           Attached to Root Hub
           External Device
           Connected
           Enabled
           Connected to External Port
    Number Of Endpoints (includes EP0):   
        Total Endpoints for Configuration 1 (current):   2
    Device Descriptor   
        Descriptor Version Number:   0x0100
        Device Class:   0   (Composite)
        Device Subclass:   0
        Device Protocol:   0
        Device MaxPacketSize:   8
        Device VendorID/ProductID:   0x255E/0x0001   (unknown vendor)
        Device Version Number:   0x0100
        Number of Configurations:   1
        Manufacturer String:   0 (none)
        Product String:   0 (none)
        Serial Number String:   0 (none)
    Configuration Descriptor (current config)   
        Length (and contents):   25
            Raw Descriptor (hex)    0000: 09 02 19 00 01 01 00 A0  FA 09 04 00 00 01 FF 00  
            Raw Descriptor (hex)    0010: 00 00 07 05 81 03 08 00  0A 
        Number of Interfaces:   1
        Configuration Value:   1
        Attributes:   0xA0 (bus-powered, remote wakeup)
        MaxPower:   500 mA
        Interface #0 - Vendor-specific   
            Alternate Setting   0
            Number of Endpoints   1
            Interface Class:   255   (Vendor-specific)
            Interface Subclass;   0   (Vendor-specific)
            Interface Protocol:   0
            Endpoint 0x81 - Interrupt Input   
                Address:   0x81  (IN)
                Attributes:   0x03  (Interrupt)
                Max Packet Size:   8
                Polling Interval:   10 ms

My test code source(https://github.com/maqinjun/MyDriver/blob/master/MyDriver/MyDriver/MyDriver.cpp).

As the details, my infrared touch screen is not a HID USB device, and report interrupt input event. So, I need to write a custom USB driver for it. And then, I decided to write a USB driver kext.

According to the Mac Developer Library (I/O Kit Fundamentals),I see the Handling Events.To put the role of the work loop in perspective, it helps first to consider the event sources that it is designed for. In the I/O Kit there are five broad categories of asynchronous events:

      1. Interrupt events—indirect (secondary) interrupts originating from devices
      2. Timer events—events delivered periodically by timers, such as timeouts
      3. I/O commands—I/O requests issued by driver clients to their providers
      4. Power events—typically generated through calls down the driver stack
      5. Structural events—typically events involving the I/O Registry

    I set up their work loops, event sources, and event handlers in their start function.But not works.So, I can't get the data from USB touch screen device.
    My questions:

        1. Is there other ways to receive the report data from USB device in os x USB kext ?
        2. How to dispatch the coordinate to system, when get the report data ?


      Someone help me?


      回答1:


      That's not how USB works. USB devices never generate events on their own - you need to find the relevant pipe on the device's interface. Then, you'll need to send requests to the device, and when an event happens, the device will respond.

      I suggest reading up on how USB works. Also, if a driver for another operating system already exists for this device, maybe the developer for that can walk you through it? You'll also find that this book for all its faults, does have a decent chapter on writing USB drivers, and explains how USB devices, interfaces, endpoints, etc. fit together.

      You might want to look into writing your driver in userspace. Writing kexts isn't really something I'd recommend to novices, and never something I'd recommend if it's possible to do the same thing in userspace.

      Finally, please don't expect the users of this site to walk you through the whole learning process of writing a driver for your device. There's a lot of material out there that you can learn from - books, Apple's documentation, blog posts, Apple's source code, 3rd party source code, and so on. Yes, this will probably take you some months. There's no way around that (other than hiring someone else to do it).



      来源:https://stackoverflow.com/questions/20876794/how-to-write-a-custom-usb-infrared-touch-screen-driver-for-os-x

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