GetDeviceInfo (v1)

访问与某一输入设备的完整属性和功能有关的信息。

语法

HRESULT GetDeviceInfo(
    const GameInputDeviceInfo** info
);

参数

info _Outptr_
类型:GameInputDeviceInfo**

与 IGameInputDevice 关联的设备信息。

返回值

类型:HRESULT

函数结果。

备注

GetDeviceInfo 方法内存还不属于应用程序。 如果应用程序使 IGameInput 实例保持活动状态,则内存将保持可访问状态。 释放对 IGameInput 对象的引用后,内存将会消失。

以下代码示例演示了如何识别游戏板上的额外按钮。

bool IsGamepadButton(IGameInputDevice* gamepad, uint32_t buttonIndex) noexcept
{
    const GameInputDeviceInfo* gamepadInfo = nullptr;
    const bool succeeded = gamepad->GetDeviceInfo(&gamepadInfo);
    assert(succeeded);
    assert(buttonIndex < gamepadInfo->controllerButtonCount);

    const auto buttonInfo = &gamepadInfo->controllerButtonInfo[buttonIndex];
    const bool isGamepadButton = (buttonInfo->mappedInput & GameInputKindGamepad);

    return isGamepadButton;
}

以下代码示例演示了如何确定某一赛车方向盘是否有离合器。

bool HasClutch(IGameInputDevice* wheel) noexcept
{
    const GameInputDeviceInfo* wheelInfo = nullptr;
    const bool succeeded = wheel->GetDeviceInfo(&wheelInfo);
    assert(succeeded);
    assert(wheelInfo->racingWheelInfo);

    const bool hasClutch = wheelInfo->racingWheelInfo->hasClutch;

    return hasClutch;
}

要求

头文件:GameInput.h

库:gameinput.lib

支持的平台: 窗户

另请参阅

GameInputGameInputDeviceInfoIGameInputDevice 概述