Forráskód Böngészése

Separate joystick power state into battery status and percentage

This allows you to see battery percentage while the controller is charging
Sam Lantinga 1 éve
szülő
commit
8847b35244
42 módosított fájl, 527 hozzáadás és 932 törlés
  1. 3 1
      docs/README-migration.md
  2. 2 1
      include/SDL3/SDL_events.h
  3. 21 6
      include/SDL3/SDL_gamepad.h
  4. 27 13
      include/SDL3/SDL_joystick.h
  5. 0 2
      include/SDL3/SDL_oldnames.h
  6. 4 7
      include/SDL3/SDL_power.h
  7. 4 2
      src/dynapi/SDL_dynapi.sym
  8. 4 2
      src/dynapi/SDL_dynapi_overrides.h
  9. 4 2
      src/dynapi/SDL_dynapi_procs.h
  10. 16 3
      src/joystick/SDL_gamepad.c
  11. 35 18
      src/joystick/SDL_joystick.c
  12. 1 1
      src/joystick/SDL_joystick_c.h
  13. 4 1
      src/joystick/SDL_sysjoystick.h
  14. 7 16
      src/joystick/apple/SDL_mfijoystick.m
  15. 28 11
      src/joystick/gdk/SDL_gameinputjoystick.c
  16. 5 1
      src/joystick/hidapi/SDL_hidapi_gamecube.c
  17. 2 12
      src/joystick/hidapi/SDL_hidapi_luna.c
  18. 0 3
      src/joystick/hidapi/SDL_hidapi_ps3.c
  19. 19 16
      src/joystick/hidapi/SDL_hidapi_ps4.c
  20. 24 19
      src/joystick/hidapi/SDL_hidapi_ps5.c
  21. 21 30
      src/joystick/hidapi/SDL_hidapi_shield.c
  22. 0 1
      src/joystick/hidapi/SDL_hidapi_stadia.c
  23. 23 20
      src/joystick/hidapi/SDL_hidapi_switch.c
  24. 30 12
      src/joystick/hidapi/SDL_hidapi_wii.c
  25. 0 1
      src/joystick/hidapi/SDL_hidapi_xbox360.c
  26. 2 12
      src/joystick/hidapi/SDL_hidapi_xbox360w.c
  27. 22 18
      src/joystick/hidapi/SDL_hidapi_xboxone.c
  28. 7 0
      src/joystick/hidapi/SDL_hidapijoystick.c
  29. 29 25
      src/joystick/windows/SDL_rawinputjoystick.c
  30. 34 13
      src/joystick/windows/SDL_windows_gaming_input.c
  31. 29 23
      src/joystick/windows/SDL_xinputjoystick.c
  32. 1 5
      test/CMakeLists.txt
  33. BIN
      test/gamepad_battery.bmp
  34. 82 81
      test/gamepad_battery.h
  35. BIN
      test/gamepad_battery_empty.bmp
  36. BIN
      test/gamepad_battery_full.bmp
  37. 0 179
      test/gamepad_battery_full.h
  38. BIN
      test/gamepad_battery_low.bmp
  39. 0 179
      test/gamepad_battery_low.h
  40. BIN
      test/gamepad_battery_medium.bmp
  41. 0 179
      test/gamepad_battery_medium.h
  42. 37 17
      test/gamepadutils.c

+ 3 - 1
docs/README-migration.md

@@ -333,6 +333,8 @@ The mouseX and mouseY fields of SDL_MouseWheelEvent have been renamed mouse_x an
 
 The touchId and fingerId fields of SDL_TouchFingerEvent have been renamed touchID and fingerID.
 
+The level field of SDL_JoyBatteryEvent has been split into state and percent.
+
 SDL_QUERY, SDL_IGNORE, SDL_ENABLE, and SDL_DISABLE have been removed. You can use the functions SDL_SetEventEnabled() and SDL_EventEnabled() to set and query event processing state.
 
 SDL_AddEventWatch() now returns -1 if it fails because it ran out of memory and couldn't add the event watch callback.
@@ -793,7 +795,6 @@ The following functions have been renamed:
 * SDL_JoystickAttachVirtual() => SDL_AttachVirtualJoystick()
 * SDL_JoystickAttachVirtualEx() => SDL_AttachVirtualJoystickEx()
 * SDL_JoystickClose() => SDL_CloseJoystick()
-* SDL_JoystickCurrentPowerLevel() => SDL_GetJoystickPowerLevel()
 * SDL_JoystickDetachVirtual() => SDL_DetachVirtualJoystick()
 * SDL_JoystickFromInstanceID() => SDL_GetJoystickFromInstanceID()
 * SDL_JoystickFromPlayerIndex() => SDL_GetJoystickFromPlayerIndex()
@@ -836,6 +837,7 @@ The following symbols have been renamed:
 * SDL_JOYSTICK_TYPE_GAMECONTROLLER => SDL_JOYSTICK_TYPE_GAMEPAD
 
 The following functions have been removed:
+* SDL_JoystickCurrentPowerLevel() - replaced with SDL_GetJoystickConnectionState() and SDL_GetJoystickPowerInfo()
 * SDL_JoystickEventState() - replaced with SDL_SetJoystickEventsEnabled() and SDL_JoystickEventsEnabled()
 * SDL_JoystickGetDeviceGUID() - replaced with SDL_GetJoystickInstanceGUID()
 * SDL_JoystickGetDeviceInstanceID()

+ 2 - 1
include/SDL3/SDL_events.h

@@ -488,7 +488,8 @@ typedef struct SDL_JoyBatteryEvent
     Uint32 reserved;
     Uint64 timestamp;   /**< In nanoseconds, populated using SDL_GetTicksNS() */
     SDL_JoystickID which; /**< The joystick instance id */
-    SDL_JoystickPowerLevel level; /**< The joystick battery level */
+    SDL_PowerState state; /**< The joystick battery state */
+    int percent;          /**< The joystick battery percent charge remaining */
 } SDL_JoyBatteryEvent;
 
 /**

+ 21 - 6
include/SDL3/SDL_gamepad.h

@@ -842,16 +842,31 @@ extern DECLSPEC const char * SDLCALL SDL_GetGamepadSerial(SDL_Gamepad *gamepad);
 extern DECLSPEC Uint64 SDLCALL SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad);
 
 /**
- * Get the battery level of a gamepad, if available.
+ * Get the connection state of a gamepad.
  *
- * \param gamepad a gamepad identifier previously returned by
- *                SDL_OpenGamepad()
- * \returns the current battery level as SDL_JoystickPowerLevel on success or
- *          `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
+ * \param gamepad the gamepad object to query.
+ * \returns the connection state on success or `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ */
+extern DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad);
+
+/**
+ * Get the battery state of a gamepad.
+ *
+ * You should never take a battery status as absolute truth. Batteries
+ * (especially failing batteries) are delicate hardware, and the values
+ * reported here are best estimates based on what that hardware reports. It's
+ * not uncommon for older batteries to lose stored power much faster than it
+ * reports, or completely drain when reporting it has 20 percent left, etc.
+ *
+ * \param gamepad the gamepad object to query.
+ * \param percent a pointer filled in with the percentage of battery life left, between 0 and 100, or NULL to ignore. This will be filled in with -1 we can't determine a value or there is no battery.
+ * \returns the current battery state.
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_GetGamepadPowerLevel(SDL_Gamepad *gamepad);
+extern DECLSPEC SDL_PowerState SDLCALL SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent);
 
 /**
  * Check if a gamepad has been opened and is currently connected.

+ 27 - 13
include/SDL3/SDL_joystick.h

@@ -42,6 +42,7 @@
 #include <SDL3/SDL_error.h>
 #include <SDL3/SDL_guid.h>
 #include <SDL3/SDL_mutex.h>
+#include <SDL3/SDL_power.h>
 #include <SDL3/SDL_properties.h>
 
 #include <SDL3/SDL_begin_code.h>
@@ -99,14 +100,11 @@ typedef enum
 
 typedef enum
 {
-    SDL_JOYSTICK_POWER_UNKNOWN = -1,
-    SDL_JOYSTICK_POWER_EMPTY,   /* <= 5% */
-    SDL_JOYSTICK_POWER_LOW,     /* <= 20% */
-    SDL_JOYSTICK_POWER_MEDIUM,  /* <= 70% */
-    SDL_JOYSTICK_POWER_FULL,    /* <= 100% */
-    SDL_JOYSTICK_POWER_WIRED,
-    SDL_JOYSTICK_POWER_MAX
-} SDL_JoystickPowerLevel;
+    SDL_JOYSTICK_CONNECTION_INVALID = -1,
+    SDL_JOYSTICK_CONNECTION_UNKNOWN,
+    SDL_JOYSTICK_CONNECTION_WIRED,
+    SDL_JOYSTICK_CONNECTION_WIRELESS,
+} SDL_JoystickConnectionState;
 
 #define SDL_JOYSTICK_AXIS_MAX   32767
 #define SDL_JOYSTICK_AXIS_MIN   -32768
@@ -1082,15 +1080,31 @@ extern DECLSPEC int SDLCALL SDL_SendJoystickEffect(SDL_Joystick *joystick, const
 extern DECLSPEC void SDLCALL SDL_CloseJoystick(SDL_Joystick *joystick);
 
 /**
- * Get the battery level of a joystick as SDL_JoystickPowerLevel.
+ * Get the connection state of a joystick.
  *
- * \param joystick the SDL_Joystick to query
- * \returns the current battery level as SDL_JoystickPowerLevel on success or
- *          `SDL_JOYSTICK_POWER_UNKNOWN` if it is unknown
+ * \param joystick The joystick to query
+ * \returns the connection state on success or `SDL_JOYSTICK_CONNECTION_INVALID` on failure; call SDL_GetError() for more information.
+ *
+ * \since This function is available since SDL 3.0.0.
+ */
+extern DECLSPEC SDL_JoystickConnectionState SDLCALL SDL_GetJoystickConnectionState(SDL_Joystick *joystick);
+
+/**
+ * Get the battery state of a joystick.
+ *
+ * You should never take a battery status as absolute truth. Batteries
+ * (especially failing batteries) are delicate hardware, and the values
+ * reported here are best estimates based on what that hardware reports. It's
+ * not uncommon for older batteries to lose stored power much faster than it
+ * reports, or completely drain when reporting it has 20 percent left, etc.
+ *
+ * \param joystick The joystick to query
+ * \param percent a pointer filled in with the percentage of battery life left, between 0 and 100, or NULL to ignore. This will be filled in with -1 we can't determine a value or there is no battery.
+ * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure; call SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  */
-extern DECLSPEC SDL_JoystickPowerLevel SDLCALL SDL_GetJoystickPowerLevel(SDL_Joystick *joystick);
+extern DECLSPEC SDL_PowerState SDLCALL SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent);
 
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus

+ 0 - 2
include/SDL3/SDL_oldnames.h

@@ -297,7 +297,6 @@
 #define SDL_JoystickAttachVirtual SDL_AttachVirtualJoystick
 #define SDL_JoystickAttachVirtualEx SDL_AttachVirtualJoystickEx
 #define SDL_JoystickClose SDL_CloseJoystick
-#define SDL_JoystickCurrentPowerLevel SDL_GetJoystickPowerLevel
 #define SDL_JoystickDetachVirtual SDL_DetachVirtualJoystick
 #define SDL_JoystickFromInstanceID SDL_GetJoystickFromInstanceID
 #define SDL_JoystickFromPlayerIndex SDL_GetJoystickFromPlayerIndex
@@ -797,7 +796,6 @@
 #define SDL_JoystickAttachVirtual SDL_JoystickAttachVirtual_renamed_SDL_AttachVirtualJoystick
 #define SDL_JoystickAttachVirtualEx SDL_JoystickAttachVirtualEx_renamed_SDL_AttachVirtualJoystickEx
 #define SDL_JoystickClose SDL_JoystickClose_renamed_SDL_CloseJoystick
-#define SDL_JoystickCurrentPowerLevel SDL_JoystickCurrentPowerLevel_renamed_SDL_GetJoystickPowerLevel
 #define SDL_JoystickDetachVirtual SDL_JoystickDetachVirtual_renamed_SDL_DetachVirtualJoystick
 #define SDL_JoystickFromInstanceID SDL_JoystickFromInstanceID_renamed_SDL_GetJoystickFromInstanceID
 #define SDL_JoystickFromPlayerIndex SDL_JoystickFromPlayerIndex_renamed_SDL_GetJoystickFromPlayerIndex

+ 4 - 7
include/SDL3/SDL_power.h

@@ -41,6 +41,7 @@ extern "C" {
  */
 typedef enum
 {
+    SDL_POWERSTATE_ERROR = -1,   /**< error determining power status */
     SDL_POWERSTATE_UNKNOWN,      /**< cannot determine power status */
     SDL_POWERSTATE_ON_BATTERY,   /**< Not plugged in, running on the battery */
     SDL_POWERSTATE_NO_BATTERY,   /**< Plugged in, no battery available */
@@ -64,13 +65,9 @@ typedef enum
  * It's possible a platform can only report battery percentage or time left
  * but not both.
  *
- * \param seconds seconds of battery life left, you can pass a NULL here if
- *                you don't care, will return -1 if we can't determine a
- *                value, or we're not running on a battery
- * \param percent percentage of battery life left, between 0 and 100, you can
- *                pass a NULL here if you don't care, will return -1 if we
- *                can't determine a value, or we're not running on a battery
- * \returns an SDL_PowerState enum representing the current battery state.
+ * \param seconds a pointer filled in with the seconds of battery life left, or NULL to ignore. This will be filled in with -1 if we can't determine a value or there is no battery.
+ * \param percent a pointer filled in with the percentage of battery life left, between 0 and 100, or NULL to ignore. This will be filled in with -1 we can't determine a value or there is no battery.
+ * \returns the current battery state or `SDL_POWERSTATE_ERROR` on failure; call SDL_GetError() for more information.
  *
  * \since This function is available since SDL 3.0.0.
  */

+ 4 - 2
src/dynapi/SDL_dynapi.sym

@@ -232,6 +232,7 @@ SDL3_0.0.0 {
     SDL_GetGamepadButtonFromString;
     SDL_GetGamepadButtonLabel;
     SDL_GetGamepadButtonLabelForType;
+    SDL_GetGamepadConnectionState;
     SDL_GetGamepadFirmwareVersion;
     SDL_GetGamepadFromInstanceID;
     SDL_GetGamepadFromPlayerIndex;
@@ -252,7 +253,7 @@ SDL3_0.0.0 {
     SDL_GetGamepadName;
     SDL_GetGamepadPath;
     SDL_GetGamepadPlayerIndex;
-    SDL_GetGamepadPowerLevel;
+    SDL_GetGamepadPowerInfo;
     SDL_GetGamepadProduct;
     SDL_GetGamepadProductVersion;
     SDL_GetGamepadProperties;
@@ -287,6 +288,7 @@ SDL3_0.0.0 {
     SDL_GetJoystickAxisInitialState;
     SDL_GetJoystickBall;
     SDL_GetJoystickButton;
+    SDL_GetJoystickConnectionState;
     SDL_GetJoystickFirmwareVersion;
     SDL_GetJoystickFromInstanceID;
     SDL_GetJoystickFromPlayerIndex;
@@ -307,7 +309,7 @@ SDL3_0.0.0 {
     SDL_GetJoystickName;
     SDL_GetJoystickPath;
     SDL_GetJoystickPlayerIndex;
-    SDL_GetJoystickPowerLevel;
+    SDL_GetJoystickPowerInfo;
     SDL_GetJoystickProduct;
     SDL_GetJoystickProductVersion;
     SDL_GetJoystickProperties;

+ 4 - 2
src/dynapi/SDL_dynapi_overrides.h

@@ -257,6 +257,7 @@
 #define SDL_GetGamepadButtonFromString SDL_GetGamepadButtonFromString_REAL
 #define SDL_GetGamepadButtonLabel SDL_GetGamepadButtonLabel_REAL
 #define SDL_GetGamepadButtonLabelForType SDL_GetGamepadButtonLabelForType_REAL
+#define SDL_GetGamepadConnectionState SDL_GetGamepadConnectionState_REAL
 #define SDL_GetGamepadFirmwareVersion SDL_GetGamepadFirmwareVersion_REAL
 #define SDL_GetGamepadFromInstanceID SDL_GetGamepadFromInstanceID_REAL
 #define SDL_GetGamepadFromPlayerIndex SDL_GetGamepadFromPlayerIndex_REAL
@@ -277,7 +278,7 @@
 #define SDL_GetGamepadName SDL_GetGamepadName_REAL
 #define SDL_GetGamepadPath SDL_GetGamepadPath_REAL
 #define SDL_GetGamepadPlayerIndex SDL_GetGamepadPlayerIndex_REAL
-#define SDL_GetGamepadPowerLevel SDL_GetGamepadPowerLevel_REAL
+#define SDL_GetGamepadPowerInfo SDL_GetGamepadPowerInfo_REAL
 #define SDL_GetGamepadProduct SDL_GetGamepadProduct_REAL
 #define SDL_GetGamepadProductVersion SDL_GetGamepadProductVersion_REAL
 #define SDL_GetGamepadProperties SDL_GetGamepadProperties_REAL
@@ -312,6 +313,7 @@
 #define SDL_GetJoystickAxisInitialState SDL_GetJoystickAxisInitialState_REAL
 #define SDL_GetJoystickBall SDL_GetJoystickBall_REAL
 #define SDL_GetJoystickButton SDL_GetJoystickButton_REAL
+#define SDL_GetJoystickConnectionState SDL_GetJoystickConnectionState_REAL
 #define SDL_GetJoystickFirmwareVersion SDL_GetJoystickFirmwareVersion_REAL
 #define SDL_GetJoystickFromInstanceID SDL_GetJoystickFromInstanceID_REAL
 #define SDL_GetJoystickFromPlayerIndex SDL_GetJoystickFromPlayerIndex_REAL
@@ -332,7 +334,7 @@
 #define SDL_GetJoystickName SDL_GetJoystickName_REAL
 #define SDL_GetJoystickPath SDL_GetJoystickPath_REAL
 #define SDL_GetJoystickPlayerIndex SDL_GetJoystickPlayerIndex_REAL
-#define SDL_GetJoystickPowerLevel SDL_GetJoystickPowerLevel_REAL
+#define SDL_GetJoystickPowerInfo SDL_GetJoystickPowerInfo_REAL
 #define SDL_GetJoystickProduct SDL_GetJoystickProduct_REAL
 #define SDL_GetJoystickProductVersion SDL_GetJoystickProductVersion_REAL
 #define SDL_GetJoystickProperties SDL_GetJoystickProperties_REAL

+ 4 - 2
src/dynapi/SDL_dynapi_procs.h

@@ -295,6 +295,7 @@ SDL_DYNAPI_PROC(Uint8,SDL_GetGamepadButton,(SDL_Gamepad *a, SDL_GamepadButton b)
 SDL_DYNAPI_PROC(SDL_GamepadButton,SDL_GetGamepadButtonFromString,(const char *a),(a),return)
 SDL_DYNAPI_PROC(SDL_GamepadButtonLabel,SDL_GetGamepadButtonLabel,(SDL_Gamepad *a, SDL_GamepadButton b),(a,b),return)
 SDL_DYNAPI_PROC(SDL_GamepadButtonLabel,SDL_GetGamepadButtonLabelForType,(SDL_GamepadType a, SDL_GamepadButton b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_JoystickConnectionState,SDL_GetGamepadConnectionState,(SDL_Gamepad *a),(a),return)
 SDL_DYNAPI_PROC(Uint16,SDL_GetGamepadFirmwareVersion,(SDL_Gamepad *a),(a),return)
 SDL_DYNAPI_PROC(SDL_Gamepad*,SDL_GetGamepadFromInstanceID,(SDL_JoystickID a),(a),return)
 SDL_DYNAPI_PROC(SDL_Gamepad*,SDL_GetGamepadFromPlayerIndex,(int a),(a),return)
@@ -315,7 +316,7 @@ SDL_DYNAPI_PROC(char**,SDL_GetGamepadMappings,(int *a),(a),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetGamepadName,(SDL_Gamepad *a),(a),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetGamepadPath,(SDL_Gamepad *a),(a),return)
 SDL_DYNAPI_PROC(int,SDL_GetGamepadPlayerIndex,(SDL_Gamepad *a),(a),return)
-SDL_DYNAPI_PROC(SDL_JoystickPowerLevel,SDL_GetGamepadPowerLevel,(SDL_Gamepad *a),(a),return)
+SDL_DYNAPI_PROC(SDL_PowerState,SDL_GetGamepadPowerInfo,(SDL_Gamepad *a, int *b),(a,b),return)
 SDL_DYNAPI_PROC(Uint16,SDL_GetGamepadProduct,(SDL_Gamepad *a),(a),return)
 SDL_DYNAPI_PROC(Uint16,SDL_GetGamepadProductVersion,(SDL_Gamepad *a),(a),return)
 SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetGamepadProperties,(SDL_Gamepad *a),(a),return)
@@ -350,6 +351,7 @@ SDL_DYNAPI_PROC(Sint16,SDL_GetJoystickAxis,(SDL_Joystick *a, int b),(a,b),return
 SDL_DYNAPI_PROC(SDL_bool,SDL_GetJoystickAxisInitialState,(SDL_Joystick *a, int b, Sint16 *c),(a,b,c),return)
 SDL_DYNAPI_PROC(int,SDL_GetJoystickBall,(SDL_Joystick *a, int b, int *c, int *d),(a,b,c,d),return)
 SDL_DYNAPI_PROC(Uint8,SDL_GetJoystickButton,(SDL_Joystick *a, int b),(a,b),return)
+SDL_DYNAPI_PROC(SDL_JoystickConnectionState,SDL_GetJoystickConnectionState,(SDL_Joystick *a),(a),return)
 SDL_DYNAPI_PROC(Uint16,SDL_GetJoystickFirmwareVersion,(SDL_Joystick *a),(a),return)
 SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GetJoystickFromInstanceID,(SDL_JoystickID a),(a),return)
 SDL_DYNAPI_PROC(SDL_Joystick*,SDL_GetJoystickFromPlayerIndex,(int a),(a),return)
@@ -370,7 +372,7 @@ SDL_DYNAPI_PROC(Uint16,SDL_GetJoystickInstanceVendor,(SDL_JoystickID a),(a),retu
 SDL_DYNAPI_PROC(const char*,SDL_GetJoystickName,(SDL_Joystick *a),(a),return)
 SDL_DYNAPI_PROC(const char*,SDL_GetJoystickPath,(SDL_Joystick *a),(a),return)
 SDL_DYNAPI_PROC(int,SDL_GetJoystickPlayerIndex,(SDL_Joystick *a),(a),return)
-SDL_DYNAPI_PROC(SDL_JoystickPowerLevel,SDL_GetJoystickPowerLevel,(SDL_Joystick *a),(a),return)
+SDL_DYNAPI_PROC(SDL_PowerState,SDL_GetJoystickPowerInfo,(SDL_Joystick *a, int *b),(a,b),return)
 SDL_DYNAPI_PROC(Uint16,SDL_GetJoystickProduct,(SDL_Joystick *a),(a),return)
 SDL_DYNAPI_PROC(Uint16,SDL_GetJoystickProductVersion,(SDL_Joystick *a),(a),return)
 SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetJoystickProperties,(SDL_Joystick *a),(a),return)

+ 16 - 3
src/joystick/SDL_gamepad.c

@@ -3427,14 +3427,27 @@ Uint64 SDL_GetGamepadSteamHandle(SDL_Gamepad *gamepad)
     return handle;
 }
 
-SDL_JoystickPowerLevel SDL_GetGamepadPowerLevel(SDL_Gamepad *gamepad)
+SDL_JoystickConnectionState SDL_GetGamepadConnectionState(SDL_Gamepad *gamepad)
 {
     SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad);
 
     if (!joystick) {
-        return SDL_JOYSTICK_POWER_UNKNOWN;
+        return SDL_JOYSTICK_CONNECTION_INVALID;
     }
-    return SDL_GetJoystickPowerLevel(joystick);
+    return SDL_GetJoystickConnectionState(joystick);
+}
+
+SDL_PowerState SDL_GetGamepadPowerInfo(SDL_Gamepad *gamepad, int *percent)
+{
+    SDL_Joystick *joystick = SDL_GetGamepadJoystick(gamepad);
+
+    if (percent) {
+        *percent = -1;
+    }
+    if (!joystick) {
+        return SDL_POWERSTATE_ERROR;
+    }
+    return SDL_GetJoystickPowerInfo(joystick, percent);
 }
 
 /*

+ 35 - 18
src/joystick/SDL_joystick.c

@@ -1054,7 +1054,6 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id)
     SDL_Joystick *joysticklist;
     const char *joystickname = NULL;
     const char *joystickpath = NULL;
-    SDL_JoystickPowerLevel initial_power_level;
     SDL_bool invert_sensors = SDL_FALSE;
     const SDL_SteamVirtualGamepadInfo *info;
 
@@ -1089,8 +1088,8 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id)
     joystick->driver = driver;
     joystick->instance_id = instance_id;
     joystick->attached = SDL_TRUE;
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
     joystick->led_expiration = SDL_GetTicks();
+    joystick->battery_percent = -1;
 
     if (driver->Open(joystick, device_index) < 0) {
         SDL_free(joystick);
@@ -1159,11 +1158,6 @@ SDL_Joystick *SDL_OpenJoystick(SDL_JoystickID instance_id)
     joystick->next = SDL_joysticks;
     SDL_joysticks = joystick;
 
-    /* send initial battery event */
-    initial_power_level = joystick->epowerlevel;
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
-    SDL_SendJoystickBatteryLevel(joystick, initial_power_level);
-
     driver->Update(joystick);
 
     SDL_UnlockJoysticks();
@@ -3410,35 +3404,58 @@ SDL_JoystickGUID SDL_GetJoystickGUIDFromString(const char *pchGUID)
     return SDL_GUIDFromString(pchGUID);
 }
 
-/* update the power level for this joystick */
-void SDL_SendJoystickBatteryLevel(SDL_Joystick *joystick, SDL_JoystickPowerLevel ePowerLevel)
+void SDL_SendJoystickPowerInfo(SDL_Joystick *joystick, SDL_PowerState state, int percent)
 {
     SDL_AssertJoysticksLocked();
 
-    SDL_assert(joystick->ref_count); /* make sure we are calling this only for update, not for initialization */
-    if (ePowerLevel != joystick->epowerlevel) {
+    if (state != joystick->battery_state || percent != joystick->battery_percent) {
+        joystick->battery_state = state;
+        joystick->battery_percent = percent;
+
         if (SDL_EventEnabled(SDL_EVENT_JOYSTICK_BATTERY_UPDATED)) {
             SDL_Event event;
             event.type = SDL_EVENT_JOYSTICK_BATTERY_UPDATED;
             event.common.timestamp = 0;
             event.jbattery.which = joystick->instance_id;
-            event.jbattery.level = ePowerLevel;
+            event.jbattery.state = state;
+            event.jbattery.percent = percent;
             SDL_PushEvent(&event);
         }
-        joystick->epowerlevel = ePowerLevel;
     }
 }
 
-/* return its power level */
-SDL_JoystickPowerLevel SDL_GetJoystickPowerLevel(SDL_Joystick *joystick)
+SDL_JoystickConnectionState SDL_GetJoystickConnectionState(SDL_Joystick *joystick)
 {
-    SDL_JoystickPowerLevel retval;
+    SDL_JoystickConnectionState retval;
 
     SDL_LockJoysticks();
     {
-        CHECK_JOYSTICK_MAGIC(joystick, SDL_JOYSTICK_POWER_UNKNOWN);
+        CHECK_JOYSTICK_MAGIC(joystick, SDL_JOYSTICK_CONNECTION_INVALID);
+
+        retval = joystick->connection_state;
+    }
+    SDL_UnlockJoysticks();
 
-        retval = joystick->epowerlevel;
+    return retval;
+}
+
+SDL_PowerState SDL_GetJoystickPowerInfo(SDL_Joystick *joystick, int *percent)
+{
+    SDL_PowerState retval;
+
+    if (percent) {
+        *percent = -1;
+    }
+
+    SDL_LockJoysticks();
+    {
+        CHECK_JOYSTICK_MAGIC(joystick, SDL_POWERSTATE_ERROR);
+
+        retval = joystick->battery_state;
+
+        if (percent) {
+            *percent = joystick->battery_percent;
+        }
     }
     SDL_UnlockJoysticks();
 

+ 1 - 1
src/joystick/SDL_joystick_c.h

@@ -167,7 +167,7 @@ extern int SDL_SendJoystickHat(Uint64 timestamp, SDL_Joystick *joystick, Uint8 h
 extern int SDL_SendJoystickButton(Uint64 timestamp, SDL_Joystick *joystick, Uint8 button, Uint8 state);
 extern int SDL_SendJoystickTouchpad(Uint64 timestamp, SDL_Joystick *joystick, int touchpad, int finger, Uint8 state, float x, float y, float pressure);
 extern int SDL_SendJoystickSensor(Uint64 timestamp, SDL_Joystick *joystick, SDL_SensorType type, Uint64 sensor_timestamp, const float *data, int num_values);
-extern void SDL_SendJoystickBatteryLevel(SDL_Joystick *joystick, SDL_JoystickPowerLevel ePowerLevel);
+extern void SDL_SendJoystickPowerInfo(SDL_Joystick *joystick, SDL_PowerState state, int percent);
 
 /* Function to get the Steam virtual gamepad info for a joystick */
 extern const struct SDL_SteamVirtualGamepadInfo *SDL_GetJoystickInstanceVirtualGamepadInfo(SDL_JoystickID instance_id);

+ 4 - 1
src/joystick/SDL_sysjoystick.h

@@ -121,8 +121,11 @@ struct SDL_Joystick
 
     SDL_bool attached _guarded;
     SDL_bool is_gamepad _guarded;
+    SDL_JoystickConnectionState connection_state _guarded;
+    SDL_PowerState battery_state _guarded;
+    int battery_percent _guarded;
+
     SDL_bool delayed_guide_button _guarded;      /* SDL_TRUE if this device has the guide button event delayed */
-    SDL_JoystickPowerLevel epowerlevel _guarded; /* power level of this joystick, SDL_JOYSTICK_POWER_UNKNOWN if not supported */
 
     SDL_SensorID accel_sensor _guarded;
     SDL_Sensor *accel _guarded;

+ 7 - 16
src/joystick/apple/SDL_mfijoystick.m

@@ -1296,33 +1296,24 @@ static void IOS_MFIJoystickUpdate(SDL_Joystick *joystick)
         if (@available(macOS 10.16, iOS 14.0, tvOS 14.0, *)) {
             GCDeviceBattery *battery = controller.battery;
             if (battery) {
-                SDL_JoystickPowerLevel ePowerLevel = SDL_JOYSTICK_POWER_UNKNOWN;
+                SDL_PowerState state = SDL_POWERSTATE_UNKNOWN;
+                int percent = (int)SDL_roundf(battery.batteryLevel * 100.0f);
 
                 switch (battery.batteryState) {
                 case GCDeviceBatteryStateDischarging:
-                {
-                    float power_level = battery.batteryLevel;
-                    if (power_level <= 0.05f) {
-                        ePowerLevel = SDL_JOYSTICK_POWER_EMPTY;
-                    } else if (power_level <= 0.20f) {
-                        ePowerLevel = SDL_JOYSTICK_POWER_LOW;
-                    } else if (power_level <= 0.70f) {
-                        ePowerLevel = SDL_JOYSTICK_POWER_MEDIUM;
-                    } else {
-                        ePowerLevel = SDL_JOYSTICK_POWER_FULL;
-                    }
-                } break;
+                    state = SDL_POWERSTATE_ON_BATTERY;
+                    break;
                 case GCDeviceBatteryStateCharging:
-                    ePowerLevel = SDL_JOYSTICK_POWER_WIRED;
+                    state = SDL_POWERSTATE_CHARGING;
                     break;
                 case GCDeviceBatteryStateFull:
-                    ePowerLevel = SDL_JOYSTICK_POWER_FULL;
+                    state = SDL_POWERSTATE_CHARGED;
                     break;
                 default:
                     break;
                 }
 
-                SDL_SendJoystickBatteryLevel(joystick, ePowerLevel);
+                SDL_SendJoystickPowerInfo(joystick, state, percent);
             }
         }
 #endif /* ENABLE_MFI_BATTERY */

+ 28 - 11
src/joystick/gdk/SDL_gameinputjoystick.c

@@ -341,17 +341,36 @@ static SDL_JoystickID GAMEINPUT_JoystickGetDeviceInstanceID(int device_index)
     return GAMEINPUT_InternalFindByIndex(device_index)->device_instance;
 }
 
-static SDL_JoystickPowerLevel GAMEINPUT_InternalGetPowerLevel(IGameInputDevice *device)
+static void GAMEINPUT_UpdatePowerInfo(SDL_Joystick *joystick, IGameInputDevice *device)
 {
     GameInputBatteryState battery_state;
+    SDL_PowerState state;
+    int percent = 0;
 
     SDL_zero(battery_state);
     IGameInputDevice_GetBatteryState(device, &battery_state);
 
-    if (battery_state.status == GameInputBatteryDischarging) {
-        /* FIXME: What are the units for remainingCapacity? */
-    }
-    return SDL_JOYSTICK_POWER_UNKNOWN;
+    switch (battery_state.status) {
+    case GameInputBatteryNotPresent:
+        state = SDL_POWERSTATE_NO_BATTERY;
+        break;
+    case GameInputBatteryDischarging:
+        state = SDL_POWERSTATE_ON_BATTERY;
+        break;
+    case GameInputBatteryIdle:
+        state = SDL_POWERSTATE_CHARGED;
+        break;
+    case GameInputBatteryCharging:
+        state = SDL_POWERSTATE_CHARGING;
+        break;
+    default:
+        state = SDL_POWERSTATE_UNKNOWN;
+        break;
+    }
+    if (battery_state.fullChargeCapacity > 0.0f) {
+        percent = (int)SDL_roundf((battery_state.remainingCapacity / battery_state.fullChargeCapacity) * 100.0f);
+    }
+    SDL_SendJoystickPowerInfo(joystick, state, percent);
 }
 
 #if 0
@@ -417,9 +436,9 @@ static int GAMEINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
     }
 
     if (info->capabilities & GameInputDeviceCapabilityWireless) {
-        joystick->epowerlevel = GAMEINPUT_InternalGetPowerLevel(elem->device);
+        joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS;
     } else {
-        joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
+        joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRED;
     }
     return 0;
 }
@@ -580,10 +599,8 @@ static void GAMEINPUT_JoystickUpdate(SDL_Joystick *joystick)
 
     IGameInputReading_Release(reading);
 
-    if (joystick->epowerlevel != SDL_JOYSTICK_POWER_WIRED) {
-        /* FIXME: We can poll this at a much lower rate */
-        SDL_SendJoystickBatteryLevel(joystick, GAMEINPUT_InternalGetPowerLevel(device));
-    }
+    /* FIXME: We can poll this at a much lower rate */
+    GAMEINPUT_UpdatePowerInfo(joystick, device);
 }
 
 static void GAMEINPUT_JoystickClose(SDL_Joystick* joystick)

+ 5 - 1
src/joystick/hidapi/SDL_hidapi_gamecube.c

@@ -392,7 +392,11 @@ static SDL_bool HIDAPI_DriverGameCube_OpenJoystick(SDL_HIDAPI_Device *device, SD
         if (joystick->instance_id == ctx->joysticks[i]) {
             joystick->nbuttons = 12;
             joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
-            joystick->epowerlevel = ctx->wireless[i] ? SDL_JOYSTICK_POWER_UNKNOWN : SDL_JOYSTICK_POWER_WIRED;
+            if (ctx->wireless[i]) {
+                joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS;
+            } else {
+                joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRED;
+            }
             return SDL_TRUE;
         }
     }

+ 2 - 12
src/joystick/hidapi/SDL_hidapi_luna.c

@@ -103,7 +103,6 @@ static SDL_bool HIDAPI_DriverLuna_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Jo
     joystick->nbuttons = SDL_GAMEPAD_NUM_LUNA_BUTTONS;
     joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
     joystick->nhats = 1;
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_FULL;
 
     return SDL_TRUE;
 }
@@ -259,17 +258,8 @@ static void HIDAPI_DriverLuna_HandleBluetoothStatePacket(SDL_Joystick *joystick,
 
     if (size >= 2 && data[0] == 0x04) {
         /* Battery level report */
-        int level = data[1] * 100 / 0xFF;
-        if (level == 0) {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
-        } else if (level <= 20) {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
-        } else if (level <= 70) {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
-        } else {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
-        }
-
+        int percent = (int)SDL_roundf((data[1] / 255.0f) * 100.0f);
+        SDL_SendJoystickPowerInfo(joystick, SDL_POWERSTATE_ON_BATTERY, percent);
         return;
     }
 

+ 0 - 3
src/joystick/hidapi/SDL_hidapi_ps3.c

@@ -279,7 +279,6 @@ static SDL_bool HIDAPI_DriverPS3_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
     joystick->nbuttons = 11;
     joystick->naxes = 16;
     joystick->nhats = 1;
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
 
     SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f);
 
@@ -682,7 +681,6 @@ static SDL_bool HIDAPI_DriverPS3ThirdParty_OpenJoystick(SDL_HIDAPI_Device *devic
     joystick->nbuttons = 11;
     joystick->naxes = 16;
     joystick->nhats = 1;
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
 
     return SDL_TRUE;
 }
@@ -1127,7 +1125,6 @@ static SDL_bool HIDAPI_DriverPS3SonySixaxis_OpenJoystick(SDL_HIDAPI_Device *devi
     joystick->nbuttons = 11;
     joystick->naxes = 16;
     joystick->nhats = 1;
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
 
     SDL_PrivateJoystickAddSensor(joystick, SDL_SENSOR_ACCEL, 100.0f);
 

+ 19 - 16
src/joystick/hidapi/SDL_hidapi_ps4.c

@@ -720,7 +720,7 @@ static void HIDAPI_DriverPS4_SetEnhancedModeAvailable(SDL_DriverPS4_Context *ctx
         SDL_PrivateJoystickAddSensor(ctx->joystick, SDL_SENSOR_ACCEL, 250.0f);
     }
 
-    if (ctx->device->is_bluetooth && ctx->official_controller) {
+    if (ctx->official_controller) {
         ctx->report_battery = SDL_TRUE;
     }
 
@@ -833,12 +833,6 @@ static SDL_bool HIDAPI_DriverPS4_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
     }
     joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
     joystick->nhats = 1;
-    if (device->is_bluetooth) {
-        /* We'll update this once we're in enhanced mode */
-        joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
-    } else {
-        joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
-    }
 
     SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE,
                         SDL_PS4RumbleHintChanged, ctx);
@@ -1073,17 +1067,26 @@ static void HIDAPI_DriverPS4_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
     SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, axis);
 
     if (size > 9 && ctx->report_battery && ctx->enhanced_reports) {
-        /* Battery level ranges from 0 to 10 */
-        int level = (packet->ucBatteryLevel & 0xF);
-        if (level == 0) {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
-        } else if (level <= 2) {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
-        } else if (level <= 7) {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
+        SDL_PowerState state;
+        int percent;
+        Uint8 level = (packet->ucBatteryLevel & 0x0F);
+
+        if (packet->ucBatteryLevel & 0x10) {
+            if (level <= 10) {
+                state = SDL_POWERSTATE_CHARGING;
+                percent = SDL_min(level * 10 + 5, 100);
+            } else if (level == 11) {
+                state = SDL_POWERSTATE_CHARGED;
+                percent = 100;
+            } else {
+                state = SDL_POWERSTATE_UNKNOWN;
+                percent = 0;
+            }
         } else {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
+            state = SDL_POWERSTATE_ON_BATTERY;
+            percent = SDL_min(level * 10 + 5, 100);
         }
+        SDL_SendJoystickPowerInfo(joystick, state, percent);
     }
 
     if (size > 9 && ctx->report_touchpad && ctx->enhanced_reports) {

+ 24 - 19
src/joystick/hidapi/SDL_hidapi_ps5.c

@@ -815,9 +815,7 @@ static void HIDAPI_DriverPS5_SetEnhancedModeAvailable(SDL_DriverPS5_Context *ctx
         }
     }
 
-    if (ctx->device->is_bluetooth) {
-        ctx->report_battery = SDL_TRUE;
-    }
+    ctx->report_battery = SDL_TRUE;
 
     HIDAPI_UpdateDeviceProperties(ctx->device);
 }
@@ -956,12 +954,6 @@ static SDL_bool HIDAPI_DriverPS5_OpenJoystick(SDL_HIDAPI_Device *device, SDL_Joy
     }
     joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
     joystick->nhats = 1;
-    if (device->is_bluetooth) {
-        /* We'll update this once we're in enhanced mode */
-        joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
-    } else {
-        joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
-    }
     joystick->firmware_version = ctx->firmware_version;
 
     SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE,
@@ -1387,17 +1379,30 @@ static void HIDAPI_DriverPS5_HandleStatePacket(SDL_Joystick *joystick, SDL_hid_d
     }
 
     if (ctx->report_battery) {
-        /* Battery level ranges from 0 to 10 */
-        int level = (packet->ucBatteryLevel & 0xF);
-        if (level == 0) {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
-        } else if (level <= 2) {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
-        } else if (level <= 7) {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
-        } else {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
+        SDL_PowerState state;
+        int percent;
+        Uint8 status = (packet->ucBatteryLevel >> 4) & 0x0F;
+        Uint8 level = (packet->ucBatteryLevel & 0x0F);
+
+        switch (status) {
+        case 0:
+            state = SDL_POWERSTATE_ON_BATTERY;
+            percent = SDL_min(level * 10 + 5, 100);
+            break;
+        case 1:
+            state = SDL_POWERSTATE_CHARGING;
+            percent = SDL_min(level * 10 + 5, 100);
+            break;
+        case 2:
+            state = SDL_POWERSTATE_CHARGED;
+            percent = 100;
+            break;
+        default:
+            state = SDL_POWERSTATE_UNKNOWN;
+            percent = 0;
+            break;
         }
+        SDL_SendJoystickPowerInfo(joystick, state, percent);
     }
 
     SDL_memcpy(&ctx->last_state, packet, sizeof(ctx->last_state));

+ 21 - 30
src/joystick/hidapi/SDL_hidapi_shield.c

@@ -77,8 +77,10 @@ typedef struct
 {
     Uint8 seq_num;
 
-    SDL_JoystickPowerLevel battery_level;
-    SDL_bool charging;
+    SDL_bool has_charging;
+    Uint8 charging;
+    SDL_bool has_battery_level;
+    Uint8 battery_level;
     Uint64 last_battery_query_time;
 
     SDL_bool rumble_report_pending;
@@ -184,14 +186,12 @@ static SDL_bool HIDAPI_DriverShield_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
         joystick->nbuttons = SDL_GAMEPAD_NUM_SHIELD_V103_BUTTONS;
         joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
         joystick->nhats = 1;
-        joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
 
         SDL_PrivateJoystickAddTouchpad(joystick, 1);
     } else {
         joystick->nbuttons = SDL_GAMEPAD_NUM_SHIELD_V104_BUTTONS;
         joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
         joystick->nhats = 1;
-        joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
     }
 
     /* Request battery and charging info */
@@ -451,6 +451,17 @@ static void HIDAPI_DriverShield_HandleStatePacketV104(SDL_Joystick *joystick, SD
     SDL_memcpy(ctx->last_state, data, SDL_min(size, sizeof(ctx->last_state)));
 }
 
+static void HIDAPI_DriverShield_UpdatePowerInfo(SDL_Joystick *joystick, SDL_DriverShield_Context *ctx)
+{
+    if (!ctx->has_charging || !ctx->has_battery_level) {
+        return;
+    }
+
+    SDL_PowerState state = ctx->charging ? SDL_POWERSTATE_CHARGING : SDL_POWERSTATE_ON_BATTERY;
+    int percent = ctx->battery_level * 20;
+    SDL_SendJoystickPowerInfo(joystick, state, percent);
+}
+
 static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device)
 {
     SDL_DriverShield_Context *ctx = (SDL_DriverShield_Context *)device->context;
@@ -496,34 +507,14 @@ static SDL_bool HIDAPI_DriverShield_UpdateDevice(SDL_HIDAPI_Device *device)
                 HIDAPI_DriverShield_SendNextRumble(device);
                 break;
             case CMD_CHARGE_STATE:
-                ctx->charging = cmd_resp_report->payload[0] != 0;
-                if (joystick) {
-                    SDL_SendJoystickBatteryLevel(joystick, ctx->charging ? SDL_JOYSTICK_POWER_WIRED : ctx->battery_level);
-                }
+                ctx->has_charging = SDL_TRUE;
+                ctx->charging = cmd_resp_report->payload[0];
+                HIDAPI_DriverShield_UpdatePowerInfo(joystick, ctx);
                 break;
             case CMD_BATTERY_STATE:
-                switch (cmd_resp_report->payload[2]) {
-                case 0:
-                    ctx->battery_level = SDL_JOYSTICK_POWER_EMPTY;
-                    break;
-                case 1:
-                    ctx->battery_level = SDL_JOYSTICK_POWER_LOW;
-                    break;
-                case 2: /* 40% */
-                case 3: /* 60% */
-                case 4: /* 80% */
-                    ctx->battery_level = SDL_JOYSTICK_POWER_MEDIUM;
-                    break;
-                case 5:
-                    ctx->battery_level = SDL_JOYSTICK_POWER_FULL;
-                    break;
-                default:
-                    ctx->battery_level = SDL_JOYSTICK_POWER_UNKNOWN;
-                    break;
-                }
-                if (joystick) {
-                    SDL_SendJoystickBatteryLevel(joystick, ctx->charging ? SDL_JOYSTICK_POWER_WIRED : ctx->battery_level);
-                }
+                ctx->has_battery_level = SDL_TRUE;
+                ctx->battery_level = cmd_resp_report->payload[2];
+                HIDAPI_DriverShield_UpdatePowerInfo(joystick, ctx);
                 break;
             }
             break;

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_stadia.c

@@ -109,7 +109,6 @@ static SDL_bool HIDAPI_DriverStadia_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
     joystick->nbuttons = SDL_GAMEPAD_NUM_STADIA_BUTTONS;
     joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
     joystick->nhats = 1;
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
 
     return SDL_TRUE;
 }

