gpt4 book ai didi

c - IOHID : add trackpad to matching dictionary

转载 作者:太空宇宙 更新时间:2023-11-04 03:23:01 26 4
gpt4 key购买 nike

我正在尝试将触控板的属性添加到传递给 IOHIDManager 的字典中。这位经理将查看所有指针控制设备。这适用于鼠标:

CFArrayRef matches;
{
CFMutableDictionaryRef mouse = myCreateDeviceMatchingDictionary(0x01, kHIDUsage_GD_Mouse); //works
CFMutableDictionaryRef pointer = myCreateDeviceMatchingDictionary(0x01, kHIDUsage_GD_Pointer); //does not track
CFMutableDictionaryRef matchesList[] = {pointer, mouse};
matches = CFArrayCreate(kCFAllocatorDefault, (const void **)matchesList, 2, NULL);
}

IOHIDManagerSetDeviceMatchingMultiple(hidManager, matches);

我无法让它接收触控板事件。我必须测试的唯一触控板是 Apple 触控板,但它似乎不起作用。列出所有常量的页面是 here .我需要在我的匹配字典中添加什么才能得到这个?

编辑:myCreateDeviceMatchingDictionary() 是这样实现的:

CFMutableDictionaryRef myCreateDeviceMatchingDictionary(UInt32 usagePage,  UInt32 usage){

CFMutableDictionaryRef dict = CFDictionaryCreateMutable(kCFAllocatorDefault, 0
, & kCFTypeDictionaryKeyCallBacks
, & kCFTypeDictionaryValueCallBacks);
if (!dict)
return NULL;

CFNumberRef pageNumberRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, & usagePage);
if (!pageNumberRef) {
CFRelease(dict);
return NULL;
}
CFDictionarySetValue(dict, CFSTR(kIOHIDDeviceUsagePageKey), pageNumberRef);
CFRelease(pageNumberRef);

CFNumberRef usageNumberRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, & usage);
if (!usageNumberRef) {
CFRelease(dict);
return NULL;
}
CFDictionarySetValue(dict, CFSTR(kIOHIDDeviceUsageKey), usageNumberRef);
CFRelease(usageNumberRef);
return dict;
}

最佳答案

我的 rMBP 上的触摸板在其报告描述符中有一堆“使用”声明,其中之一是

0x05, 0x0D,        // Usage Page (Digitizer)
0x09, 0x05, // Usage (Touch Pad)

我怀疑这对应于

myCreateDeviceMatchingDictionary(kHIDPage_Digitizer, kHIDUsage_Dig_TouchPad);

具体取决于您的 myCreateDeviceMatchingDictionary 代码是什么。

您可以使用如下命令读取所有 HID 设备的报告描述符:

ioreg -irc IOHIDDevice -w 0

然后选择“ReportDescriptor”属性。

注意:长输出,最好将其重定向到文件。

关于c - IOHID : add trackpad to matching dictionary,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43664398/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com