-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Enhancement] show controller battery status on in-game OSD #102
Comments
I don't think gamepad APIs generally offer getting the baterry level. So, I'm not sure if this is feasible unfortunately. |
Are there any APIs out there which expose battery level? |
It's a battery so It's possible that info would be available from a power management API. |
I'd be surprised. This stuff is very controller-specific. If the APIs that interact with controllers don't expose it I'm not sure if anything else would, at least not if you're looking for a generic solution. |
I found this config option for Linux: https://cateee.net/lkddb/web-lkddb/HID_BATTERY_STRENGTH.html Edit: Huh, looks like the driver on linux has support for it for DS4 https://github.com/torvalds/linux/blob/master/drivers/hid/hid-sony.c#L1027-L1056 so maybe the above solution is ok. Don't know for how many controllers it'll work, but it's a start. For Windows I found this UWP API, but I wouldn't be very hopeful: https://docs.microsoft.com/en-us/windows/uwp/devices-sensors/get-battery-info |
So there's some APIs that expose levels. @cdu13a or @VelocityRa would you be willing to add battery level to an API in peripheral.joystick? I can take care of the API changes and all the GUI work. |
There's some APIs that expose levels, but that doesn't mean that most controllers' drivers will implement it. What I found is only confirmed working for DS4, on Linux. I'm right in the middle of exams atm and right after that I'm going on a holiday, will be back at about July 25th. I'll look into it then if noone else will have but if it's Linux-only and not even for every controller I'm not sure if it'd be acceptable. |
Going to look at peripheral.joystick to see if I would be able to make the required changes. My C++ is rather rusty, but I might be able to figure it out. I've done a bit more looking at where the battery level info can come from and xinput on windows has https://docs.microsoft.com/en-us/windows/desktop/api/xinput/nf-xinput-xinputgetbatteryinformation so should be able to do more then just linux. as for some drivers not implementing the reading of any power supply/battery info. I don't think that is our problem. As long as we can get info for some controllers on each platform, i think we are good. |
Yeah, just being practical. If 99% of controllers that people use (like Xbox/DS3/DS4 controllers) aren't supported maybe it wouldn't be as worth doing. There's more dev to it than getting the battery level after all (also maintenance).
Looks promising, maybe make a test program first and test some controllers? |
If XInput supports it that's most PC game controllers on windows. That alone makes it worth it. You should familiarize yourself with the Peripheral API: https://github.com/xbmc/xbmc/blob/master/xbmc/addons/kodi-addon-dev-kit/include/kodi/addon-instance/Peripheral.h. That's were we'll expose battery info to Kodi. A good first step would be adding battery info to that header file. Then it's just a matter of implementing support in the add-on. |
It's frustrating to have a controller die during game play. So it would be nice to be able to show the battery status of controllers on in-game OSD.
The text was updated successfully, but these errors were encountered: