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

# IGameInputDevice::GetXInputDeviceIndex

> 입력 장치에 할당된 XInput 사용자 인덱스가 있으면 이를 가져옵니다.

입력 장치에 할당된 XInput 사용자 인덱스가 있으면 이를 가져옵니다.

## 구문

```cpp theme={null}
bool GetXInputDeviceIndex(
    uint32_t* index
);
```

### 매개변수

*index*   \_Out\_\
형식: uint32\_t\*

장치의 0부터 시작하는 XInput 사용자 인덱스(0\~3)를 받습니다. 장치에 XInput 사용자 인덱스가 없으면 0으로 설정됩니다.

### 반환값

형식: bool

장치에 현재 XInput 사용자 인덱스가 있으면 `true`이고, 그렇지 않으면 `false`입니다.

## 설명

XInput 사용자 인덱스는 XInput API가 컨트롤러를 식별하는 데 사용하는 컨트롤러 슬롯으로, 일반적으로 컨트롤러에 표시되는 플레이어 표시기에 해당합니다. 이 메서드를 사용하여 GameInput 장치를 XInput에서 동일한 사용자 인덱스가 가리키는 컨트롤러와 연관시킬 수 있습니다. 예를 들어 타이틀을 XInput에서 GameInput으로 컨트롤러 하나씩 마이그레이션할 때 유용합니다.

XInput을 통해 노출되는 장치만 사용자 인덱스를 가집니다. 키보드, 마우스 및 대부분의 HID 게임 컨트롤러와 같은 다른 장치는 `false`를 반환합니다. 집계 장치에는 XInput 사용자 인덱스가 없습니다. 장치 연결이 끊어지면 해당 사용자 인덱스가 해제되고 메서드는 `false`를 반환합니다.

대부분의 장치 속성과 달리 XInput 사용자 인덱스는 장치가 연결되어 있는 동안 변경될 수 있습니다. 인덱스가 변경되면 GameInput은 등록된 장치 콜백에 [GameInputDeviceEvent](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/enums/gameinputdeviceevent)의 `GameInputDeviceEventXInputIndexUpdated` 값으로 알립니다. 콜백에서 `GetXInputDeviceIndex`를 다시 호출하여 새 인덱스를 가져오세요.

```cpp theme={null}
void CALLBACK OnDeviceEvent(
    GameInputCallbackToken callbackToken,
    void* context,
    GameInputDeviceEvent deviceEvent,
    IGameInputDevice* device) noexcept
{
    if (deviceEvent == GameInputDeviceEventXInputIndexUpdated)
    {
        uint32_t index = 0;
        if (device->GetXInputDeviceIndex(&index))
        {
            // The device is now assigned to XInput user index 'index'.
        }
        else
        {
            // The device no longer has an XInput user index.
        }
    }
}
```

## 요구 사항

**헤더:** GameInput.h

**라이브러리:** gameinput.lib

**지원되는 플랫폼:** Windows, XBOX One 제품군 콘솔 및 XBOX Series 콘솔

## 함께 보기

[GameInput 개요](https://docs.xbox.com/ko/build/core-features/common/input/overviews/input-overview.md)\
[IGameInputDevice](https://docs.xbox.com/ko/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)\
[GameInputDeviceEvent](https://learn.microsoft.com/en-us/gaming/gdk/docs/reference/input/gameinput/enums/gameinputdeviceevent)\
[IGameInput::RegisterDeviceCallback](https://docs.xbox.com/ko/reference/input/gameinput/interfaces/igameinput/methods/igameinput_registerdevicecallback.md)

## 버전 기록

| 버전 | 변경 사항 |
| - | - |
| **v4** | 도입됨. |


## Related topics

- [IGameInputDevice (인터페이스 콘텐츠)](https://docs.xbox.com/ko/reference/input/gameinput/interfaces/igameinputdevice/igameinputdevice.md)
- [IGameInputDevice::GetTouchSurfaceInfo](https://docs.xbox.com/ko/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_gettouchsurfaceinfo.md)
- [IGameInputDevice::GetGamepadInfo](https://docs.xbox.com/ko/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getgamepadinfo.md)
- [IGameInputDevice::GetDeviceFamily](https://docs.xbox.com/ko/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdevicefamily.md)
- [IGameInputDevice::GetDeviceId](https://docs.xbox.com/ko/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getdeviceid.md)
