macos - 如何在 Cocoa 应用程序中从 HID USB 设备读取数据?

标签 macos cocoa xcode4 usb hid

我正在尝试在 Mac OS X 中实现 HID USB 应用程序。该应用程序需要从 HID USB 设备读取数据。我找到了一些有关从 HID USB 设备读取的信息,其中提到了 HID 管理器 kext 的创建。我的问题是,如何创建 HID 管理器 kext 以及如何在我的 Cocoa 应用程序中实现此 kext?

这是来自 USB Prober 的我的设备信息:

Low Speed device @ 2 (0x5D200000): .............................................   Composite device: "SportBrain USB\000\000\000\000\000\000\000\000\000\000\000\000"
    Device Descriptor   
        Descriptor Version Number:   0x0110
        Device Class:   0   (Composite)
        Device Subclass:   0
        Device Protocol:   0
        Device MaxPacketSize:   8
        Device VendorID/ProductID:   0x1125/0x2000   (unknown vendor)
        Device Version Number:   0x0106
        Number of Configurations:   1
        Manufacturer String:   1 "SportBrain In"
        Product String:   2 "SportBrain USB\000\000\000\000\000\000\000\000\000\000\000\000"
        Serial Number String:   0 (none)
    Configuration Descriptor: .......................................   "SportBrain USB\000\000\000\000\000\000\000\000\000\000\000\000"
        Length (and contents):   34
            Raw Descriptor (hex)    0000: 09 02 22 00 01 01 02 80  0D 09 04 00 00 01 03 00  
            Raw Descriptor (hex)    0010: 00 02 09 21 00 01 00 01  22 1C 00 07 05 81 03 08  
            Raw Descriptor (hex)    0020: 00 0A 
        Number of Interfaces:   1
        Configuration Value:   1
        Attributes:   0x80 (bus-powered)
        MaxPower:   26 ma
        Interface #0 - HID   
            Alternate Setting   0
            Number of Endpoints   1
            Interface Class:   3   (HID)
            Interface Subclass;   0
            Interface Protocol:   0
            HID Descriptor   
                Descriptor Version Number:   0x0100
                Country Code:   0
                Descriptor Count:   1
                Descriptor 1   
                    Type:   0x22  (Report Descriptor)
                    Length (and contents):   28
                        Raw Descriptor (hex)    0000: 06 A0 FF 09 01 A1 01 09  01 15 00 25 FF 75 08 95  
                        Raw Descriptor (hex)    0010: 08 81 02 09 03 75 08 95  08 B1 02 C0 
                    Parsed Report Descriptor:   
                          Usage Page    (65440) 
                          Usage 1 (0x1)    
                              Collection (Application)    
                                Usage 1 (0x1)    
                                Logical Minimum.........    (0)  
                                Logical Maximum.........    (-1)  
                                Report Size.............    (8)  
                                Report Count............    (8)  
                                Input...................   (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Bitfield) 
                                Usage 3 (0x3)    
                                Report Size.............    (8)  
                                Report Count............    (8)  
                                Feature.................   (Data, Variable, Absolute, No Wrap, Linear, Preferred State, No Null Position, Nonvolatile, Bitfield) 
                              End Collection     
            Endpoint 0x81 - Interrupt Input   
                Address:   0x81  (IN)
                Attributes:   0x03  (Interrupt no synchronization data endpoint)
                Max Packet Size:   8
                Polling Interval:   10 ms

如果有人知道这一点,请帮助我。

最佳答案

您不需要实现kext。您只需使用 IOKit,特别是 IOHid 接口(interface)。

关于macos - 如何在 Cocoa 应用程序中从 HID USB 设备读取数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7631020/

相关文章:

ios - 我的应用程序在模拟器上运行但不在设备上

macos - 2016 年以后 Mac 上的 Silverlight : Is Out Of Browser (OOB) an option?

linux - 如何在 Linux 或 OS X 上为 Swift 包生成代码覆盖率?

objective-c - 外部自动释放池

objective-c - Xcode 4.1 多点触控手势改变

xcode - 从WebView获取当前URL和标题

macos - OS X Webview 用户代理不会改变

python - 错误: "Traceback (most recent call last):"

objective-c - 每个 NSThread 是否自动分配一个调度队列?

php - 你能将 php 函数quoted_printable_decode() 转换为基于 NSString 的 Objective-C 函数/类别方法吗?