> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# IGameInputDevice::GetMouseInfo

> 检索设备的鼠标属性，例如其支持的按钮、采样率和滚轮。

检索设备的鼠标属性，例如其支持的按钮、采样率和滚轮。

## 语法

```cpp theme={null}
bool GetMouseInfo(
    GameInputMouseInfo* info
);
```

### 参数

*info*   \_Out\_\
类型：[GameInputMouseInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/structs/gameinputmouseinfo.md)\*

指向 `GameInputMouseInfo` 结构的指针，该结构接收设备的鼠标属性。如果设备不支持鼠标输入，则该结构的每个成员都设置为零。

### 返回值

类型：bool

如果设备支持鼠标输入并且已填充 *info*，则为 `true`；否则为 `false`。

## 备注

`GetMouseInfo` 方法将设备的鼠标属性复制到调用方提供的结构中。当 [GetSupportedInput](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedinput.md) 返回的值包含 `GameInputKindMouse` 时，设备支持鼠标输入。如果设备不支持鼠标输入，`GetMouseInfo` 会将 *info* 零初始化并返回 `false`。

`supportedButtons` 成员报告鼠标具有哪些 [GameInputMouseButtons](https://docs.xbox.com/zh-CN/reference/input/gameinput/enums/gameinputmousebuttons.md)，`hasWheelX` 和 `hasWheelY` 成员报告鼠标是否具有水平滚轮和垂直滚轮。鼠标状态通过 [IGameInputReading::GetMouseState](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getmousestate.md) 从读数中读取。

此方法返回的属性在设备的生存期内是固定的，因此你可以只查询一次（例如在设备连接时）并缓存结果。

以下示例演示如何查询设备的鼠标属性。

```cpp theme={null}
GameInputMouseInfo info;
if (device->GetMouseInfo(&info))
{
    if (info.hasWheelY)
    {
        // Enable scroll-wheel controls.
    }
}
```

在 GameInput v3 及更早版本中，此信息可从 [IGameInputDevice::GetDeviceInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md) 返回的 [GameInputDeviceInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) 结构的 `mouseInfo` 成员中获取。

## 要求

**头文件：** GameInput.h

**库：** gameinput.lib

**支持的平台：** Windows、XBOX One 系列主机和 XBOX Series 主机

## 另请参阅

[GameInput 概述](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-overview.md)\
[GameInputMouseInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/structs/gameinputmouseinfo.md)\
[GetSupportedInput](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedinput.md)\
[GameInputKind](https://docs.xbox.com/zh-CN/reference/input/gameinput/enums/gameinputkind.md)\
[GameInputMouseButtons](https://docs.xbox.com/zh-CN/reference/input/gameinput/enums/gameinputmousebuttons.md)\
[IGameInputReading::GetMouseState](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getmousestate.md)\
[IGameInputDevice](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)

## 版本历史

| 版本 | 变更 |
| - | - |
| **v4** | 引入。 |


## Related topics

- [GameInputMouseInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/structs/gameinputmouseinfo.md)
- [IGameInputDevice::GetInputReportInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getinputreportinfo.md)
- [IGameInputDevice::GetKeyboardInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getkeyboardinfo.md)
- [IGameInputDevice::GetGamepadInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getgamepadinfo.md)
- [IGameInputDevice::GetSensorsInfo](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsensorsinfo.md)
