Skip to content
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

Open
cdu13a opened this issue Jul 6, 2018 · 10 comments
Open

[Enhancement] show controller battery status on in-game OSD #102

cdu13a opened this issue Jul 6, 2018 · 10 comments

Comments

@cdu13a
Copy link

cdu13a commented Jul 6, 2018

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.

kodi-game-osd

@VelocityRa
Copy link

VelocityRa commented Jul 6, 2018

I don't think gamepad APIs generally offer getting the baterry level.
I quickly checked DirectInput, cocoa, SDL and udev and none of them seem to do so.

So, I'm not sure if this is feasible unfortunately.

@garbear
Copy link
Owner

garbear commented Jul 6, 2018

Are there any APIs out there which expose battery level?

@cdu13a
Copy link
Author

cdu13a commented Jul 6, 2018

It's a battery so It's possible that info would be available from a power management API.

@VelocityRa
Copy link

VelocityRa commented Jul 6, 2018

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.

@VelocityRa
Copy link

VelocityRa commented Jul 6, 2018

I found this config option for Linux: https://cateee.net/lkddb/web-lkddb/HID_BATTERY_STRENGTH.html
upower makes use of it, so maybe test it to see if shows battery levels of a connected controller.

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
Also it looks like it's UWP only, which would suck.

@garbear
Copy link
Owner

garbear commented Jul 7, 2018

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.

@VelocityRa
Copy link

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.

@cdu13a
Copy link
Author

cdu13a commented Jul 9, 2018

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.

@VelocityRa
Copy link

VelocityRa commented Jul 9, 2018

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).

I've done a bit more looking at where the battery level info can come from and xinput on windows has

Looks promising, maybe make a test program first and test some controllers?

@garbear
Copy link
Owner

garbear commented Jul 10, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants