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

Add power battery% access #5871

Closed
wants to merge 2 commits into from

Conversation

StraToN
Copy link
Member

@StraToN StraToN commented Jul 23, 2016

(repost of #5869 which was broken)
Only tested X11 and Windows by @vnen. Sorry I don't have a mac.

JOB IS NOT FINISHED FOR ALL PLATFORMS! DON'T MERGE BEFORE ALL PLATFORMS ARE TESTED !!

NEED TESTERS for iOS, OSX, WinRT and Android (may not compile for these).
Thanks

@vnen
Copy link
Member

vnen commented Jul 23, 2016

BTW, I wouldn't bother (for now) about WinRT. Right now it does not even compile.

@@ -154,6 +155,8 @@ class OS_Android : public OS_Unix {
VideoPauseFunc video_pause_func;
VideoStopFunc video_stop_func;
SetKeepScreenOnFunc set_keep_screen_on_func;

power_android power_manager;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be power_android *power_manager;, right? This is what breaks the build for Android.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's corrected. I just pushed the fix, but I can't affirm android will build, I'm almost certain there are other problems, especially in platform/android/power_android.cpp's method int Android_JNI_GetPowerInfo(int* plugged, int* charged, int* battery, int* seconds, int* percent)

@StraToN StraToN force-pushed the godot-power-battery branch 3 times, most recently from 663b2e4 to 7944b97 Compare July 24, 2016 09:03
@akien-mga
Copy link
Member

It fails building on OSX and Android: https://travis-ci.org/godotengine/godot/builds/146963962

@StraToN
Copy link
Member Author

StraToN commented Jul 25, 2016

@akien-mga Yes, I don't have a Mac to test, nor I have an Android environment.

@akien-mga
Copy link
Member

Yes but you can check the build logs and see what are the issues :)

For Android you'd likely have to setup a build environment to test properly though, as there seem to be various issues: https://travis-ci.org/godotengine/godot/jobs/146963965
For OSX it looks like you just forgot to translate a SDL2 type to Dictionary: https://travis-ci.org/godotengine/godot/jobs/146963967

@itsraineing
Copy link
Contributor

Adding #include <CoreFoundation/CoreFoundation.h> to platform/osx/power_osx.h and '-framework', 'IOKit' to the LDFLAGS in platform/osx/detect.py gets it to compile and work fine on OS X. I haven't tested iOS, but it seems to compile.

@StraToN
Copy link
Member Author

StraToN commented Jul 26, 2016

@vnen I think it's possible to implement WinRT pretty easily using the Battery class documented here http://msdn.microsoft.com/library/windowsphone/develop/jj207231, according to SDL comment left in platform/winrt/power_winrt.cpp:41. I didn't take the time to do it as I couldn't test it anyway, however it seems we only need to return the values obtained with Battery::GetDefault().RemainingChargePercent and Battery::GetDefault().RemainingDischargeTime.

@GungnirInd Thanks a lot, it worked :)
Now testing is needed for OSX and iOS, for people insterested, thanks in advance!

@vnen
Copy link
Member

vnen commented Aug 13, 2016

I need to test this for Android. It'd be nice to merge this before 2.2. Since now I'm fixing the WinRT port, it can be added too for such platform.

@StraToN
Copy link
Member Author

StraToN commented Aug 14, 2016

@vnen I'll try to get it to compile with Android now, even though I am not an Android developer. I suppose some includes are missing.

@StraToN StraToN closed this Aug 14, 2016
@StraToN StraToN reopened this Aug 14, 2016
@reduz
Copy link
Member

reduz commented Sep 10, 2016

What's the status of this one?

@StraToN
Copy link
Member Author

StraToN commented Sep 10, 2016

@reduz Still missing Android development by converting SDL code to Godot. I am not competent on this one yet 😕

@reduz
Copy link
Member

reduz commented Sep 10, 2016

you can ask @RandomShaper for help I guess

@akien-mga
Copy link
Member

@StraToN The PR has conflicts, could you have a look at rebasing?

@StraToN
Copy link
Member Author

StraToN commented Oct 1, 2016

@akien-mga Will do ASAP.

@StraToN
Copy link
Member Author

StraToN commented Oct 5, 2016

Rebased.
Thanks again to @akien-mga for the (now usual) help :)

@akien-mga
Copy link
Member

Looking at the commit history, there's still something fishy though.. :/

@StraToN
Copy link
Member Author

StraToN commented Oct 6, 2016

Indeed, looks like I left 2 useless commits . Will correct it tonight

@vnen vnen mentioned this pull request Oct 18, 2016
@StraToN StraToN force-pushed the godot-power-battery branch 2 times, most recently from 49a9ef6 to 9232bb7 Compare October 22, 2016 16:02
@StraToN
Copy link
Member Author

StraToN commented Oct 22, 2016

@akien-mga Corrected. Do you validate? :)

@akien-mga
Copy link
Member

Looks good commit-wise from a quick glance :)

@@ -0,0 +1,78 @@
/*************************************************************************/
/* power_winrt.h */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot to change the file name here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected. Thanks !

@akien-mga
Copy link
Member

@StraToN You have some rebase work ahead :)

Done:
- X11, server (tested)
- Windows (developed, would be nice to retest)
- OSX (not tested)
Prepared (not developed):
- Android (code is here, but may not compile)
- iphone
- winrt
- bb10
- haiku
- javascript
@StraToN
Copy link
Member Author

StraToN commented Jan 19, 2017

@akien-mga Done ;)

Ping @vnen for winrt and Mux213 on IRC for osx

@akien-mga akien-mga added this to the 3.0 milestone Jan 19, 2017
int percent_left;
PowerState power_state;
void checkps(CFDictionaryRef dict, bool * have_ac, bool * have_battery, bool * charging);
bool GetPowerInfo_MacOSX(/*PowerState * state, int *seconds, int *percent*/);
Copy link
Member Author

@StraToN StraToN Jan 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should kick this comment with parameters out.

@akien-mga
Copy link
Member

Merged manually in 94103c0.

Please open a new issue to keep track of the state of this feature on all platforms (implemented/working) so that we make sure it's all good for 3.0.

@akien-mga akien-mga closed this Mar 4, 2017
@StraToN StraToN deleted the godot-power-battery branch July 26, 2017 11:20
akien-mga added a commit to akien-mga/godot that referenced this pull request Feb 14, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants