有没有办法获得IOKit中定义的常量和枚举的字符串表示?
我对IOKit进行了一次搜索,并试图通过控制台注销一些USB设备返回的参数。但我最终得到了一系列的数字。有没有其他方法可以列出这些意味着什么?
例如在IOHIDKeys.h中
enum IOHIDElementType {
kIOHIDElementTypeInput_Misc = 1,
kIOHIDElementTypeInput_Button = 2,
kIOHIDElementTypeInput_Axis = 3,
kIOHIDElementTypeInput_ScanCodes = 4,
kIOHIDElementTypeOutput = 129,
kIOHIDElementTypeFeature = 257,
kIOHIDElementTypeCollection = 513
};
typedef enum IOHIDElementType IOHIDElementType;或者更糟糕的是(对我来说)在IOHIDUsageTables.h中我必须查找十六进制值并在标题中找到它……例如:
kHIDUsage_GD_Joystick = 0x04, /* Application Collection */
kHIDUsage_GD_GamePad = 0x05, /* Application Collection */
kHIDUsage_GD_Keyboard = 0x06, /* Application Collection */
kHIDUsage_GD_Keypad = 0x07, /* Application Collection */发布于 2010-09-13 20:23:25
你可以使用经典的切换方法,例如。
const char *IOHIDElemtType2str(IOHIDElementType type)
{
switch(type)
{
case kIOHIDElementTypeInput_Misc:
return "kIOHidElementTypeInput_Misc";
}
}诸若此类。
https://stackoverflow.com/questions/3700274
复制相似问题