+ 23 - 20
src/joystick/hidapi/SDL_hidapi_switch.c

@@ -1447,7 +1447,6 @@ static SDL_bool HIDAPI_DriverSwitch_OpenJoystick(SDL_HIDAPI_Device *device, SDL_
     joystick->nbuttons = SDL_GAMEPAD_NUM_SWITCH_BUTTONS;
     joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
     joystick->nhats = 1;
-    joystick->epowerlevel = device->is_bluetooth ? SDL_JOYSTICK_POWER_UNKNOWN : SDL_JOYSTICK_POWER_WIRED;
 
     /* Set up for input */
     ctx->m_bSyncWrite = SDL_FALSE;
@@ -2095,28 +2094,32 @@ static void HandleFullControllerState(SDL_Joystick *joystick, SDL_DriverSwitch_C
         SDL_SendJoystickAxis(timestamp, joystick, SDL_GAMEPAD_AXIS_RIGHTY, ~axis);
     }
 
-    if (ctx->device->is_bluetooth) {
-        /* High nibble of battery/connection byte is battery level, low nibble is connection status
-         * LSB of connection nibble is USB/Switch connection status
-         */
-        if (packet->controllerState.ucBatteryAndConnection & 0x1) {
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
+    /* High nibble of battery/connection byte is battery level, low nibble is connection status
+     * LSB of connection nibble is USB/Switch connection status
+     * LSB of the battery nibble is used to report charging.
+     * The battery level is reported from 0(empty)-8(full)
+     */
+    SDL_PowerState state;
+    int charging = (packet->controllerState.ucBatteryAndConnection & 0x10);
+    int level = (packet->controllerState.ucBatteryAndConnection & 0xE0) >> 4;
+    int percent = (int)SDL_roundf((level / 8.0f) * 100.0f);
+
+    if (packet->controllerState.ucBatteryAndConnection & 0x01) {
+        joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRED;
+    } else {
+        joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS;
+    }
+
+    if (charging) {
+        if (level == 8) {
+            state = SDL_POWERSTATE_CHARGED;
         } else {
-            /* LSB of the battery nibble is used to report charging.
-             * The battery level is reported from 0(empty)-8(full)
-             */
-            int level = (packet->controllerState.ucBatteryAndConnection & 0xE0) >> 4;
-            if (level == 0) {
-                SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
-            } else if (level <= 2) {
-                SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
-            } else if (level <= 6) {
-                SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
-            } else {
-                SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
-            }
+            state = SDL_POWERSTATE_CHARGING;
         }
+    } else {
+        state = SDL_POWERSTATE_ON_BATTERY;
     }
+    SDL_SendJoystickPowerInfo(joystick, state, percent);
 
     if (ctx->m_bReportSensors) {
         SDL_bool bHasSensorData = (packet->imuState[0].sAccelZ != 0 ||

+ 30 - 12
src/joystick/hidapi/SDL_hidapi_wii.c

@@ -493,15 +493,17 @@ static void DeactivateMotionPlus(SDL_DriverWii_Context *ctx)
 
 static void UpdatePowerLevelWii(SDL_Joystick *joystick, Uint8 batteryLevelByte)
 {
+    int percent;
     if (batteryLevelByte > 178) {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
+        percent = 100;
     } else if (batteryLevelByte > 51) {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
+        percent = 70;
     } else if (batteryLevelByte > 13) {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
+        percent = 20;
     } else {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
+        percent = 5;
     }
+    SDL_SendJoystickPowerInfo(joystick, SDL_POWERSTATE_ON_BATTERY, percent);
 }
 
 static void UpdatePowerLevelWiiU(SDL_Joystick *joystick, Uint8 extensionBatteryByte)
@@ -510,23 +512,39 @@ static void UpdatePowerLevelWiiU(SDL_Joystick *joystick, Uint8 extensionBatteryB
     SDL_bool pluggedIn = !(extensionBatteryByte & 0x04);
     Uint8 batteryLevel = extensionBatteryByte >> 4;
 
+    if (pluggedIn) {
+        joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRED;
+    } else {
+        joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS;
+    }
+
     /* Not sure if all Wii U Pro controllers act like this, but on mine
      * 4, 3, and 2 are held for about 20 hours each
      * 1 is held for about 6 hours
      * 0 is held for about 2 hours
      * No value above 4 has been observed.
      */
-    if (pluggedIn && !charging) {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
-    } else if (batteryLevel >= 4) {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
-    } else if (batteryLevel > 1) {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
+    SDL_PowerState state;
+    int percent;
+    if (charging) {
+        state = SDL_POWERSTATE_CHARGING;
+    } else if (pluggedIn) {
+        state = SDL_POWERSTATE_CHARGED;
+    } else {
+        state = SDL_POWERSTATE_ON_BATTERY;
+    }
+    if (batteryLevel >= 4) {
+        percent = 100;
+    } else if (batteryLevel == 3) {
+        percent = 70;
+    } else if (batteryLevel == 2) {
+        percent = 40;
     } else if (batteryLevel == 1) {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
+        percent = 10;
     } else {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
+        percent = 3;
     }
+    SDL_SendJoystickPowerInfo(joystick, state, percent);
 }
 
 static EWiiInputReportIDs GetButtonPacketType(SDL_DriverWii_Context *ctx)

+ 0 - 1
src/joystick/hidapi/SDL_hidapi_xbox360.c

@@ -191,7 +191,6 @@ static SDL_bool HIDAPI_DriverXbox360_OpenJoystick(SDL_HIDAPI_Device *device, SDL
     joystick->nbuttons = 11;
     joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
     joystick->nhats = 1;
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
 
     return SDL_TRUE;
 }

+ 2 - 12
src/joystick/hidapi/SDL_hidapi_xbox360w.c

@@ -109,17 +109,8 @@ static void SDLCALL SDL_PlayerLEDHintChanged(void *userdata, const char *name, c
 
 static void UpdatePowerLevel(SDL_Joystick *joystick, Uint8 level)
 {
-    float normalized_level = (float)level / 255.0f;
-
-    if (normalized_level <= 0.05f) {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_EMPTY);
-    } else if (normalized_level <= 0.20f) {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
-    } else if (normalized_level <= 0.70f) {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
-    } else {
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
-    }
+    int percent = (int)SDL_roundf((level / 255.0f) * 100.0f);
+    SDL_SendJoystickPowerInfo(joystick, SDL_POWERSTATE_ON_BATTERY, percent);
 }
 
 static SDL_bool HIDAPI_DriverXbox360W_InitDevice(SDL_HIDAPI_Device *device)
@@ -186,7 +177,6 @@ static SDL_bool HIDAPI_DriverXbox360W_OpenJoystick(SDL_HIDAPI_Device *device, SD
     /* Initialize the joystick capabilities */
     joystick->nbuttons = 15;
     joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
 
     return SDL_TRUE;
 }

+ 22 - 18
src/joystick/hidapi/SDL_hidapi_xboxone.c

@@ -432,10 +432,6 @@ static SDL_bool HIDAPI_DriverXboxOne_OpenJoystick(SDL_HIDAPI_Device *device, SDL
     joystick->naxes = SDL_GAMEPAD_AXIS_MAX;
     joystick->nhats = 1;
 
-    if (!device->is_bluetooth) {
-        joystick->epowerlevel = SDL_JOYSTICK_POWER_WIRED;
-    }
-
     SDL_AddHintCallback(SDL_HINT_JOYSTICK_HIDAPI_XBOX_ONE_HOME_LED,
                         SDL_HomeLEDHintChanged, ctx);
     return SDL_TRUE;
@@ -1068,23 +1064,31 @@ static void HIDAPI_DriverXboxOneBluetooth_HandleBatteryPacket(SDL_Joystick *joys
 {
     Uint8 flags = data[1];
     SDL_bool on_usb = (((flags & 0x0C) >> 2) == 0);
-
+    SDL_PowerState state;
+    int percent;
+
+    // Mapped percentage value from:
+    // https://learn.microsoft.com/en-us/gaming/gdk/_content/gc/reference/input/gameinput/interfaces/igameinputdevice/methods/igameinputdevice_getbatterystate
+    switch (flags & 0x03) {
+    case 0:
+        percent = 10;
+        break;
+    case 1:
+        percent = 40;
+        break;
+    case 2:
+        percent = 70;
+        break;
+    case 3:
+        percent = 100;
+        break;
+    }
     if (on_usb) {
-        /* Does this ever happen? */
-        SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_WIRED);
+        state = SDL_POWERSTATE_CHARGING;
     } else {
-        switch ((flags & 0x03)) {
-        case 0:
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_LOW);
-            break;
-        case 1:
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_MEDIUM);
-            break;
-        default: /* 2, 3 */
-            SDL_SendJoystickBatteryLevel(joystick, SDL_JOYSTICK_POWER_FULL);
-            break;
-        }
+        state = SDL_POWERSTATE_ON_BATTERY;
     }
+    SDL_SendJoystickPowerInfo(joystick, state, percent);
 }
 
 static void HIDAPI_DriverXboxOne_HandleSerialIDPacket(SDL_DriverXboxOne_Context *ctx, const Uint8 *data, int size)

+ 7 - 0
src/joystick/hidapi/SDL_hidapijoystick.c

@@ -1517,6 +1517,13 @@ static int HIDAPI_JoystickOpen(SDL_Joystick *joystick, int device_index)
         return SDL_SetError("HIDAPI device disconnected while opening");
     }
 
+    /* Set the default connection state, can be overridden below */
+    if (device->is_bluetooth) {
+        joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS;
+    } else {
+        joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRED;
+    }
+
     if (!device->driver->OpenJoystick(device, joystick)) {
         /* The open failed, mark this device as disconnected and update devices */
         HIDAPI_JoystickDisconnected(device, joystickID);

+ 29 - 25
src/joystick/windows/SDL_rawinputjoystick.c

@@ -1426,8 +1426,6 @@ static int RAWINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index)
         }
     }
 
-    joystick->epowerlevel = SDL_JOYSTICK_POWER_UNKNOWN;
-
 #ifdef SDL_JOYSTICK_RAWINPUT_XINPUT
     if (ctx->is_xinput) {
         SDL_SetBooleanProperty(SDL_GetJoystickProperties(joystick), SDL_PROP_JOYSTICK_CAP_RUMBLE_BOOLEAN, SDL_TRUE);
@@ -1961,30 +1959,36 @@ static void RAWINPUT_UpdateOtherAPIs(SDL_Joystick *joystick)
             }
             has_trigger_data = SDL_TRUE;
 
-            if (battery_info->BatteryType != BATTERY_TYPE_UNKNOWN &&
-                battery_info->BatteryType != BATTERY_TYPE_DISCONNECTED) {
-                SDL_JoystickPowerLevel ePowerLevel = SDL_JOYSTICK_POWER_UNKNOWN;
-                if (battery_info->BatteryType == BATTERY_TYPE_WIRED) {
-                    ePowerLevel = SDL_JOYSTICK_POWER_WIRED;
-                } else {
-                    switch (battery_info->BatteryLevel) {
-                    case BATTERY_LEVEL_EMPTY:
-                        ePowerLevel = SDL_JOYSTICK_POWER_EMPTY;
-                        break;
-                    case BATTERY_LEVEL_LOW:
-                        ePowerLevel = SDL_JOYSTICK_POWER_LOW;
-                        break;
-                    case BATTERY_LEVEL_MEDIUM:
-                        ePowerLevel = SDL_JOYSTICK_POWER_MEDIUM;
-                        break;
-                    default:
-                    case BATTERY_LEVEL_FULL:
-                        ePowerLevel = SDL_JOYSTICK_POWER_FULL;
-                        break;
-                    }
-                }
-                SDL_SendJoystickBatteryLevel(joystick, ePowerLevel);
+            SDL_PowerState state;
+            int percent;
+            switch (battery_info->BatteryType) {
+            case BATTERY_TYPE_WIRED:
+                state = SDL_POWERSTATE_CHARGING;
+                break;
+            case BATTERY_TYPE_UNKNOWN:
+            case BATTERY_TYPE_DISCONNECTED:
+                state = SDL_POWERSTATE_UNKNOWN;
+                break;
+            default:
+                state = SDL_POWERSTATE_ON_BATTERY;
+                break;
+            }
+            switch (battery_info->BatteryLevel) {
+            case BATTERY_LEVEL_EMPTY:
+                percent = 10;
+                break;
+            case BATTERY_LEVEL_LOW:
+                percent = 40;
+                break;
+            case BATTERY_LEVEL_MEDIUM:
+                percent = 70;
+                break;
+            default:
+            case BATTERY_LEVEL_FULL:
+                percent = 100;
+                break;
             }
+            SDL_SendJoystickPowerInfo(joystick, state, percent);
         }
     }
 #endif /* SDL_JOYSTICK_RAWINPUT_XINPUT */

+ 34 - 13
src/joystick/windows/SDL_windows_gaming_input.c

@@ -739,7 +739,11 @@ static int WGI_JoystickOpen(SDL_Joystick *joystick, int device_index)
     }
 
     /* Initialize the joystick capabilities */
