-
-
Notifications
You must be signed in to change notification settings - Fork 21k
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
Power/Battery management #8770
Comments
I'd not call X11 see https://github.com/godotengine/godot/blob/master/platform/x11/power_x11.cpp#L178 |
@Marqin Indeed, there's a big miss here. It's pretty old now, when I attempted to translate SDL code to Godot. I may have started this part and never finished it. But as you pointed it out, testing was obviously insufficient because I was lucky during my tests. |
Some fixes were brought by 411f09a, my tests on X11 pass. I tried to take care of NULL pointer dereferences but I may have missed some. Also it is complicated to test all features as my laptop doesn't support a 'number of seconds remaining on battery' computation, thus it returns -1. However, un/plugging power cable does change the battery status and %. I am currently unable to test this on Android though, as the scene being ran in the export is all grey, I can't explain why. Other platforms need attention too. |
I found it via Static Analyzer :D (I made our Scons generate clang's buils commands .json file and then run clang-tidy on that) |
I tried it on Manjaro and worked fine but it isn't working on Android. I'm using master (9eb4d4a) and I added the |
Would it be possible to print an error message if trying to access battery status without the permission? That said, it'll only be visible if you use remote debugging or |
@alex-evelyn
|
Since this was never finished (despite @StraToN's best intentions :)) and is current either not implemented or not thorough tested on all platforms, I suggest to drop this API in 4.0. We can then consider reimplementing it either for 4.0 or for a later release, taking the time to ensure that most platforms have good support before merging. |
It was initially implemented in godotengine#5871 for Godot 3.0, but never really completed or thoroughly tested for most platforms. It then stayed in limbo and nobody seems really keen to finish it, so it's better to remove it in 4.0, and re-add eventually (possibly with a different API) if there's demand and an implementation confirmed working on all platforms. Closes godotengine#8770.
OS.get_power_state() This was useful on platforms where it worked 😭 |
This issue keeps track of current implementation of battery/power management in Godot.
For reference, #314
The code is ready to welcome implementations for all missing platforms (classes and methods ready but return a warning - not implemented on this platform)
Platforms:
Android : needs testing
The code is directly adaptated from SDL to using Godot API. It probably diserves more attention.
Haiku : not developed
Iphone : not developed
Javascript : not developed
Waiting for more information & specs
https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API
https://w3c.github.io/battery/
OSX : needs testing
Server : partially tested, but shows obvious code flaws
UWP : not developed
This could be of use https://docs.microsoft.com/en-us/windows/uwp/devices-sensors/get-battery-info
Windows : needs testing
X11 : partially tested, but shows obvious code flaws
edit: adding a test project that may be used on every platform.
godot-power-test.zip
The text was updated successfully, but these errors were encountered: