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

# GameInputAxisMapping

> GameInputAxisMapping

# GameInputAxisMapping

描述軸如何對應至控制器。

## 語法

```cpp theme={null}
struct GameInputAxisMapping {
    GameInputElementKind controllerElementKind;
    uint32_t             controllerIndex;

    // When axis is mapped from a axis
    bool isInverted;

    // When the axis is mapped from a button
    bool     fromTwoButtons;
    uint32_t buttonMinIndexValue;

    // When the axis is mapped from a switch
    GameInputSwitchPosition referenceDirection;
};
```

### 成員

*controllerElementKind*\

類型：[GameInputElementKind](/zh-TW/reference/input/gameinput/enums/gameinputelementkind)

軸所對應之來源控制器元素的種類。

*controllerIndex*\

類型：uint32\_t

軸所對應之來源控制器元素的索引。此索引以零為起始，且相對於相同種類的其他元素。無論軸是從另一個軸、按鈕或開關對應而來，此索引都適用。

*isInverted*\

類型：bool
表示軸是否反轉。例如，如果提供的值範圍是 \[0 - 1]，其中 0 為中立位置、1 為完全位移，則 1 應代表中立位置、0 代表完全位移，中間的值也會反轉。只有當軸是從另一個軸對應而來時，此成員才有效。

*fromTwoButtons*\

類型：bool

表示軸是否從兩個按鈕對應而來。只有當軸是從按鈕對應而來時，此成員才有效。如果此值為 true，則 index 欄位是按鈕最大值，而 buttonMinIndexValue 欄位是按鈕最小值。

*buttonMinIndexValue*\

類型：uint32\_t

代表軸最小值之按鈕的索引。此索引以零為起始。只有當軸是從兩個按鈕對應而來時，此成員才有效。

*referenceDirection*\

類型：[GameInputSwitchPosition](/zh-TW/reference/input/gameinput/enums/gameinputswitchposition)

代表軸正方向的開關位置。參考位置應對應至軸值 `1.0`，而相反方向則對應至軸值 `0.0`。中間的值可能有所不同。如果考慮相鄰位置，則緊鄰的位置也應對應至 `1.0`，接下來的值則對應至 `0.5`；如果不考慮相鄰位置，則除了相反方向之外，所有非參考位置都會對應至 `0.5`。只有當軸是從開關對應而來時，此成員才有效。

## 備註

此對應資訊會分享由裝置或通訊協定所提供的內部資訊，說明其預期針對指定輸入如何被解譯。在某些情況下，我們不會分享這些資訊的全部內容，而是分享與產生指定輸入之對應最相關的資訊。

對於軸，我們允許從軸、按鈕或開關進行對應。來源輸入由 *controllerElementKind* 指定。對於所有來源元素種類，來源輸入的索引由 *controllerIndex* 指定。接著可根據 *controllerElementKind* 值，將此索引與控制器的軸、按鈕或開關搭配使用。

## 需求

**標頭：** GameInput.h

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

## 另請參閱

[GameInput 概觀](/zh-TW/build/core-features/common/input/overviews/input-overview)\


[GameInput](/zh-TW/reference/input/gameinput/gameinput_members)

## 版本歷程記錄

| 版本 | 變更 |
| - | - |
| **v3** | 在目前的 API 中推出的**新結構**。v0、v1 或 v2 中沒有此結構。 |


## Related topics

- [GetGamepadAxisMappingInfo](/zh-TW/reference/input/gameinput/interfaces/igameinputmapper/methods/igameinputmapper_getgamepadaxismappinginfo.md)
- [GetFlightStickAxisMappingInfo](/zh-TW/reference/input/gameinput/interfaces/igameinputmapper/methods/igameinputmapper_getflightstickaxismappinginfo.md)
- [GetRacingWheelAxisMappingInfo](/zh-TW/reference/input/gameinput/interfaces/igameinputmapper/methods/igameinputmapper_getracingwheelaxismappinginfo.md)
- [GameInputElementKind](/zh-TW/reference/input/gameinput/enums/gameinputelementkind.md)
- [GameInput API 成員](/zh-TW/reference/input/gameinput/gameinput_members.md)
