src/joystick/SDL_joystick.c
changeset 9884 26b595dea221
parent 9876 1496e502e51d
child 9916 9429bc102632
     1.1 --- a/src/joystick/SDL_joystick.c	Wed Sep 30 15:38:30 2015 -0700
     1.2 +++ b/src/joystick/SDL_joystick.c	Wed Sep 30 15:39:30 2015 -0700
     1.3 @@ -178,6 +178,7 @@
     1.4      if (joystick->buttons) {
     1.5          SDL_memset(joystick->buttons, 0, joystick->nbuttons * sizeof(Uint8));
     1.6      }
     1.7 +    joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
     1.8  
     1.9      /* Add joystick to list */
    1.10      ++joystick->ref_count;
    1.11 @@ -619,10 +620,10 @@
    1.12      /* Make sure we're not getting garbage or duplicate events */
    1.13      if (button >= joystick->nbuttons) {
    1.14          return 0;
    1.15 -	}
    1.16 -	if (state == joystick->buttons[button]) {
    1.17 -		return 0;
    1.18 -	}
    1.19 +    }
    1.20 +    if (state == joystick->buttons[button]) {
    1.21 +        return 0;
    1.22 +    }
    1.23  
    1.24      /* We ignore events if we don't have keyboard focus, except for button
    1.25       * release. */
    1.26 @@ -825,4 +826,21 @@
    1.27  }
    1.28  
    1.29  
    1.30 +/* update the power level for this joystick */
    1.31 +void SDL_PrivateJoystickBatteryLevel(SDL_Joystick * joystick, SDL_JoystickPowerLevel ePowerLevel)
    1.32 +{
    1.33 +    joystick->epowerlevel = ePowerLevel;
    1.34 +}
    1.35 +
    1.36 +
    1.37 +/* return its power level */
    1.38 +SDL_JoystickPowerLevel SDL_JoystickCurrentPowerLevel(SDL_Joystick * joystick)
    1.39 +{
    1.40 +    if (!SDL_PrivateJoystickValid(joystick)) {
    1.41 +        return (SDL_JOYSTICK_POWER_UNKNOWN);
    1.42 +    }
    1.43 +    return joystick->epowerlevel;
    1.44 +}
    1.45 +
    1.46 +
    1.47  /* vi: set ts=4 sw=4 expandtab: */