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

# GameInputFocusPolicy（已弃用）

> 枚举输入设备的焦点策略（已在 v4 中移除）。

> [!WARNING]
>
> **已弃用。** 此枚举已在 GameInput v4 中移除，当前 API 中不再提供。请改用 [IGameInput::EnableBackgroundInput](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_enablebackgroundinput.md)。

枚举输入设备的焦点策略。

## 语法

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

## 常量

| 常量 | 说明 |
| - | - |
| GameInputDefaultFocusPolicy | 确保仅在进程处于焦点时才向其发送输入和系统按钮事件。 |
| GameInputExclusiveForegroundInput | 阻止其他使用 GameInput 的进程看到它所接收的输入。此限制仅在游戏处于焦点时生效，并且不适用于系统按钮。 |
| GameInputExclusiveForegroundGuideButton | 阻止其他使用 GameInput 的进程看到它所接收的 Guide 按钮按下事件。此限制仅在游戏处于焦点时生效。 |
| GameInputExclusiveForegroundShareButton | 阻止其他使用 GameInput 的进程看到它所接收的 Share 按钮按下事件。此限制仅在游戏处于焦点时生效。 |
| GameInputEnableBackgroundInput | 确保即使游戏不处于焦点时也始终将输入发送到游戏。这不包括系统按钮，系统按钮需要使用各自的焦点策略标志。 |
| GameInputEnableBackgroundGuideButton | 确保即使游戏不处于焦点时也将 Guide 按钮事件发送到游戏。当处于焦点的进程拥有独占访问权限时，Guide 按钮按下事件仍不会发送到该应用程序。 |
| GameInputEnableBackgroundShareButton | 确保即使游戏不处于焦点时也将 Share 按钮事件发送到游戏。当处于焦点的进程拥有独占访问权限时，Share 按钮按下事件仍不会发送到该应用程序。 |

## 备注

此枚举由 [IGameInput::SetFocusPolicy](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_setfocuspolicy.md) 方法使用。调用 `SetFocusPolicy` 以指定当游戏不处于焦点时是否向其发送输入。默认情况下，GameInput 不会提供后台输入。可以组合多个值。

如果游戏处理 Guide 或 Share 按钮，分别设置 `GameInputExclusiveForegroundGuideButton` 或 `GameInputExclusiveForegroundShareButton` 标志有助于确保后台叠加层应用程序不会同时处理它们。例如，这可以防止在打算自行使用这些按钮的游戏上弹出不需要的叠加菜单或屏幕截图。

> [!NOTE]
>
> 许多用户会使用叠加层应用程序，通过 Guide 按钮打开菜单、通过 Share 按钮进行屏幕截图。请考虑你的游戏是否需要覆盖该功能，以避免用户产生混淆。

焦点策略仅适用于 Windows。GameInputFocusPolicy 中的 Guide 和 Share 按钮值已添加到 Windows SDK 10.0.26031 Preview 版本的 GameInput.h 中，将添加到 GDK 的未来版本。

有关详细信息，请参阅 [GameInput 基础](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-fundamentals.md)。

## 要求

**头文件：** GameInput.h

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

## 另请参阅

[已弃用的 GameInput API 成员](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/gameinput_deprecated_members.md)\
[IGameInput::EnableBackgroundInput](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_enablebackgroundinput.md)\
[GameInput 概述](https://docs.xbox.com/zh-CN/build/core-features/common/input/overviews/input-overview.md)\

[GameInput](https://docs.xbox.com/zh-CN/reference/input/gameinput/gameinput_members.md)

## 版本历史

| 版本 | 变更 |
| - | - |
| **v4** | 已移除。 |
| **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 应用程序默认不接收后台输入，这些标志是冗余的。EnableBackgroundGuideButton (0x80) 和 EnableBackgroundShareButton (0x100) 标志已在 v2 中新增，以允许应用程序注册其在后台接收输入的意图。


## Related topics

- [IGameInput::SetFocusPolicy（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_setfocuspolicy.md)
- [已弃用的 GameInput API 成员](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/gameinput_deprecated_members.md)
- [IGameInput::SetFocusPolicy](https://docs.xbox.com/zh-CN/reference/input/gameinput/interfaces/igameinput/methods/igameinput_setfocuspolicy.md)
- [GameInputLocation（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/enums/gameinputlocation.md)
- [GameInputString（已弃用）](https://docs.xbox.com/zh-CN/reference/input/gameinput/deprecated/structs/gameinputstring.md)
