summaryrefslogtreecommitdiff
path: root/platform/haiku
diff options
context:
space:
mode:
Diffstat (limited to 'platform/haiku')
-rw-r--r--platform/haiku/os_haiku.cpp2
-rw-r--r--platform/haiku/os_haiku.h6
-rw-r--r--platform/haiku/power_haiku.cpp74
-rw-r--r--platform/haiku/power_haiku.h49
4 files changed, 131 insertions, 0 deletions
diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp
index 9f218aeff4..b9b95ddacd 100644
--- a/platform/haiku/os_haiku.cpp
+++ b/platform/haiku/os_haiku.cpp
@@ -143,6 +143,8 @@ void OS_Haiku::initialize(const VideoMode& p_desired, int p_video_driver, int p_
if (AudioDriverManager::get_driver(p_audio_driver)->init() != OK) {
ERR_PRINT("Initializing audio failed.");
}
+
+ power_manager = memnew( PowerHaiku );
}
void OS_Haiku::finalize() {
diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h
index 531c7a56c3..2c84e95ac3 100644
--- a/platform/haiku/os_haiku.h
+++ b/platform/haiku/os_haiku.h
@@ -40,6 +40,7 @@
#include "context_gl_haiku.h"
#include "haiku_application.h"
#include "haiku_direct_window.h"
+#include "power_haiku.h"
class OS_Haiku : public OS_Unix {
@@ -53,6 +54,7 @@ private:
VideoMode current_video_mode;
PhysicsServer* physics_server;
Physics2DServer* physics_2d_server;
+ PowerHaiku* power_manager;
#ifdef MEDIA_KIT_ENABLED
AudioDriverMediaKit driver_media_kit;
@@ -114,6 +116,10 @@ public:
virtual VideoMode get_video_mode(int p_screen=0) const;
virtual void get_fullscreen_mode_list(List<VideoMode> *p_list, int p_screen=0) const;
virtual String get_executable_path() const;
+
+ virtual PowerState get_power_state();
+ virtual int get_power_seconds_left();
+ virtual int get_power_percent_left();
};
#endif
diff --git a/platform/haiku/power_haiku.cpp b/platform/haiku/power_haiku.cpp
new file mode 100644
index 0000000000..ecedc46500
--- /dev/null
+++ b/platform/haiku/power_haiku.cpp
@@ -0,0 +1,74 @@
+/*************************************************************************/
+/* power_haiku.cpp */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#include "core/error_macros.h"
+
+#include "power_haiku.h"
+
+bool PowerHaiku::UpdatePowerInfo() {
+
+ return false;
+}
+
+PowerState PowerHaiku::get_power_state() {
+ if (UpdatePowerInfo()) {
+ return power_state;
+ }
+ else {
+ WARN_PRINT("Power management is not implemented on this platform, defaulting to POWERSTATE_UNKNOWN");
+ return POWERSTATE_UNKNOWN;
+ }
+}
+
+int PowerX11::get_power_seconds_left() {
+ if (UpdatePowerInfo()) {
+ return nsecs_left;
+ }
+ else {
+ WARN_PRINT("Power management is not implemented on this platform, defaulting to -1");
+ return -1;
+ }
+}
+
+int PowerX11::get_power_percent_left() {
+ if (UpdatePowerInfo()) {
+ return percent_left;
+ }
+ else {
+ WARN_PRINT("Power management is not implemented on this platform, defaulting to -1");
+ return -1;
+ }
+}
+
+PowerHaiku::PowerHaiku() : nsecs_left(-1), percent_left(-1), power_state(POWERSTATE_UNKNOWN) {
+
+}
+
+PowerHaiku::~PowerHaiku() {
+} \ No newline at end of file
diff --git a/platform/haiku/power_haiku.h b/platform/haiku/power_haiku.h
new file mode 100644
index 0000000000..0889e5880c
--- /dev/null
+++ b/platform/haiku/power_haiku.h
@@ -0,0 +1,49 @@
+/*************************************************************************/
+/* power_haiku.h */
+/*************************************************************************/
+/* This file is part of: */
+/* GODOT ENGINE */
+/* http://www.godotengine.org */
+/*************************************************************************/
+/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
+/* */
+/* Permission is hereby granted, free of charge, to any person obtaining */
+/* a copy of this software and associated documentation files (the */
+/* "Software"), to deal in the Software without restriction, including */
+/* without limitation the rights to use, copy, modify, merge, publish, */
+/* distribute, sublicense, and/or sell copies of the Software, and to */
+/* permit persons to whom the Software is furnished to do so, subject to */
+/* the following conditions: */
+/* */
+/* The above copyright notice and this permission notice shall be */
+/* included in all copies or substantial portions of the Software. */
+/* */
+/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
+/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
+/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
+/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
+/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
+/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
+/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
+/*************************************************************************/
+
+#ifndef PLATFORM_HAIKU_POWER_HAIKU_H_
+#define PLATFORM_HAIKU_POWER_HAIKU_H_
+
+class PowerHaiku {
+private:
+ int nsecs_left;
+ int percent_left;
+ PowerState power_state;
+
+ bool UpdatePowerInfo();
+public:
+ PowerHaiku();
+ virtual ~PowerHaiku();
+
+ PowerState get_power_state();
+ int get_power_seconds_left();
+ int get_power_percent_left();
+};
+
+#endif /* PLATFORM_HAIKU_POWER_HAIKU_H_ */ \ No newline at end of file