> ## 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.

# GameInputFocusPolicy

> GameInputFocusPolicy

# GameInputFocusPolicy

列舉輸入裝置的焦點原則。

<a id="syntaxSection" />

## 語法

```cpp theme={null}
enum GameInputFocusPolicy
{
    GameInputDefaultFocusPolicy             = 0x00000000,
    GameInputExclusiveForegroundInput       = 0x00000002,
    GameInputExclusiveForegroundGuideButton = 0x00000008,
    GameInputExclusiveForegroundShareButton = 0x00000020,
    GameInputEnableBackgroundInput          = 0x00000040,
    GameInputEnableBackgroundGuideButton    = 0x00000080,
    GameInputEnableBackgroundShareButton    = 0x00000100
};
```

<a id="constantsSection" />

## 常數

| 常數 | 描述 |
| - | - |
| GameInputDefaultFocusPolicy | 確保只有在處理序取得焦點時，才會將輸入和系統按鈕傳送給該處理序。 |
| GameInputExclusiveForegroundInput | 防止其他使用 GameInput 的處理序看到其所接收的輸入。此限制僅在遊戲取得焦點時生效，且不適用於系統按鈕。 |
| GameInputExclusiveForegroundGuideButton | 防止其他使用 GameInput 的處理序看到其所接收的 Guide 按鈕按下動作。此限制僅在遊戲取得焦點時生效。 |
| GameInputExclusiveForegroundShareButton | 防止其他使用 GameInput 的處理序看到其所接收的 Share 按鈕按下動作。此限制僅在遊戲取得焦點時生效。 |
| GameInputEnableBackgroundInput | 確保輸入一律會傳送給遊戲，即使遊戲未取得焦點也一樣。這不包括系統按鈕，系統按鈕需要使用各自的焦點原則旗標。 |
| GameInputEnableBackgroundGuideButton | 確保即使遊戲未取得焦點，Guide 按鈕事件仍會傳送給遊戲。當取得焦點的處理序擁有獨佔存取權時，Guide 按鈕按下動作仍不會傳送給應用程式。 |
| GameInputEnableBackgroundShareButton | 確保即使遊戲未取得焦點，Share 按鈕事件仍會傳送給遊戲。當取得焦點的處理序擁有獨佔存取權時，Share 按鈕按下動作仍不會傳送給應用程式。 |

<a id="remarksSection" />

## 備註

此列舉由 [IGameInput::SetFocusPolicy](/zh-TW/reference/input/gameinput/interfaces/igameinput/methods/igameinput_setfocuspolicy) 方法使用。呼叫 `SetFocusPolicy` 可指定在遊戲未取得焦點時是否將輸入傳送給遊戲。根據預設，GameInput 不會提供背景輸入。這些值可以合併使用。

如果遊戲會處理 Guide 或 Share 按鈕，分別設定 `GameInputExclusiveForegroundGuideButton` 或 `GameInputExclusiveForegroundShareButton` 旗標，有助於確保背景重疊應用程式不會同時處理這些按鈕。例如，這可以防止在打算自行使用這些按鈕的遊戲上方跳出不必要的重疊功能表或螢幕擷取畫面。

<Note>許多使用者會使用以 Guide 按鈕開啟功能表、以 Share 按鈕擷取螢幕畫面的重疊應用程式。請考量您的遊戲是否需要覆寫該功能，以避免造成使用者混淆。</Note>

焦點原則僅適用於 Windows。GameInputFocusPolicy 的 Guide 和 Share 按鈕值已新增至 Windows SDK 10.0.26031 Preview 的 GameInput.h，並將新增至未來版本的 GDK。

如需詳細資訊，請參閱 [GameInput 基本概念](/zh-TW/build/core-features/common/input/overviews/input-fundamentals)。

<a id="requirementsSection" />

## 需求

**標頭：** GameInput.h

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

<a id="seealsoSection" />

## 另請參閱

[GameInput 概觀](/zh-TW/build/core-features/common/input/overviews/input-overview)<br />
[GameInput](/zh-TW/reference/input/gameinput/gameinput_members)

## 版本歷程記錄

| 版本 | 變更 |
| - | - |
| **v2** | **已移除** `DisableBackgroundInput` (0x1) 和 `DisableBackgroundShareButton` (0x10)。**已新增** `EnableBackgroundGuideButton` (0x80) 和 `EnableBackgroundShareButton` (0x100)。 |
| **v0** | 初次推出。 |

## 附錄：先前版本

### v0

```cpp theme={null}
enum GameInputFocusPolicy
{
    GameInputDefaultFocusPolicy             = 0x00000000,
    GameInputDisableBackgroundInput         = 0x00000001,
    GameInputExclusiveForegroundInput       = 0x00000002,
    GameInputExclusiveForegroundGuideButton = 0x00000008,
    GameInputDisableBackgroundShareButton   = 0x00000010,
    GameInputExclusiveForegroundShareButton = 0x00000020,
    GameInputEnableBackgroundInput          = 0x00000040,
};
```

請注意，DisableBackgroundInput (0x1) 和 DisableBackgroundShareButton (0x10) 旗標已在 v2 中移除。GameInput 應用程式預設不接收背景輸入，因此這些旗標是多餘的。v2 中新增了 EnableBackgroundGuideButton (0x80) 和 EnableBackgroundShareButton (0x100) 旗標，讓應用程式能夠登錄其在背景中接收輸入的意圖。


## Related topics

- [GameInputFocusPolicy](/reference/input/gameinput/enums/gameinputfocuspolicy.md)
- [IGameInput::SetFocusPolicy](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_setfocuspolicy.md)
- [IGameInput::RegisterSystemButtonCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registersystembuttoncallback.md)
- [GameInput](/reference/input/gameinput/gameinput_members.md)
