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

# RegisterSystemButtonCallback (Deprecated)

> Registers a callback for Guide and Share buttons (removed in v4).

> [!WARNING]
>
> **Deprecated.** This method was removed in GameInput v4 and is not available in the current API. Read system button state from input readings with [IGameInputReading::GetSystemButtonState](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getsystembuttonstate.md) and `GameInputKindSystemButton` instead.

Registers a callback function that is called when the Guide or Share button is pressed or released.

## Syntax

```cpp theme={null}
HRESULT RegisterSystemButtonCallback(
    IGameInputDevice* device,
    GameInputSystemButtons buttonFilter,
    void* context,
    GameInputSystemButtonCallback callbackFunc,
    GameInputCallbackToken* callbackToken
);
```

### Parameters

*device*   \_In\_opt\_\
Type: IGameInputDevice\*

Optionally limits registered callback to trigger a specific device.

*buttonFilter*   \_In\_\
Type: GameInputSystemButtons

The set of buttons to receive callbacks for, logical ORed together.

*context*   \_In\_opt\_\
Type: void\*

An object that provides relevant information for the callback function. Typically, it is the calling object.

*callbackFunc*   \_In\_\
Type: GameInputSystemButtonCallback

Title-defined callback function that is called when the system buttons are pressed or released.

*callbackToken*   \_Out\_opt\_\
Type: GameInputCallbackToken\*

Token identifying the registered callback function. This token is used to identify the registered function if you need to cancel or unregister the callback function.

### Return value

Type: HRESULT

Function result.

## Remarks

This method registers a callback function call when the Guide or System button is pressed or released. Whether callbacks are dispensed depends on the [GameInputFocusPolicy](https://docs.xbox.com/reference/input/gameinput/deprecated/enums/gameinputfocuspolicy.md) set by [IGameInput::SetFocusPolicy](https://docs.xbox.com/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_setfocuspolicy.md) in your process and other processes. See [GameInputFocusPolicy](https://docs.xbox.com/reference/input/gameinput/deprecated/enums/gameinputfocuspolicy.md) for details. On the XBOX, the shell always consumes the guide button, so these callbacks are never dispatched on XBOX.

On PC, when the GameInput runtime is sideloaded with the application rather than installed on the system, this method fails with `GAMEINPUT_E_FEATURE_REQUIRES_INSTALL` (0x838AD02B). For more information, see [GameInput sideloading](https://docs.xbox.com/build/core-features/common/input/overviews/input-agility-redistributable.md).

To stop receiving callbacks, see the [IGameInput::UnregisterCallback](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinput/methods/igameinput_unregistercallback.md) and [IGameInput::StopCallback](https://docs.xbox.com/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_stopcallback.md) methods.

This was added in the Windows SDK 10.0.26031 preview GameInput.h and will be added to a future release of the GDK.

The following code example demonstrates how to listen for presses of the Guide button.

```cpp theme={null}
Microsoft::WRL::ComPtr<IGameInput> gameInput;

void CALLBACK OnGuideButton(
    _In_ GameInputCallbackToken callbackToken,
    _In_ void * context,
    _In_ IGameInputDevice * device,
    _In_ uint64_t timestamp,
    _In_ GameInputSystemButtons currentButtons,
    _In_ GameInputSystemButtons previousButtons)
{
    bool guidePressed = currentButtons & GameInputSystemButtons::GameInputSystemButtonGuide;
    bool guidePreviouslyPressed = previousButtons & GameInputSystemButtons::GameInputSystemButtonGuide;
    if (guidePressed && !guidePreviouslyPressed)
    {
        // Handle new Guide button press
    }
    else if (!guidePressed && guidePreviouslyPressed)
    {
        // Handle new Guide button release
    }
}

void RegisterForGuideButton() noexcept
{
    GameInputCallbackToken token;
    if (SUCCEEDED(gameInput->RegisterSystemButtonCallback(
        nullptr, // All devices
        GameInputSystemButtons::GameInputSystemButtonGuide, // Filter to the Guide button
        nullptr, // No context
        OnGuideButton, // Callback
        &token))) // token
    {
        // Success!
    }
}
```

## Requirements

**Header:** GameInput.h

**Library:** gameinput.lib

**Supported platforms:** Windows, XBOX One family consoles and XBOX Series consoles

## See also

[Deprecated GameInput API members](https://docs.xbox.com/reference/input/gameinput/deprecated/gameinput_deprecated_members.md)\
[IGameInputReading::GetSystemButtonState](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinputreading/methods/igameinputreading_getsystembuttonstate.md)\
[Advanced GameInput topics](https://docs.xbox.com/build/core-features/common/input/advanced/input-advanced-topics.md)\

[Overview GameInput](https://docs.xbox.com/build/core-features/common/input/overviews/input-overview.md)\

[IGameInput](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinput/igameinput.md)

## Version History

| Version | Changes |
| - | - |
| **v4** | Removed. |
| **v1** | Introduced. Replaces `RegisterGuideButtonCallback`. |


## Related topics

- [IGameInput::RegisterGuideButtonCallback (Deprecated)](https://docs.xbox.com/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_registerguidebuttoncallback.md)
- [RegisterSystemButtonCallback](https://docs.xbox.com/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registersystembuttoncallback.md)
- [GameInputGuidButtonCallback (Deprecated)](https://docs.xbox.com/reference/input/gameinput/deprecated/functions/gameinputguidebuttoncallback.md)
- [Deprecated GameInput API members](https://docs.xbox.com/reference/input/gameinput/deprecated/gameinput_deprecated_members.md)
- [IGameInput::StopCallback (Deprecated)](https://docs.xbox.com/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_stopcallback.md)
