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

# XInputGetKeystroke

> XInputGetKeystroke

# XInputGetKeystroke

ゲームパッドの入力イベントを取得します。

## 構文

```cpp theme={null}
DWORD XInputGetKeystroke(  
         DWORD dwUserIndex,  
         _Reserved_ dwReserved,  
         XINPUT_KEYSTROKE* pKeystroke  
)  
```

### パラメーター

*dwUserIndex*   \_In\_\
型: DWORD

デバイスに関連付けられている、サインインしているゲーマーのインデックス。0 から XUSER\_MAX\_COUNT - 1 までの範囲の値。XUSER\_INDEX\_ANY を使用すると、任意のユーザーから次に利用可能な入力イベントを取得します。

*dwReserved*   \
型: *Reserved*

このパラメーターは使用されません。

*pKeystroke*   \_Out\_\
型: [XINPUT\_KEYSTROKE\*](/reference/input/xinputongameinput/structs/xinput_keystroke)

入力イベントを受け取る [XINPUT\_KEYSTROKE](/reference/input/xinputongameinput/structs/xinput_keystroke) 構造体へのポインター。

### 戻り値

型: DWORD

* 関数が成功した場合は **ERROR\_SUCCESS** を返します。
* 新しいキーが押されていない場合、関数は **ERROR\_EMPTY** を返します。
* コントローラーが接続されていない、またはユーザーがアクティブにしていない場合、関数は **ERROR\_DEVICE\_NOT\_CONNECTED** を返します。以下の「解説」セクションを参照してください。
* 関数が失敗した場合は、Winerror.h で定義されているエラー コードを返します。

## 解説

ワイヤレス コントローラーは、システム起動時にはアクティブとは見なされません。ワイヤレス コントローラーがアクティブになる前に XInput 関数のいずれかを呼び出した場合、その呼び出しは **ERROR\_DEVICE\_NOT\_CONNECTED** を返します。ゲーム タイトルは戻り値のコードを確認し、この状況を処理する準備をしておく必要があります。有線コントローラーは、挿入されると自動的にアクティブになります。ワイヤレス コントローラーは、ユーザーが START または Guide ボタンを押してコントローラーの電源を入れたときにアクティブになります。

XInput から GameInput に移植するコードで GetKeyStroke 関数を呼び出さない場合、XINPUT\_ON\_GAMEINPUT\_NO\_XINPUTGETKEYSTROKE を定義することで XInput ラッパーのサイズを縮小できます。詳細については、[XInput から GameInput への移植](/build/core-features/common/input/porting/input-porting-xinput#optimizingSection)を参照してください。

## 要件

**ヘッダー:** XInputOnGameInput.h

**ライブラリ:** xgameruntime.lib

**対応プラットフォーム:** XBOX One ファミリー本体および XBOX Series 本体

## 関連項目

[XInput から GameInput への移植](/build/core-features/common/input/porting/input-porting-xinput)\
[XInputOnGameInput](/reference/input/xinputongameinput/xinputongameinput_members)


## Related topics

- [XINPUT_KEYSTROKE](/ja-jp/reference/input/xinputongameinput/structs/xinput_keystroke.md)
- [XInputOnGameInput](/ja-jp/reference/input/xinputongameinput/xinputongameinput_members.md)
- [XInput から GameInput への移植](/ja-jp/build/core-features/common/input/porting/input-porting-xinput.md)
- [Input](/ja-jp/build/core-features/common/input/gc-input-toc.md)
- [XInputGetCapabilities](/ja-jp/reference/input/xinputongameinput/functions/xinputgetcapabilities.md)
