feat: battery indicator and rumble test button

Plumb controller battery type/level from the GIP status packets
through the C API into the card header (SF Symbol battery icon).
Add a per-controller Rumble button wired to a new
xone_controller_rumble() entry point; it validates its arguments
and returns -ENOSYS until host to controller TX is implemented.

Co-Authored-By: qwen3.8-27b@q3_k_xl: battery + rumble button UI
This commit is contained in:
portersky
2026-08-29 15:13:18 +02:00
parent 8d6672f43d
commit 416507ed53
7 changed files with 80 additions and 4 deletions
+10 -1
View File
@@ -74,7 +74,8 @@ int xone_controller_mac(xone_dongle const *d, int index, char *buf, int len);
// Snapshot of the latest standard Xbox controller input report. Stick values
// are signed 16-bit values; trigger values are unsigned 10-bit values. The
// buttons field uses the standard GIP gamepad bit assignments.
// buttons field uses the standard GIP gamepad bit assignments. Battery fields
// come from periodic GIP status packets (battery_type is 0 when unknown).
struct xone_controller_state {
uint16_t buttons;
bool guide_down;
@@ -87,6 +88,8 @@ struct xone_controller_state {
int16_t stick_right_x;
int16_t stick_right_y;
uint32_t sequence;
uint8_t battery_type;
uint8_t battery_level;
};
// Copy the latest input state for the controller at index. Returns 0 on
@@ -97,6 +100,12 @@ int xone_controller_get_state(xone_dongle const *d, int index,
// Enter or leave pairing mode (beacon pairing flag + LED blink).
void xone_set_pairing(xone_dongle *d, bool enable);
// Trigger a rumble test on the controller at index. Returns 0 on success,
// -1 for an invalid session or index. Not implemented yet: host to
// controller TX (GIP_CMD_RUMBLE payload) is pending, so this currently
// returns -ENOSYS.
int xone_controller_rumble(xone_dongle *d, int index);
#ifdef __cplusplus
}
#endif