void UpdateStatus() { var capabilities = new XInput.XINPUT_CAPABILITIES(); var conneced = XInput.GetCapabilities(ControllerNo.Value, XInput.XINPUT_FLAG_GAMEPAD, ref capabilities); if (conneced == (uint)XInput.ErrCode.ERROR_SUCCESS) { //capabilities.Typeから値を取得すると1になって、バッテリー情報が取れない。ので決め打ち。ゲームパッドしか使えない仕様。仕様です。 const byte BATTERY_DEVTYPE_GAMEPAD = 0; var battryInfo = new XInput.XINPUT_BATTERY_INFORMATION(); var sucsess = XInput.GetBatteryInformation(ControllerNo.Value, BATTERY_DEVTYPE_GAMEPAD, ref battryInfo); BatteryLevel.Value = battryInfo.BatteryLevel; IsConnected.Value = true; } else if (conneced == (uint)XInput.ErrCode.ERROR_DEVICE_NOT_CONNECTED) { BatteryLevel.Value = 0; IsConnected.Value = false; } Stauts.Value = $"Controller {ControllerNo.Value + 1}: {(IsConnected.Value ? "Connect" : "Disconnect")}"; }