-    joystick->epowerlevel = wireless ? SDL_JOYSTICK_POWER_UNKNOWN : SDL_JOYSTICK_POWER_WIRED;
+    if (wireless) {
+        joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRELESS;
+    } else {
+        joystick->connection_state = SDL_JOYSTICK_CONNECTION_WIRED;
+    }
     __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_ButtonCount(hwdata->controller, &joystick->nbuttons);
     __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_AxisCount(hwdata->controller, &joystick->naxes);
     __x_ABI_CWindows_CGaming_CInput_CIRawGameController_get_SwitchCount(hwdata->controller, &joystick->nhats);
@@ -893,14 +897,38 @@ static void WGI_JoystickUpdate(SDL_Joystick *joystick)
     SDL_stack_free(hats);
     SDL_stack_free(axes);
 
-    if (joystick->epowerlevel != SDL_JOYSTICK_POWER_WIRED && hwdata->battery) {
+    if (hwdata->battery) {
         __x_ABI_CWindows_CDevices_CPower_CIBatteryReport *report = NULL;
 
         hr = __x_ABI_CWindows_CGaming_CInput_CIGameControllerBatteryInfo_TryGetBatteryReport(hwdata->battery, &report);
         if (SUCCEEDED(hr) && report) {
+            SDL_PowerState state = SDL_POWERSTATE_UNKNOWN;
+            int percent = 0;
+            __x_ABI_CWindows_CSystem_CPower_CBatteryStatus status;
             int full_capacity = 0, curr_capacity = 0;
             __FIReference_1_int *full_capacityP, *curr_capacityP;
 
+            hr = __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_Status(report, &status);
+            if (SUCCEEDED(hr)) {
+                switch (status) {
+                case BatteryStatus_NotPresent:
+                    state = SDL_POWERSTATE_NO_BATTERY;
+                    break;
+                case BatteryStatus_Discharging:
+                    state = SDL_POWERSTATE_ON_BATTERY;
+                    break;
+                case BatteryStatus_Idle:
+                    state = SDL_POWERSTATE_CHARGED;
+                    break;
+                case BatteryStatus_Charging:
+                    state = SDL_POWERSTATE_CHARGING;
+                    break;
+                default:
+                    state = SDL_POWERSTATE_UNKNOWN;
+                    break;
+                }
+            }
+
             hr = __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_get_FullChargeCapacityInMilliwattHours(report, &full_capacityP);
             if (SUCCEEDED(hr)) {
                 __FIReference_1_int_get_Value(full_capacityP, &full_capacity);
@@ -914,18 +942,11 @@ static void WGI_JoystickUpdate(SDL_Joystick *joystick)
             }
 
             if (full_capacity > 0) {
-                float ratio = (float)curr_capacity / full_capacity;
-
-                if (ratio <= 0.05f) {
-                    joystick->epowerlevel = SDL_JOYSTICK_POWER_EMPTY;
-                } else if (ratio <= 0.20f) {
-                    joystick->epowerlevel = SDL_JOYSTICK_POWER_LOW;
-                } else if (ratio <= 0.70f) {
-                    joystick->epowerlevel = SDL_JOYSTICK_POWER_MEDIUM;
-                } else {
-                    joystick->epowerlevel = SDL_JOYSTICK_POWER_FULL;
-                }
+                percent = (int)SDL_roundf(((float)curr_capacity / full_capacity) * 100.0f);
             }
+
+            SDL_SendJoystickPowerInfo(joystick, state, percent);
+
             __x_ABI_CWindows_CDevices_CPower_CIBatteryReport_Release(report);
         }
     }

+ 29 - 23
src/joystick/windows/SDL_xinputjoystick.c

@@ -289,30 +289,36 @@ int SDL_XINPUT_JoystickOpen(SDL_Joystick *joystick, JoyStick_DeviceData *joystic
 
 static void UpdateXInputJoystickBatteryInformation(SDL_Joystick *joystick, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)
 {
-    if (pBatteryInformation->BatteryType != BATTERY_TYPE_UNKNOWN) {
-        SDL_JoystickPowerLevel ePowerLevel = SDL_JOYSTICK_POWER_UNKNOWN;
-        if (pBatteryInformation->BatteryType == BATTERY_TYPE_WIRED) {
-            ePowerLevel = SDL_JOYSTICK_POWER_WIRED;
-        } else {
-            switch (pBatteryInformation->BatteryLevel) {
-            case BATTERY_LEVEL_EMPTY:
-                ePowerLevel = SDL_JOYSTICK_POWER_EMPTY;
-                break;
-            case BATTERY_LEVEL_LOW:
-                ePowerLevel = SDL_JOYSTICK_POWER_LOW;
-                break;
-            case BATTERY_LEVEL_MEDIUM:
-                ePowerLevel = SDL_JOYSTICK_POWER_MEDIUM;
-                break;
-            default:
-            case BATTERY_LEVEL_FULL:
-                ePowerLevel = SDL_JOYSTICK_POWER_FULL;
-                break;
-            }
-        }
-
-        SDL_SendJoystickBatteryLevel(joystick, ePowerLevel);
+    SDL_PowerState state;
+    int percent;
+    switch (pBatteryInformation->BatteryType) {
+    case BATTERY_TYPE_WIRED:
+        state = SDL_POWERSTATE_CHARGING;
+        break;
+    case BATTERY_TYPE_UNKNOWN:
+    case BATTERY_TYPE_DISCONNECTED:
+        state = SDL_POWERSTATE_UNKNOWN;
+        break;
+    default:
+        state = SDL_POWERSTATE_ON_BATTERY;
+        break;
+    }
+    switch (pBatteryInformation->BatteryLevel) {
+    case BATTERY_LEVEL_EMPTY:
+        percent = 10;
+        break;
+    case BATTERY_LEVEL_LOW:
+        percent = 40;
+        break;
+    case BATTERY_LEVEL_MEDIUM:
+        percent = 70;
+        break;
+    default:
+    case BATTERY_LEVEL_FULL:
+        percent = 100;
+        break;
     }
+    SDL_SendJoystickPowerInfo(joystick, state, percent);
 }
 
 static void UpdateXInputJoystickState(SDL_Joystick *joystick, XINPUT_STATE *pXInputState, XINPUT_BATTERY_INFORMATION_EX *pBatteryInformation)

+ 1 - 5
test/CMakeLists.txt

@@ -340,11 +340,7 @@ files2headers(gamepad_image_headers
     gamepad_axis_arrow.bmp
     gamepad_axis.bmp
     gamepad_back.bmp
-    gamepad_battery_empty.bmp
-    gamepad_battery_full.bmp
-    gamepad_battery_low.bmp
-    gamepad_battery_medium.bmp
-    gamepad_battery_unknown.bmp
+    gamepad_battery.bmp
     gamepad_battery_wired.bmp
     gamepad_button_background.bmp
     gamepad_button.bmp

BIN
test/gamepad_battery.bmp


+ 82 - 81
test/gamepad_battery_empty.h → test/gamepad_battery.h

@@ -1,15 +1,16 @@
-unsigned char gamepad_battery_empty_bmp[] = {
-  0x42, 0x4d, 0x3a, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0x00,
-  0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10, 0x00,
+unsigned char gamepad_battery_bmp[] = {
+  0x42, 0x4d, 0x4a, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8a, 0x00,
+  0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10, 0x00,
   0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x07,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
-  0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x20, 0x6e,
-  0x69, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x42, 0x47,
+  0x52, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x26, 0x26, 0x26, 0xbc, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+  0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x26, 0x26, 0x26, 0xbc, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
@@ -18,9 +19,9 @@ unsigned char gamepad_battery_empty_bmp[] = {
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x1a, 0x1a, 0x1a, 0xfb, 0x30, 0x30, 0x30, 0x59, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xf5, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
+  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x1a, 0x1a, 0x1a, 0xfb, 0x30, 0x30,
+  0x30, 0x59, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+  0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
@@ -28,20 +29,10 @@ unsigned char gamepad_battery_empty_bmp[] = {
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
+  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0x0a, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
@@ -51,110 +42,120 @@ unsigned char gamepad_battery_empty_bmp[] = {
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0x56, 0x56,
-  0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0x00, 0xcc, 0x15, 0xff, 0x0a, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01, 0x01,
-  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xeb, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff,
-  0xff, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0xff, 0xff,
+  0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0x56, 0x56, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06,
-  0x06, 0x00, 0x4a, 0x4a, 0x4a, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03,
+  0x03, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x23, 0x23, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
-  0x01, 0x00, 0xff, 0xff, 0xff, 0x00, 0x17, 0x17, 0x17, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-  0x02, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0x00, 0xff, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
+  0x00, 0xc2, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
+  0x0a, 0x00, 0xff, 0xff, 0xff, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01,
+  0x01, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x06, 0x06, 0x06, 0x00, 0x4a, 0x4a, 0x4a, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01, 0x01,
-  0x01, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
-  0x01, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0x00, 0xcc, 0x15, 0xff, 0x0a, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x23,
+  0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0xff, 0xff, 0xff, 0x00, 0x17, 0x17,
+  0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff,
+  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+  0xff, 0x00, 0x01, 0x01, 0x01, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x00, 0x23, 0x23, 0x23, 0x00, 0xff, 0xff,
+  0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0x0a, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
+  0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x2e, 0x2e, 0x2e, 0x00, 0x0b, 0x0b,
-  0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x00, 0x23, 0x23,
+  0x23, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
   0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0x00, 0xcc, 0x15, 0xff, 0x0a, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x44, 0x44,
+  0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x2e, 0x2e,
+  0x2e, 0x00, 0x0b, 0x0b, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x02, 0x02, 0x02, 0x00, 0x0b, 0x0b, 0x0b, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x11, 0x11, 0x11, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01, 0x01,
-  0x01, 0x00, 0x32, 0x32, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x92, 0x92, 0x92, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff,
+  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x02, 0x02, 0x02, 0x00, 0x0b, 0x0b,
+  0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11, 0x11, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0x01, 0x01, 0x01, 0x00, 0x32, 0x32, 0x32, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x92, 0x92, 0x92, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
+  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
+  0x0a, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x02, 0x02, 0x02, 0x00, 0x1a, 0x1a, 0x1a, 0x00, 0x45, 0x45,
-  0x45, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xc2, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00,
+  0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x02, 0x02, 0x02, 0x00, 0x1a, 0x1a,
+  0x1a, 0x00, 0x45, 0x45, 0x45, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+  0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00,
+  0x00, 0xcc, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+  0x00, 0xcc, 0x15, 0xff, 0x0a, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+  0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
+  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
   0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
+  0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
+  0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x00,
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
@@ -162,9 +163,9 @@ unsigned char gamepad_battery_empty_bmp[] = {
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
   0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x0d, 0x0d, 0x0d, 0xaf, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
+  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
+  0x00, 0xd6, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff,
+  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x0d, 0x0d, 0x0d, 0xaf, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
@@ -173,7 +174,7 @@ unsigned char gamepad_battery_empty_bmp[] = {
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
   0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x0a, 0x0a, 0x0a, 0x52, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00
+  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x0a, 0x0a,
+  0x0a, 0x52, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00
 };
-unsigned int gamepad_battery_empty_bmp_len = 2106;
+unsigned int gamepad_battery_bmp_len = 2122;

BIN
test/gamepad_battery_empty.bmp


BIN
test/gamepad_battery_full.bmp


+ 0 - 179
test/gamepad_battery_full.h

@@ -1,179 +0,0 @@
-unsigned char gamepad_battery_full_bmp[] = {
-  0x42, 0x4d, 0x3a, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0x00,
-  0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10, 0x00,
-  0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x07,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
-  0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x20, 0x6e,
-  0x69, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x26, 0x26, 0x26, 0xbc, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x1a, 0x1a, 0x1a, 0xfb, 0x30, 0x30, 0x30, 0x59, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xf5, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xeb, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xc2, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x0d, 0x0d, 0x0d, 0xaf, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x0a, 0x0a, 0x0a, 0x52, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00
-};
-unsigned int gamepad_battery_full_bmp_len = 2106;

BIN
test/gamepad_battery_low.bmp


+ 0 - 179
test/gamepad_battery_low.h

@@ -1,179 +0,0 @@
-unsigned char gamepad_battery_low_bmp[] = {
-  0x42, 0x4d, 0x3a, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0x00,
-  0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10, 0x00,
-  0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x07,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
-  0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x20, 0x6e,
-  0x69, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x26, 0x26, 0x26, 0xbc, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x1a, 0x1a, 0x1a, 0xfb, 0x30, 0x30, 0x30, 0x59, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xf5, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01, 0x01,
-  0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xeb, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06,
-  0x06, 0x00, 0x4a, 0x4a, 0x4a, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x23, 0x23, 0x23, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
-  0x01, 0x00, 0xff, 0xff, 0xff, 0x00, 0x17, 0x17, 0x17, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02,
-  0x02, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x01, 0x01,
-  0x01, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01,
-  0x01, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x1f, 0x1f, 0x1f, 0x00, 0x23, 0x23, 0x23, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x44, 0x44, 0x44, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x2e, 0x2e, 0x2e, 0x00, 0x0b, 0x0b,
-  0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x02, 0x02, 0x02, 0x00, 0x0b, 0x0b, 0x0b, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x11, 0x11, 0x11, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x01, 0x01,
-  0x01, 0x00, 0x32, 0x32, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x92, 0x92, 0x92, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x03, 0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x02, 0x02, 0x02, 0x00, 0x1a, 0x1a, 0x1a, 0x00, 0x45, 0x45,
-  0x45, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xc2, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x0d, 0x0d, 0x0d, 0xaf, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x0a, 0x0a, 0x0a, 0x52, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00
-};
-unsigned int gamepad_battery_low_bmp_len = 2106;

BIN
test/gamepad_battery_medium.bmp


+ 0 - 179
test/gamepad_battery_medium.h

@@ -1,179 +0,0 @@
-unsigned char gamepad_battery_medium_bmp[] = {
-  0x42, 0x4d, 0x3a, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7a, 0x00,
-  0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x10, 0x00,
-  0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x03, 0x00, 0x00, 0x00, 0xc0, 0x07,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff,
-  0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x20, 0x6e,
-  0x69, 0x57, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x26, 0x26, 0x26, 0xbc, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x1a, 0x1a, 0x1a, 0xfb, 0x30, 0x30, 0x30, 0x59, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xf5, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xeb, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x01, 0x01,
-  0x01, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x1f, 0x1f, 0x1f, 0x00, 0x23, 0x23, 0x23, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x01, 0x01,
-  0x01, 0x00, 0x32, 0x32, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-  0x00, 0x00, 0x92, 0x92, 0x92, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x02, 0x02, 0x02, 0x00, 0x1a, 0x1a, 0x1a, 0x00, 0x45, 0x45,
-  0x45, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xeb, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xc2, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xcc, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xcc, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff,
-  0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0x15, 0xff, 0x0a, 0xff, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00,
-  0x00, 0xcc, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0x99, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff,
-  0xff, 0x00, 0x0d, 0x0d, 0x0d, 0xaf, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00,
-  0x00, 0xff, 0x00, 0x00, 0x00, 0xf5, 0x0a, 0x0a, 0x0a, 0x52, 0xff, 0xff,
-  0xff, 0x00, 0xff, 0xff, 0xff, 0x00
-};
-unsigned int gamepad_battery_medium_bmp_len = 2106;

+ 37 - 17
test/gamepadutils.c

@@ -18,11 +18,7 @@
 #include "gamepad_face_abxy.h"
 #include "gamepad_face_bayx.h"
 #include "gamepad_face_sony.h"
-#include "gamepad_battery_unknown.h"
-#include "gamepad_battery_empty.h"
-#include "gamepad_battery_low.h"
-#include "gamepad_battery_medium.h"
-#include "gamepad_battery_full.h"
+#include "gamepad_battery.h"
 #include "gamepad_battery_wired.h"
 #include "gamepad_touchpad.h"
 #include "gamepad_button.h"
@@ -99,7 +95,7 @@ struct GamepadImage
     SDL_Texture *face_abxy_texture;
     SDL_Texture *face_bayx_texture;
     SDL_Texture *face_sony_texture;
-    SDL_Texture *battery_texture[1 + SDL_JOYSTICK_POWER_MAX];
+    SDL_Texture *battery_texture[2];
     SDL_Texture *touchpad_texture;
     SDL_Texture *button_texture;
     SDL_Texture *axis_texture;
@@ -125,7 +121,8 @@ struct GamepadImage
 
     SDL_bool elements[SDL_GAMEPAD_ELEMENT_MAX];
 
-    SDL_JoystickPowerLevel battery_level;
+    SDL_PowerState battery_state;
+    int battery_percent;
 
     int num_fingers;
     GamepadTouchpadFinger *fingers;
@@ -160,13 +157,9 @@ GamepadImage *CreateGamepadImage(SDL_Renderer *renderer)
         ctx->face_sony_texture = CreateTexture(renderer, gamepad_face_sony_bmp, gamepad_face_sony_bmp_len);
         SDL_QueryTexture(ctx->face_abxy_texture, NULL, NULL, &ctx->face_width, &ctx->face_height);
 
-        ctx->battery_texture[1 + SDL_JOYSTICK_POWER_UNKNOWN] = CreateTexture(renderer, gamepad_battery_unknown_bmp, gamepad_battery_unknown_bmp_len);
-        ctx->battery_texture[1 + SDL_JOYSTICK_POWER_EMPTY] = CreateTexture(renderer, gamepad_battery_empty_bmp, gamepad_battery_empty_bmp_len);
-        ctx->battery_texture[1 + SDL_JOYSTICK_POWER_LOW] = CreateTexture(renderer, gamepad_battery_low_bmp, gamepad_battery_low_bmp_len);
-        ctx->battery_texture[1 + SDL_JOYSTICK_POWER_MEDIUM] = CreateTexture(renderer, gamepad_battery_medium_bmp, gamepad_battery_medium_bmp_len);
-        ctx->battery_texture[1 + SDL_JOYSTICK_POWER_FULL] = CreateTexture(renderer, gamepad_battery_full_bmp, gamepad_battery_full_bmp_len);
-        ctx->battery_texture[1 + SDL_JOYSTICK_POWER_WIRED] = CreateTexture(renderer, gamepad_battery_wired_bmp, gamepad_battery_wired_bmp_len);
-        SDL_QueryTexture(ctx->battery_texture[1 + SDL_JOYSTICK_POWER_UNKNOWN], NULL, NULL, &ctx->battery_width, &ctx->battery_height);
+        ctx->battery_texture[0] = CreateTexture(renderer, gamepad_battery_bmp, gamepad_battery_bmp_len);
+        ctx->battery_texture[1] = CreateTexture(renderer, gamepad_battery_wired_bmp, gamepad_battery_wired_bmp_len);
+        SDL_QueryTexture(ctx->battery_texture[0], NULL, NULL, &ctx->battery_width, &ctx->battery_height);
 
         ctx->touchpad_texture = CreateTexture(renderer, gamepad_touchpad_bmp, gamepad_touchpad_bmp_len);
         SDL_QueryTexture(ctx->touchpad_texture, NULL, NULL, &ctx->touchpad_width, &ctx->touchpad_height);
@@ -469,7 +462,7 @@ void UpdateGamepadImageFromGamepad(GamepadImage *ctx, SDL_Gamepad *gamepad)
         }
     }
 
-    ctx->battery_level = SDL_GetGamepadPowerLevel(gamepad);
+    ctx->battery_state = SDL_GetGamepadPowerInfo(gamepad, &ctx->battery_percent);
 
     if (SDL_GetNumGamepadTouchpads(gamepad) > 0) {
         int num_fingers = SDL_GetNumGamepadTouchpadFingers(gamepad, 0);
@@ -571,12 +564,39 @@ void RenderGamepadImage(GamepadImage *ctx)
         }
     }
 
-    if (ctx->display_mode == CONTROLLER_MODE_TESTING && ctx->battery_level != SDL_JOYSTICK_POWER_UNKNOWN) {
+    if (ctx->display_mode == CONTROLLER_MODE_TESTING &&
+        ctx->battery_state != SDL_POWERSTATE_NO_BATTERY &&
+        ctx->battery_state != SDL_POWERSTATE_UNKNOWN) {
+        Uint8 r, g, b, a;
+        SDL_FRect fill;
+
         dst.x = (float)ctx->x + ctx->gamepad_width - ctx->battery_width;
         dst.y = (float)ctx->y;
         dst.w = (float)ctx->battery_width;
         dst.h = (float)ctx->battery_height;
-        SDL_RenderTexture(ctx->renderer, ctx->battery_texture[1 + ctx->battery_level], NULL, &dst);
+
+        SDL_GetRenderDrawColor(ctx->renderer, &r, &g, &b, &a);
+        if (ctx->battery_percent > 40) {
+            SDL_SetRenderDrawColor(ctx->renderer, 0x00, 0xD4, 0x50, 0xFF);
+        } else if (ctx->battery_percent > 10) {
+            SDL_SetRenderDrawColor(ctx->renderer, 0xFF, 0xC7, 0x00, 0xFF);
+        } else {
+            SDL_SetRenderDrawColor(ctx->renderer, 0xC8, 0x1D, 0x13, 0xFF);
+        }
+
+        fill = dst;
+        fill.x += 2;
+        fill.y += 2;
+        fill.h -= 4;
+        fill.w = 25.0f * (ctx->battery_percent / 100.0f);
+        SDL_RenderFillRect(ctx->renderer, &fill);
+        SDL_SetRenderDrawColor(ctx->renderer, r, g, b, a);
+
+        if (ctx->battery_state == SDL_POWERSTATE_ON_BATTERY) {
+            SDL_RenderTexture(ctx->renderer, ctx->battery_texture[0], NULL, &dst);
+        } else {
+            SDL_RenderTexture(ctx->renderer, ctx->battery_texture[1], NULL, &dst);
+        }
     }
 
     if (ctx->display_mode == CONTROLLER_MODE_TESTING && ctx->showing_touchpad) {