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

# IGameInput::RegisterSystemButtonCallback

> IGameInput::RegisterSystemButtonCallback

# IGameInput::RegisterSystemButtonCallback

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](/reference/input/gameinput/enums/gameinputfocuspolicy) set by [IGameInput::SetFocusPolicy](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_setfocuspolicy) in your process and other processes. See [GameInputFocusPolicy](/reference/input/gameinput/enums/gameinputfocuspolicy) for details. On the XBOX, the shell always consumes the guide button, so these callbacks are never dispatched on XBOX.

To stop receiving callbacks, see the [IGameInput::UnregisterCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_unregistercallback) and [IGameInput::StopCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_stopcallback) 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

[Advanced GameInput topics](/build/core-features/common/input/advanced/input-advanced-topics)<br />
[Overview GameInput](/build/core-features/common/input/overviews/input-overview)<br />
[IGameInput](/reference/input/gameinput/interfaces/igameinput/igameinput)

## Version History

| Version | Changes     |
| ------- | ----------- |
| **v0**  | Introduced. |


## Related topics

- [GameInputSystemButtonCallback](/reference/input/gameinput/functions/gameinputsystembuttoncallback.md)
- [IGameInput::RegisterGuideButtonCallback](/reference/input/gameinput/deprecated/interfaces/igameinput/methods/igameinput_registerguidebuttoncallback.md)
- [GameInputGuidButtonCallback](/reference/input/gameinput/deprecated/functions/gameinputguidebuttoncallback.md)
- [IGameInput::StopCallback](/reference/input/gameinput/interfaces/igameinput/methods/igameinput_stopcallback.md)
- [GameInputSystemButtons](/reference/input/gameinput/enums/gameinputsystembuttons.md)
