SDL icon indicating copy to clipboard operation
SDL copied to clipboard

SDL_GetPowerInfo() reports wireless mouse's battery info

Open taep96 opened this issue 3 years ago • 1 comments

Osu!Lazer uses SDL_GetPowerInfo() to get battery percentage and show a warning if it's too low - https://github.com/ppy/osu/discussions/21640:

image

I'm running a battery-less PC, so this warning is incorrect. The only battery-powered device connected to my PC is a wireless mouse I checked if it's battery percentage affects it, and it does! I charged it and the warnings were gone, and when it discharged to 25% they appeared again.

image

I'm not familiar with SDL so I'm not sure about how this should be fixed, looks like SDL_GetPowerInfo() assumes system has only one power supply, so I guess this should be changed.

taep96 avatar Dec 17 '22 22:12 taep96

That's pretty funny! I'll take a look at this.

icculus avatar Dec 17 '22 22:12 icculus

I pushed a possible fix for this (we were looking for the string "device" but your screenshot has it capitalized as "Device").

If that doesn't resolve the issue, I have a more aggressive patch that rejects any power devices with identifiers that start with "hidpp_" (which is logitech's HID communication protocol). We might need this if it turns out you're using our D-Bus codepath and the existing checks didn't fix it there.

icculus avatar May 18 '23 17:05 icculus

@bdach In case your weren't subscribed

taep96 avatar May 18 '23 17:05 taep96

@icculus, are you merging fixes from SDL2 to main?

slouken avatar May 18 '23 18:05 slouken

I'm waiting to see if this is sufficient before I merge this one.

icculus avatar May 18 '23 18:05 icculus

Maintainer of upstream project where this came up here - I'm not entirely sure why I was tagged in here by @taep96 or what action is expected of me, but if it helps I'll ask to bump SDL on our side so that it can be verified that the fix fixes once we push out our next release. We build the SDL binaries we ship from source anyways, so no need to get any minor release out or anything.

bdach avatar May 20 '23 17:05 bdach

Maintainer of upstream project where this came up here - I'm not entirely sure why I was tagged in here by @taep96 or what action is expected of me, but if it helps I'll ask to bump SDL on our side so that it can be verified that the fix fixes once we push out our next release. We build the SDL binaries we ship from source anyways, so no need to get any minor release out or anything.

That would be super helpful, thank you!

icculus avatar May 21 '23 02:05 icculus

@taep96 Do you have what you need to retest this, now?

icculus avatar May 24 '23 19:05 icculus

I don't think it's released in osu yet and I'm not sure how to test it manually

taep96 avatar May 24 '23 19:05 taep96

We haven't pushed out a new user-facing release of our project yet, for whatever's worth, but the change has trickled down to our current master. If @taep96 is able to build and test that, then that should do the trick.

Otherwise probably need a while longer for us to put out a public release. Shouldn't be overly long, we aim for a release every few weeks at worst, but I don't have a concrete timeline to give right now.

bdach avatar May 24 '23 19:05 bdach

I was able to build and run it but will have to wait for my mouse to discharge to test it

taep96 avatar May 24 '23 19:05 taep96

If it doesn't fix the issue, don't charge the mouse, I have a second patch ready to go. :)

icculus avatar May 24 '23 21:05 icculus

Not getting it on 2023.524.0 (May 24th release) so I guess it's fixed?

taep96 avatar May 28 '23 20:05 taep96

I'm willing to call that Good Enough. :)

icculus avatar May 29 '23 01:05 icculus

Cherry-picked to SDL3, too, in 95f244598bb17455dc7651b0f588965e5c351086.

icculus avatar May 29 '23 01:05 icculus