summaryrefslogtreecommitdiff
path: root/core/os
diff options
context:
space:
mode:
Diffstat (limited to 'core/os')
-rw-r--r--core/os/SCsub2
-rw-r--r--core/os/copymem.h2
-rw-r--r--core/os/dir_access.cpp10
-rw-r--r--core/os/dir_access.h6
-rw-r--r--core/os/file_access.cpp6
-rw-r--r--core/os/file_access.h9
-rw-r--r--core/os/input.cpp8
-rw-r--r--core/os/input.h6
-rw-r--r--core/os/input_event.cpp20
-rw-r--r--core/os/input_event.h13
-rw-r--r--core/os/keyboard.cpp3
-rw-r--r--core/os/keyboard.h7
-rw-r--r--core/os/main_loop.cpp7
-rw-r--r--core/os/main_loop.h8
-rw-r--r--core/os/memory.cpp6
-rw-r--r--core/os/memory.h3
-rw-r--r--core/os/midi_driver.cpp2
-rw-r--r--core/os/midi_driver.h3
-rw-r--r--core/os/mutex.cpp4
-rw-r--r--core/os/mutex.h2
-rw-r--r--core/os/os.cpp19
-rw-r--r--core/os/os.h19
-rw-r--r--core/os/rw_lock.cpp2
-rw-r--r--core/os/rw_lock.h2
-rw-r--r--core/os/semaphore.cpp3
-rw-r--r--core/os/semaphore.h3
-rw-r--r--core/os/shell.h4
-rw-r--r--core/os/thread.h6
-rw-r--r--core/os/thread_dummy.cpp2
-rw-r--r--core/os/thread_dummy.h8
-rw-r--r--core/os/thread_safe.cpp5
-rw-r--r--core/os/thread_safe.h2
-rw-r--r--core/os/threaded_array_processor.h10
33 files changed, 124 insertions, 88 deletions
diff --git a/core/os/SCsub b/core/os/SCsub
index 4efc902717..1c5f954470 100644
--- a/core/os/SCsub
+++ b/core/os/SCsub
@@ -3,5 +3,3 @@
Import('env')
env.add_source_files(env.core_sources, "*.cpp")
-
-Export('env')
diff --git a/core/os/copymem.h b/core/os/copymem.h
index 87d77bd426..999c770e85 100644
--- a/core/os/copymem.h
+++ b/core/os/copymem.h
@@ -31,7 +31,7 @@
#ifndef COPYMEM_H
#define COPYMEM_H
-#include "typedefs.h"
+#include "core/typedefs.h"
#ifdef PLATFORM_COPYMEM
diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp
index e631d6e994..daa3eacd5f 100644
--- a/core/os/dir_access.cpp
+++ b/core/os/dir_access.cpp
@@ -29,10 +29,11 @@
/*************************************************************************/
#include "dir_access.h"
-#include "os/file_access.h"
-#include "os/memory.h"
-#include "os/os.h"
-#include "project_settings.h"
+
+#include "core/os/file_access.h"
+#include "core/os/memory.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
String DirAccess::_get_root_path() const {
@@ -226,6 +227,7 @@ String DirAccess::fix_path(String p_path) const {
return p_path;
} break;
+ case ACCESS_MAX: break; // Can't happen, but silences warning
}
return p_path;
diff --git a/core/os/dir_access.h b/core/os/dir_access.h
index 4df0618021..773f0bcd41 100644
--- a/core/os/dir_access.h
+++ b/core/os/dir_access.h
@@ -31,14 +31,14 @@
#ifndef DIR_ACCESS_H
#define DIR_ACCESS_H
-#include "typedefs.h"
-#include "ustring.h"
+#include "core/typedefs.h"
+#include "core/ustring.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-//@ TOOD, excellent candidate for THREAD_SAFE MACRO, should go through all these and add THREAD_SAFE where it applies
+//@ TODO, excellent candidate for THREAD_SAFE MACRO, should go through all these and add THREAD_SAFE where it applies
class DirAccess {
public:
enum AccessType {
diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp
index 59f07c03e7..e09e5e16ad 100644
--- a/core/os/file_access.cpp
+++ b/core/os/file_access.cpp
@@ -32,8 +32,8 @@
#include "core/io/file_access_pack.h"
#include "core/io/marshalls.h"
-#include "os/os.h"
-#include "project_settings.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
#include "thirdparty/misc/md5.h"
#include "thirdparty/misc/sha256.h"
@@ -46,7 +46,6 @@ bool FileAccess::backup_save = false;
FileAccess *FileAccess::create(AccessType p_access) {
- ERR_FAIL_COND_V(!create_func, 0);
ERR_FAIL_INDEX_V(p_access, ACCESS_MAX, 0);
FileAccess *ret = create_func[p_access]();
@@ -166,6 +165,7 @@ String FileAccess::fix_path(const String &p_path) const {
return r_path;
} break;
+ case ACCESS_MAX: break; // Can't happen, but silences warning
}
return r_path;
diff --git a/core/os/file_access.h b/core/os/file_access.h
index c4635fdfbb..b7d93e9f5d 100644
--- a/core/os/file_access.h
+++ b/core/os/file_access.h
@@ -31,10 +31,11 @@
#ifndef FILE_ACCESS_H
#define FILE_ACCESS_H
-#include "math_defs.h"
-#include "os/memory.h"
-#include "typedefs.h"
-#include "ustring.h"
+#include "core/math/math_defs.h"
+#include "core/os/memory.h"
+#include "core/typedefs.h"
+#include "core/ustring.h"
+
/**
* Multi-Platform abstraction for accessing to files.
*/
diff --git a/core/os/input.cpp b/core/os/input.cpp
index a5b0f91e63..6830df7e81 100644
--- a/core/os/input.cpp
+++ b/core/os/input.cpp
@@ -29,9 +29,11 @@
/*************************************************************************/
#include "input.h"
-#include "input_map.h"
-#include "os/os.h"
-#include "project_settings.h"
+
+#include "core/input_map.h"
+#include "core/os/os.h"
+#include "core/project_settings.h"
+
Input *Input::singleton = NULL;
Input *Input::get_singleton() {
diff --git a/core/os/input.h b/core/os/input.h
index 001871c5dc..db523d6789 100644
--- a/core/os/input.h
+++ b/core/os/input.h
@@ -31,9 +31,9 @@
#ifndef INPUT_H
#define INPUT_H
-#include "object.h"
-#include "os/main_loop.h"
-#include "os/thread_safe.h"
+#include "core/object.h"
+#include "core/os/main_loop.h"
+#include "core/os/thread_safe.h"
class Input : public Object {
diff --git a/core/os/input_event.cpp b/core/os/input_event.cpp
index 12c6ef7d3b..5bbdd7efb2 100644
--- a/core/os/input_event.cpp
+++ b/core/os/input_event.cpp
@@ -30,8 +30,8 @@
#include "input_event.h"
-#include "input_map.h"
-#include "os/keyboard.h"
+#include "core/input_map.h"
+#include "core/os/keyboard.h"
void InputEvent::set_device(int p_device) {
device = p_device;
@@ -962,6 +962,22 @@ bool InputEventAction::is_action(const StringName &p_action) const {
return action == p_action;
}
+bool InputEventAction::action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const {
+
+ Ref<InputEventAction> act = p_event;
+ if (act.is_null())
+ return false;
+
+ bool match = action == act->action;
+ if (match) {
+ if (p_pressed != NULL)
+ *p_pressed = act->pressed;
+ if (p_strength != NULL)
+ *p_strength = (*p_pressed) ? 1.0f : 0.0f;
+ }
+ return match;
+}
+
String InputEventAction::as_text() const {
return "InputEventAction : action=" + action + ", pressed=(" + (pressed ? "true" : "false");
diff --git a/core/os/input_event.h b/core/os/input_event.h
index 8732c7e377..789d19c5b2 100644
--- a/core/os/input_event.h
+++ b/core/os/input_event.h
@@ -31,11 +31,12 @@
#ifndef INPUT_EVENT_H
#define INPUT_EVENT_H
-#include "os/copymem.h"
-#include "resource.h"
-#include "transform_2d.h"
-#include "typedefs.h"
-#include "ustring.h"
+#include "core/math/transform_2d.h"
+#include "core/os/copymem.h"
+#include "core/resource.h"
+#include "core/typedefs.h"
+#include "core/ustring.h"
+
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
@@ -480,6 +481,8 @@ public:
virtual bool is_action(const StringName &p_action) const;
+ virtual bool action_match(const Ref<InputEvent> &p_event, bool *p_pressed, float *p_strength, float p_deadzone) const;
+
virtual bool shortcut_match(const Ref<InputEvent> &p_event) const;
virtual bool is_action_type() const { return true; }
virtual String as_text() const;
diff --git a/core/os/keyboard.cpp b/core/os/keyboard.cpp
index 9dfc91e308..abc579c58d 100644
--- a/core/os/keyboard.cpp
+++ b/core/os/keyboard.cpp
@@ -29,7 +29,8 @@
/*************************************************************************/
#include "keyboard.h"
-#include "os/os.h"
+
+#include "core/os/os.h"
struct _KeyCodeText {
int code;
diff --git a/core/os/keyboard.h b/core/os/keyboard.h
index a0e6f8b2ef..17bf5eaa48 100644
--- a/core/os/keyboard.h
+++ b/core/os/keyboard.h
@@ -31,13 +31,10 @@
#ifndef KEYBOARD_H
#define KEYBOARD_H
-#include "ustring.h"
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
+#include "core/ustring.h"
/**
-@author Juan Linietsky <reduzio@gmail.com>
+ @author Juan Linietsky <reduzio@gmail.com>
*/
/*
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index c51801e3e2..0945cdd512 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -29,18 +29,19 @@
/*************************************************************************/
#include "main_loop.h"
-#include "script_language.h"
+
+#include "core/script_language.h"
void MainLoop::_bind_methods() {
- ClassDB::bind_method(D_METHOD("input_event", "ev"), &MainLoop::input_event);
+ ClassDB::bind_method(D_METHOD("input_event", "event"), &MainLoop::input_event);
ClassDB::bind_method(D_METHOD("input_text", "text"), &MainLoop::input_text);
ClassDB::bind_method(D_METHOD("init"), &MainLoop::init);
ClassDB::bind_method(D_METHOD("iteration", "delta"), &MainLoop::iteration);
ClassDB::bind_method(D_METHOD("idle", "delta"), &MainLoop::idle);
ClassDB::bind_method(D_METHOD("finish"), &MainLoop::finish);
- BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "ev", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
+ BIND_VMETHOD(MethodInfo("_input_event", PropertyInfo(Variant::OBJECT, "event", PROPERTY_HINT_RESOURCE_TYPE, "InputEvent")));
BIND_VMETHOD(MethodInfo("_input_text", PropertyInfo(Variant::STRING, "text")));
BIND_VMETHOD(MethodInfo("_initialize"));
BIND_VMETHOD(MethodInfo("_iteration", PropertyInfo(Variant::REAL, "delta")));
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index f96e46141e..43f74302a8 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -31,12 +31,14 @@
#ifndef MAIN_LOOP_H
#define MAIN_LOOP_H
-#include "os/input_event.h"
-#include "reference.h"
-#include "script_language.h"
+#include "core/os/input_event.h"
+#include "core/reference.h"
+#include "core/script_language.h"
+
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
+
class MainLoop : public Object {
GDCLASS(MainLoop, Object);
diff --git a/core/os/memory.cpp b/core/os/memory.cpp
index 3eab4343a9..041371a6e2 100644
--- a/core/os/memory.cpp
+++ b/core/os/memory.cpp
@@ -29,9 +29,11 @@
/*************************************************************************/
#include "memory.h"
-#include "copymem.h"
+
+#include "core/error_macros.h"
+#include "core/os/copymem.h"
#include "core/safe_refcount.h"
-#include "error_macros.h"
+
#include <stdio.h>
#include <stdlib.h>
diff --git a/core/os/memory.h b/core/os/memory.h
index f5c6c0b38a..3501c3f14e 100644
--- a/core/os/memory.h
+++ b/core/os/memory.h
@@ -31,7 +31,8 @@
#ifndef MEMORY_H
#define MEMORY_H
-#include "safe_refcount.h"
+#include "core/safe_refcount.h"
+
#include <stddef.h>
/**
diff --git a/core/os/midi_driver.cpp b/core/os/midi_driver.cpp
index 7b4f84473c..2b20a708ed 100644
--- a/core/os/midi_driver.cpp
+++ b/core/os/midi_driver.cpp
@@ -30,8 +30,8 @@
#include "midi_driver.h"
+#include "core/os/os.h"
#include "main/input_default.h"
-#include "os/os.h"
MIDIDriver *MIDIDriver::singleton = NULL;
MIDIDriver *MIDIDriver::get_singleton() {
diff --git a/core/os/midi_driver.h b/core/os/midi_driver.h
index 1a3a67a411..ceb4e71d66 100644
--- a/core/os/midi_driver.h
+++ b/core/os/midi_driver.h
@@ -31,8 +31,9 @@
#ifndef MIDI_DRIVER_H
#define MIDI_DRIVER_H
+#include "core/typedefs.h"
#include "core/variant.h"
-#include "typedefs.h"
+
/**
* Multi-Platform abstraction for accessing to MIDI.
*/
diff --git a/core/os/mutex.cpp b/core/os/mutex.cpp
index 7c4ea2323c..0c01b06bd6 100644
--- a/core/os/mutex.cpp
+++ b/core/os/mutex.cpp
@@ -29,7 +29,9 @@
/*************************************************************************/
#include "mutex.h"
-#include "error_macros.h"
+
+#include "core/error_macros.h"
+
#include <stddef.h>
Mutex *(*Mutex::create_func)(bool) = 0;
diff --git a/core/os/mutex.h b/core/os/mutex.h
index 9debe7f41b..788cc00397 100644
--- a/core/os/mutex.h
+++ b/core/os/mutex.h
@@ -31,7 +31,7 @@
#ifndef MUTEX_H
#define MUTEX_H
-#include "error_list.h"
+#include "core/error_list.h"
/**
* @class Mutex
diff --git a/core/os/os.cpp b/core/os/os.cpp
index e90d714450..7547b6a042 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -30,13 +30,13 @@
#include "os.h"
-#include "dir_access.h"
-#include "input.h"
-#include "os/file_access.h"
-#include "os/midi_driver.h"
-#include "project_settings.h"
+#include "core/os/dir_access.h"
+#include "core/os/file_access.h"
+#include "core/os/input.h"
+#include "core/os/midi_driver.h"
+#include "core/project_settings.h"
+#include "core/version_generated.gen.h"
#include "servers/audio_server.h"
-#include "version_generated.gen.h"
#include <stdarg.h>
@@ -632,10 +632,13 @@ void OS::center_window() {
if (is_window_fullscreen()) return;
+ Point2 sp = get_screen_position(get_current_screen());
Size2 scr = get_screen_size(get_current_screen());
Size2 wnd = get_real_window_size();
- int x = scr.width / 2 - wnd.width / 2;
- int y = scr.height / 2 - wnd.height / 2;
+
+ int x = sp.width + (scr.width - wnd.width) / 2;
+ int y = sp.height + (scr.height - wnd.height) / 2;
+
set_window_position(Vector2(x, y));
}
diff --git a/core/os/os.h b/core/os/os.h
index 6f9a72d451..7786ffb26e 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -31,13 +31,14 @@
#ifndef OS_H
#define OS_H
-#include "engine.h"
-#include "image.h"
-#include "io/logger.h"
-#include "list.h"
-#include "os/main_loop.h"
-#include "ustring.h"
-#include "vector.h"
+#include "core/engine.h"
+#include "core/image.h"
+#include "core/io/logger.h"
+#include "core/list.h"
+#include "core/os/main_loop.h"
+#include "core/ustring.h"
+#include "core/vector.h"
+
#include <stdarg.h>
/**
@@ -128,7 +129,7 @@ protected:
RenderThreadMode _render_thread_mode;
- // functions used by main to initialize/deintialize the OS
+ // functions used by main to initialize/deinitialize the OS
void add_logger(Logger *p_logger);
virtual void initialize_core() = 0;
@@ -256,7 +257,7 @@ public:
virtual String get_executable_path() const;
virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0;
- virtual Error kill(const ProcessID &p_pid, const int p_max_wait_msec = -1) = 0;
+ virtual Error kill(const ProcessID &p_pid) = 0;
virtual int get_process_id() const;
virtual Error shell_open(String p_uri);
diff --git a/core/os/rw_lock.cpp b/core/os/rw_lock.cpp
index 35489490ed..5e51a1dbce 100644
--- a/core/os/rw_lock.cpp
+++ b/core/os/rw_lock.cpp
@@ -30,7 +30,7 @@
#include "rw_lock.h"
-#include "error_macros.h"
+#include "core/error_macros.h"
#include <stddef.h>
diff --git a/core/os/rw_lock.h b/core/os/rw_lock.h
index 3e53300c9f..8d1029723b 100644
--- a/core/os/rw_lock.h
+++ b/core/os/rw_lock.h
@@ -31,7 +31,7 @@
#ifndef RWLOCK_H
#define RWLOCK_H
-#include "error_list.h"
+#include "core/error_list.h"
class RWLock {
protected:
diff --git a/core/os/semaphore.cpp b/core/os/semaphore.cpp
index 0377aeeb29..448d17dd14 100644
--- a/core/os/semaphore.cpp
+++ b/core/os/semaphore.cpp
@@ -29,7 +29,8 @@
/*************************************************************************/
#include "semaphore.h"
-#include "error_macros.h"
+
+#include "core/error_macros.h"
Semaphore *(*Semaphore::create_func)() = 0;
diff --git a/core/os/semaphore.h b/core/os/semaphore.h
index f3021bf74c..6cec06ea28 100644
--- a/core/os/semaphore.h
+++ b/core/os/semaphore.h
@@ -31,11 +31,12 @@
#ifndef SEMAPHORE_H
#define SEMAPHORE_H
-#include "error_list.h"
+#include "core/error_list.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
+
class Semaphore {
protected:
static Semaphore *(*create_func)();
diff --git a/core/os/shell.h b/core/os/shell.h
index d3d92028ea..146c35cbc8 100644
--- a/core/os/shell.h
+++ b/core/os/shell.h
@@ -31,8 +31,8 @@
#ifndef SHELL_H
#define SHELL_H
-#include "typedefs.h"
-#include "ustring.h"
+#include "core/typedefs.h"
+#include "core/ustring.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
diff --git a/core/os/thread.h b/core/os/thread.h
index c2947bccab..97e97652a5 100644
--- a/core/os/thread.h
+++ b/core/os/thread.h
@@ -31,13 +31,13 @@
#ifndef THREAD_H
#define THREAD_H
-#include "typedefs.h"
+#include "core/typedefs.h"
+#include "core/ustring.h"
+
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-#include "ustring.h"
-
typedef void (*ThreadCreateCallback)(void *p_userdata);
class Thread {
diff --git a/core/os/thread_dummy.cpp b/core/os/thread_dummy.cpp
index b6371235c4..9e0adf9994 100644
--- a/core/os/thread_dummy.cpp
+++ b/core/os/thread_dummy.cpp
@@ -30,7 +30,7 @@
#include "thread_dummy.h"
-#include "memory.h"
+#include "core/os/memory.h"
Thread *ThreadDummy::create(ThreadCreateCallback p_callback, void *p_user, const Thread::Settings &p_settings) {
return memnew(ThreadDummy);
diff --git a/core/os/thread_dummy.h b/core/os/thread_dummy.h
index 74957b95fe..6f46a4a20c 100644
--- a/core/os/thread_dummy.h
+++ b/core/os/thread_dummy.h
@@ -31,10 +31,10 @@
#ifndef THREAD_DUMMY_H
#define THREAD_DUMMY_H
-#include "mutex.h"
-#include "rw_lock.h"
-#include "semaphore.h"
-#include "thread.h"
+#include "core/os/mutex.h"
+#include "core/os/rw_lock.h"
+#include "core/os/semaphore.h"
+#include "core/os/thread.h"
class ThreadDummy : public Thread {
diff --git a/core/os/thread_safe.cpp b/core/os/thread_safe.cpp
index acb37df02b..3fe039e1b6 100644
--- a/core/os/thread_safe.cpp
+++ b/core/os/thread_safe.cpp
@@ -29,8 +29,9 @@
/*************************************************************************/
#include "thread_safe.h"
-#include "error_macros.h"
-#include "os/memory.h"
+
+#include "core/error_macros.h"
+#include "core/os/memory.h"
ThreadSafe::ThreadSafe() {
diff --git a/core/os/thread_safe.h b/core/os/thread_safe.h
index f0876f38a1..a17ceeed1d 100644
--- a/core/os/thread_safe.h
+++ b/core/os/thread_safe.h
@@ -31,7 +31,7 @@
#ifndef THREAD_SAFE_H
#define THREAD_SAFE_H
-#include "os/mutex.h"
+#include "core/os/mutex.h"
class ThreadSafe {
diff --git a/core/os/threaded_array_processor.h b/core/os/threaded_array_processor.h
index 3ff7db2a44..89c3b7cec3 100644
--- a/core/os/threaded_array_processor.h
+++ b/core/os/threaded_array_processor.h
@@ -31,11 +31,11 @@
#ifndef THREADED_ARRAY_PROCESSOR_H
#define THREADED_ARRAY_PROCESSOR_H
-#include "os/mutex.h"
-#include "os/os.h"
-#include "os/thread.h"
-#include "safe_refcount.h"
-#include "thread_safe.h"
+#include "core/os/mutex.h"
+#include "core/os/os.h"
+#include "core/os/thread.h"
+#include "core/os/thread_safe.h"
+#include "core/safe_refcount.h"
template <class C, class U>
struct ThreadArrayProcessData {