> ## 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-TW/reference/input/gameinput/structs/gameinputmouseinfo.md)\*

指向 `GameInputMouseInfo` 結構的指標，此結構會接收裝置的滑鼠屬性。如果裝置不支援滑鼠輸入，結構的每個成員都會設定為零。

### 傳回值

類型：bool

如果裝置支援滑鼠輸入且已填入 *info*，則為 `true`；否則為 `false`。

## 備註

`GetMouseInfo` 方法會將裝置的滑鼠屬性複製到呼叫端提供的結構中。當 [GetSupportedInput](https://docs.xbox.com/zh-TW/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getsupportedinput.md) 傳回的值包含 `GameInputKindMouse` 時，裝置即支援滑鼠輸入。如果裝置不支援滑鼠輸入，`GetMouseInfo` 會將 *info* 初始化為零並傳回 `false`。

`supportedButtons` 成員會回報滑鼠具有哪些 [GameInputMouseButtons](https://docs.xbox.com/zh-TW/reference/input/gameinput/enums/gameinputmousebuttons.md)，而 `hasWheelX` 和 `hasWheelY` 成員則會回報滑鼠是否具有水平和垂直滾輪。滑鼠狀態是使用 [IGameInputReading::GetMouseState](https://docs.xbox.com/zh-TW/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-TW/reference/input/gameinput/deprecated/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceinfo.md) 所傳回 [GameInputDeviceInfo](https://docs.xbox.com/zh-TW/reference/input/gameinput/deprecated/structs/gameinputdeviceinfo.md) 結構的 `mouseInfo` 成員取得。

## 需求

**標頭：** GameInput.h

**程式庫：** gameinput.lib

**支援的平台：** Windows、XBOX One 系列主機和 XBOX Series 主機

## 另請參閱

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

## 版本歷程記錄

| 版本 | 變更 |
| - | - |
| **v4** | 已推出。 |


## Related topics

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