Battery Charge level support by Haxe Std or Sys?

Since practically all devices except Desktops and Servers are Battery powered I wanted my app to be a “good citizen” by not draining down the Battery. In latest 4.0 rc2 the only Battery API found was for JavaScript ( Haxe_Toolkit_4_0_rc2/haxe/std/js/html/BatteryManager.hx )

Are there plans for a cross Language (and hopefully cross OS) Battery API anytime soon ?
Nice if info about Charging status (Charging or running on Batteries) was part of API.

Not on all platforms “battery” is a thing, so I’m not sure if that’s even doable.

@RMax even if desktops and servers don’t have a battery, both Windows and Linux have plenty of API support for that.

@mark.knol Why would it not be doable? Does something in std have to work everywhere? (maybe I’m missing something :slight_smile:). There are plenty of cases where only certain targets are supported for certain Haxe features.

I think battery is more of a cross-platform thing than many other things :slight_smile:. Don’t several of Haxe targets such as C# and Java already have plenty of power management API? Is there even any OS without such API? Perhaps some variants of *nix, without certain kernel features.

In any case, perhaps a third party lib could handle this. In any case, more and more devices rely on batteries as the world goes more and more mobile.

This should be done in a library.


I am OK with the Battery Charge info and some related Power Management info being in a library.

I think that this is so important that when a library is created it should be supported by the Haxe Foundation just like the various target languages are supported.

I agree creating a library for this would probably be good idea. I wouldn’t wait until the Haxe Foundation will create one. So feel free to roll out your own.