aboutsummaryrefslogtreecommitdiff
path: root/core/bind
diff options
context:
space:
mode:
authorJulian Murgia2016-07-23 13:15:55 +0200
committerRémi Verschelde2017-03-04 18:04:29 +0100
commit94103c0c025f04e75d5e163d9f0bdde27bb0c848 (patch)
treed5bb55acd30270cace54dae5537b009887de1e68 /core/bind
parentef174abf6d640e69c402b5e9628743173c313439 (diff)
downloadgodot-94103c0c025f04e75d5e163d9f0bdde27bb0c848.tar.gz
godot-94103c0c025f04e75d5e163d9f0bdde27bb0c848.tar.zst
godot-94103c0c025f04e75d5e163d9f0bdde27bb0c848.zip
Add API to access battery power state
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
Diffstat (limited to 'core/bind')
-rw-r--r--core/bind/core_bind.cpp21
-rw-r--r--core/bind/core_bind.h5
2 files changed, 26 insertions, 0 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 79cfae0a3..e4348cc40 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -450,6 +450,17 @@ bool _OS::is_vsync_enabled() const {
return OS::get_singleton()->is_vsync_enabled();
}
+PowerState _OS::get_power_state() {
+ return OS::get_singleton()->get_power_state();
+}
+
+int _OS::get_power_seconds_left() {
+ return OS::get_singleton()->get_power_seconds_left();
+}
+
+int _OS::get_power_percent_left() {
+ return OS::get_singleton()->get_power_percent_left();
+}
/*
enum Weekday {
@@ -1113,6 +1124,10 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_use_vsync","enable"),&_OS::set_use_vsync);
ClassDB::bind_method(D_METHOD("is_vsync_enabled"),&_OS::is_vsync_enabled);
+ ClassDB::bind_method(D_METHOD("get_power_state"),&_OS::get_power_state);
+ ClassDB::bind_method(D_METHOD("get_power_seconds_left"),&_OS::get_power_seconds_left);
+ ClassDB::bind_method(D_METHOD("get_power_percent_left"),&_OS::get_power_percent_left);
+
BIND_CONSTANT( DAY_SUNDAY );
BIND_CONSTANT( DAY_MONDAY );
BIND_CONSTANT( DAY_TUESDAY );
@@ -1150,6 +1165,12 @@ void _OS::_bind_methods() {
BIND_CONSTANT( SYSTEM_DIR_MUSIC );
BIND_CONSTANT( SYSTEM_DIR_PICTURES );
BIND_CONSTANT( SYSTEM_DIR_RINGTONES );
+
+ BIND_CONSTANT( POWERSTATE_UNKNOWN );
+ BIND_CONSTANT( POWERSTATE_ON_BATTERY );
+ BIND_CONSTANT( POWERSTATE_NO_BATTERY );
+ BIND_CONSTANT( POWERSTATE_CHARGING );
+ BIND_CONSTANT( POWERSTATE_CHARGED );
}
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 4241912dd..b6aa87376 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -35,6 +35,7 @@
#include "os/dir_access.h"
#include "os/thread.h"
#include "os/semaphore.h"
+#include "os/power.h"
class _ResourceLoader : public Object {
@@ -308,6 +309,10 @@ public:
void set_use_vsync(bool p_enable);
bool is_vsync_enabled() const;
+ PowerState get_power_state();
+ int get_power_seconds_left();
+ int get_power_percent_left();
+
static _OS *get_singleton() { return singleton; }
_OS();