Skip to content

Commit

Permalink
Fixed crash trying to get battery status on some devices
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Apr 23, 2020
1 parent 0f374b0 commit 6ca7f51
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/joystick/windows/SDL_windows_gaming_input.c
Expand Up @@ -206,7 +206,8 @@ static HRESULT STDMETHODCALLTYPE IEventHandler_CRawGameControllerVtbl_InvokeAdde
__x_ABI_CWindows_CGaming_CInput_CIRawGameController2_Release(controller2);
}

if (SUCCEEDED(__x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(controller, &IID_IGameController, (void **)&gamecontroller))) {
hr = __x_ABI_CWindows_CGaming_CInput_CIRawGameController_QueryInterface(controller, &IID_IGameController, (void **)&gamecontroller);
if (SUCCEEDED(hr)) {
__x_ABI_CWindows_CGaming_CInput_CIArcadeStick *arcade_stick = NULL;
__x_ABI_CWindows_CGaming_CInput_CIFlightStick *flight_stick = NULL;
__x_ABI_CWindows_CGaming_CInput_CIGamepad *gamepad = NULL;
Expand Down Expand Up @@ -501,7 +502,7 @@ WGI_JoystickOpen(SDL_Joystick * joystick, int device_index)
__x_ABI_CWindows_CDevices_CPower_CIBatteryReport *report;

hr = __x_ABI_CWindows_CGaming_CInput_CIGameControllerBatteryInfo_TryGetBatteryReport(hwdata->battery, &report);
if (SUCCEEDED(hr)) {
if (SUCCEEDED(hr) && report) {
int full_capacity = 0, curr_capacity = 0;
__FIReference_1_int *full_capacityP, *curr_capacityP;

Expand Down

0 comments on commit 6ca7f51

Please sign in to comment.