Question Show/read battery level on Raspberry Pi OS from HID game controller

STB

.
Joined
Apr 2, 2022
Messages
9
Likes
28
Location
Germany
Portables
2
Hi !
I'm working on a portable game console using the Raspberry PI zero 2W for the emulation.
The console with all buttons, an IMU doing Trackball/Mouse emulation, Touchscreen, Powerbutton and Battery level is implemented using a STM32 microcontroller as USB HID device.
I'm quite experienced in STM32 programming but not in coding for the Raspberry PI.

Controller emulation, Mouse trackball/touch emulation works, also powering down via the powerbutton is O.K..
The last feature I would like to have is that I can display the battery level on the screen. I created a HID report descriptor that is basically what the xbox one controller is doing:

C:
            0x05, 0x06,                    // USAGE_PAGE (Generic Device Controls Page)
            0x09, 0x20,                    // USAGE (Battery Strength)
            0xa1, 0x01,                    // COLLECTION (Application)
            0x09, 0x20,                    //   USAGE (Battery Strength)
            0x85, 0x05,                    //   REPORT_ID (5)
            0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
            0x25, 0x64,                    //   LOGICAL_MAXIMUM (100)
            0x75, 0x08,                    //   REPORT_SIZE (8)
            0x95, 0x01,                    //   REPORT_COUNT (1)
            0x81, 0x02,                    //   INPUT (Data,Var,Abs)
            0xc0
I using Windows I can see all the HID Devices of my controller emulation.

composit_device.png


Unfortunately I have no experience with Linux.
I'm looking for someone who might have implemeted battery level reporting with an on screen icon on the raspberry PI and can give ma some advice.
I found only very little information in the web.
 
Top