在 IOKit 中获取 Constant 或 Enum 的字符串表示形式,可能吗?

发布于 2024-09-18 21:39:50 字数 892 浏览 2 评论 0原文

有没有办法获取 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 */

Is there a way to get a string representation for the Constants and enums defined in IOKit?

I making a forage into IOKit and trying to console log out some parameter which USB devices return. But I'm ending up with lists of numbers. Is there another way to list what these mean?

For example in 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;

or even worse (for me) in IOHIDUsageTables.h i'm having to look up the hex value and find it in the header... e.g.:

kHIDUsage_GD_Joystick   = 0x04, /* Application Collection */
kHIDUsage_GD_GamePad    = 0x05, /* Application Collection */
kHIDUsage_GD_Keyboard   = 0x06, /* Application Collection */
kHIDUsage_GD_Keypad = 0x07, /* Application Collection */

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

李不 2024-09-25 21:39:51

您可以使用经典的 switch 方法,例如。

const char *IOHIDElemtType2str(IOHIDElementType type)
{
    switch(type)
    {
        case kIOHIDElementTypeInput_Misc:
            return "kIOHidElementTypeInput_Misc";
    }
}

等等。

You can use the classic switch method, eg.

const char *IOHIDElemtType2str(IOHIDElementType type)
{
    switch(type)
    {
        case kIOHIDElementTypeInput_Misc:
            return "kIOHidElementTypeInput_Misc";
    }
}

and so on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文