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

Battery Notification #314

Closed
avarisclari opened this issue Apr 22, 2014 · 25 comments
Closed

Battery Notification #314

avarisclari opened this issue Apr 22, 2014 · 25 comments
Assignees
Milestone

Comments

@avarisclari
Copy link

Is there any form of battery monitor built in? If not, how much work would it be to add such a feature. I know it's not a major feature, but still nice to be able to say in an application "Your battery is low, please save and quit, or find the nearest power source."

@amagnoni
Copy link

android automatic notify drawing over a confirmation window!

@avarisclari
Copy link
Author

Is the feature available on PC's (laptops)

@reduz
Copy link
Member

reduz commented Apr 22, 2014

this API is probably available everywhere, I think SDL has it:
https://wiki.libsdl.org/SDL_GetPowerInfo
so if if anyone wants to port this code to Godot be welcome.
Could be functions added to OS

@akien-mga akien-mga added this to the Later milestone Oct 29, 2015
@akien-mga akien-mga removed this from the Later milestone Jan 5, 2016
@StraToN
Copy link
Member

StraToN commented Apr 29, 2016

WINDOWS AND OSX TESTERS NEEDED PLEASE ! SEE LIST BELOW.
This feature is currently in development on this fork branch : https://github.com/StraToN/godot/tree/314-battery-notification
Current status:

  • X11 : done, tested on GNU/Linux *but needs tests on BSD
  • OSX : done, not tested
  • IOS (iphone) : not done, WIP
  • Windows : done, not tested
  • WinRT : not done, will have to wait for experienced WinRT dev...
  • Android : partially done, the platform-specific code is ready but I don't know where to put it, so it's commented out atm (https://github.com/StraToN/godot/blob/314-battery-notification/platform/android/power_android.cpp#L38)
  • bb10 : not done
  • Haiku : not done
  • isim : not done
  • javascript : not done (is that a platform?? :s )
  • server : not done (is that a platform?? what is the difference between this and X11??)

@Calinou
Copy link
Member

Calinou commented Apr 29, 2016

server : not done (is that a platform?? what is the difference between this and X11??)

Technically, yes. server is designed for running on headless GNU/Linux (and BSD) operating systems, without requiring any X11 dependency. It can also be faster in many cases. That makes it suitable for dedicated game servers, running scripts like asset conversion…

@punto-
Copy link
Contributor

punto- commented Apr 29, 2016

"javascript" is html5, I don't know if there's apis to expose the battery
status to a website

On 29 April 2016 at 06:50, Calinou notifications@github.com wrote:

server : not done (is that a platform?? what is the difference between
this and X11??)

Technically, yes. server is designed for running on headless GNU/Linux
(and BSD) operating systems, without requiring any X11 dependency. It can
also be faster in many cases. That makes it suitable for dedicated game
servers, running scripts like asset conversion…


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#314 (comment)

@SuperUserNameMan
Copy link
Contributor

@punto- : there is a new javascript Battery Status Web API, but it is still a W3C Proposed Recommendation. It is mainly available on Firefox and Chrome (on Android and PC)

https://developer.mozilla.org/en-US/docs/Web/API/Battery_Status_API
https://w3c.github.io/battery/

@StraToN
Copy link
Member

StraToN commented Apr 29, 2016

@Calinou OK, so server would actually work the exact same way as X11. I suppose that, of course a server should never run on battery, but hey, people mind their own business ;)

@punto- @SuperUserNameMan I guess we should then simply wait for this one. Keeping it warm.

Oh, also I edited my last post. Tests were not driven for *BSD, I updated the status list.

@vnen
Copy link
Member

vnen commented Apr 29, 2016

I'll test this for Windows.

@vnen
Copy link
Member

vnen commented Apr 29, 2016

@StraToN first, there's an error on line 13 of the SCsub file for Windows. It is now 'power_windows.cpp", when it should be "power_windows.cpp" (without comma at the end).

Even after this fix I can't compile though. Got a bunch of errors:

c:\users\george\workspace\godot\godot-src\platform\windows\os_windows.h(133) : e
rror C2143: syntax error : missing ';' before '*'
c:\users\george\workspace\godot\godot-src\platform\windows\os_windows.h(133) : e
rror C2143: syntax error : missing ';' before '*'
c:\users\george\workspace\godot\godot-src\platform\windows\os_windows.h(133) : e
rror C4430: missing type specifier - int assumed. Note: C++ does not support def
ault-intc:\users\george\workspace\godot\godot-src\platform\windows\os_windows.h(
133) : error C4430: missing type specifier - int assumed. Note: C++ does not sup
port default-int

platform\windows\power_windows.cpp(34) : error C2065: 'SYSTEM_POWER_STATUS' : un
declared identifier
platform\windows\power_windows.cpp(34) : error C2146: syntax error : missing ';'
 before identifier 'status'
platform\windows\power_windows.cpp(34) : error C2065: 'status' : undeclared iden
tifier
platform\windows\power_windows.cpp(35) : error C2065: 'FALSE' : undeclared ident
ifier
platform\windows\power_windows.cpp(38) : error C2065: 'status' : undeclared iden
tifier
scons: *** [platform\windows\godot_win.windows.opt.tools.32.obj] Error 2
platform\windows\power_windows.cpp(38) : error C3861: 'GetSystemPowerStatus': id
entifier not found
platform\windows\power_windows.cpp(42) : error C2065: 'status' : undeclared iden
tifier
platform\windows\power_windows.cpp(42) : error C2228: left of '.BatteryFlag' mus
t have class/struct/union
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\INCLUDE\xlocale(337) : wa
rning C4530: C++ exception handler used, but unwind semantics are not enabled. S
pecify /EHsc
        type is 'unknown-type'
platform\windows\power_windows.cpp(44) : error C2065: 'status' : undeclared iden
tifier
platform\windows\power_windows.cpp(44) : error C2228: left of '.BatteryFlag' mus
t have class/struct/union
        type is 'unknown-type'
platform\windows\power_windows.cpp(45) : error C2100: illegal indirection
platform\windows\power_windows.cpp(46) : error C2065: 'status' : undeclared iden
tifier
platform\windows\power_windows.cpp(46) : error C2228: left of '.BatteryFlag' mus
t have class/struct/union
        type is 'unknown-type'
platform\windows\power_windows.cpp(47) : error C2100: illegal indirection
platform\windows\power_windows.cpp(48) : error C2065: 'TRUE' : undeclared identi
fier
platform\windows\power_windows.cpp(49) : error C2065: 'status' : undeclared iden
tifier
platform\windows\power_windows.cpp(49) : error C2228: left of '.ACLineStatus' mu
st have class/struct/union
        type is 'unknown-type'
platform\windows\power_windows.cpp(50) : error C2100: illegal indirection
platform\windows\power_windows.cpp(51) : error C2065: 'TRUE' : undeclared identi
fier
platform\windows\power_windows.cpp(53) : error C2100: illegal indirection
platform\windows\power_windows.cpp(54) : error C2065: 'TRUE' : undeclared identi
fier
platform\windows\power_windows.cpp(60) : error C2065: 'status' : undeclared iden
tifier
platform\windows\power_windows.cpp(60) : error C2228: left of '.BatteryLifePerce
nt' must have class/struct/union
        type is 'unknown-type'
platform\windows\power_windows.cpp(61) : error C2065: 'status' : undeclared iden
tifier
platform\windows\power_windows.cpp(61) : error C2228: left of '.BatteryLifeTime'
 must have class/struct/union
        type is 'unknown-type'
platform\windows\power_windows.cpp(71) : error C2065: 'TRUE' : undeclared identi
fier
scons: *** [platform\windows\power_windows.windows.opt.tools.32.obj] Error 2
c:\users\george\workspace\godot\godot-src\platform\windows\os_windows.h(133) : e
rror C2143: syntax error : missing ';' before '*'
c:\users\george\workspace\godot\godot-src\platform\windows\os_windows.h(133) : e
rror C4430: missing type specifier - int assumed. Note: C++ does not support def
ault-int
scons: *** [platform\windows\joystick.windows.opt.tools.32.obj] Error 2
platform\windows\os_windows.cpp(989) : error C2065: 'power_manager' : undeclared
 identifier
platform\windows\os_windows.cpp(989) : error C2061: syntax error : identifier 'P
owerWindows'
scons: *** [platform\windows\os_windows.windows.opt.tools.32.obj] Error 2
scons: building terminated because of errors.

@akien-mga
Copy link
Member

Tested on X11, it seems to work fine. Like @StraToN reported, I also get -1 for get_power_seconds_left, I'll see if I have more luck with the SDL API directly and/or if they have a bug report about it.

With the cable plugged in and the battery fully charged, I got POWERSTATE_UNKNOWN instead of POWERSTATE_CHARGED. I'm now charging it fully again to see if I can reproduce it.

Also the enums in the help are sorted alphabetically instead of by value, it would be nice to fix that.

@StraToN
Copy link
Member

StraToN commented Apr 29, 2016

@vnen Thanks a lot for your tests ! There was a missing include (I forgot windows.h). This is corrected now, please pull and try again.

@akien-mga You just need to compile libsdl and run make in src/tests. There lies a test program for power management testing.

@vnen
Copy link
Member

vnen commented Apr 30, 2016

@StraToN still missing the platform/windows/SCsub correction. Other than that it seems to be working perfectly. Unfortunately, my Windows laptop is not showing the remaining battery time (only percentage), so I can't tell if OS.get_power_seconds_left() is working as intended (I'm always getting -1, since the OS is not calculating it).

As a note, it shows the power state as NO_BATTERY on my desktop, which I guess is intended behavior.

@StraToN
Copy link
Member

StraToN commented Apr 30, 2016

@vnen Ah, I see the error now. My eyes were closing yesterday, I didn't see it. I'll correct this ASAP.
edit : done.

Concerning get_power_seconds_left(), I invite you to compile SDL as well as demo programs it features, to see if it succeeds.

Other than that, no PR until most platorms are tested and compile. We can't merge code thats breaks Godot. Looking at OSX users here in particular 😊

@StraToN
Copy link
Member

StraToN commented Jun 15, 2016

ping
Still needing OSX testers.

@vnen
Copy link
Member

vnen commented Jun 15, 2016

@trollworkout uses OSX, I believe.

@reduz
Copy link
Member

reduz commented Jun 15, 2016

ah I have a mac now, i could test..

On Wed, Jun 15, 2016 at 12:16 PM, George Marques notifications@github.com
wrote:

@trollworkout https://github.com/trollworkout uses OSX, I believe.


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#314 (comment),
or mute the thread
https://github.com/notifications/unsubscribe/AF-Z2xZXM33o-tS8kZxIvpFHKnzOIkd4ks5qMBdngaJpZM4B0TAL
.

@ghost
Copy link

ghost commented Jun 15, 2016

I got OSX. I'm looking above see how I can test this.

@akien-mga
Copy link
Member

@StraToN I'd suggest your cleanup your branch (merge some of the commits together, 16 commits is too much for this feature), rebase on top of master HEAD and make a pull request. Right now your work is kind of hidden, and forgotten.

@bojidar-bg
Copy link
Contributor

Was the PR merged in the end?

@ghost
Copy link

ghost commented Oct 18, 2016

I never ended up checking this :D

@vnen
Copy link
Member

vnen commented Oct 18, 2016

@bojidar-bg no, still open: #5871

@wt
Copy link

wt commented May 14, 2017

The last comment on #5871 seems to indicate that it was merged. Maybe this one can be closed?

@akien-mga
Copy link
Member

It still needs to be implemented on various platforms. @StraToN, I leave it up to you to either update this issue with the current implementation status, or maybe close it and open a new one for that, as it might be clearer.

@StraToN
Copy link
Member

StraToN commented May 15, 2017

@akien-mga I'll create a new issue with the current implementation status & what's missing. That's cleaner this way ;)

@akien-mga akien-mga added this to the 3.0 milestone May 15, 2017
@StraToN StraToN mentioned this issue May 15, 2017
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests