summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/osx/os_osx.h1
-rw-r--r--platform/osx/os_osx.mm6
-rw-r--r--platform/windows/os_windows.cpp16
-rw-r--r--platform/windows/os_windows.h1
-rw-r--r--platform/x11/os_x11.cpp13
-rw-r--r--platform/x11/os_x11.h1
6 files changed, 37 insertions, 1 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index 5b203f1560..5df85bca2a 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -129,6 +129,7 @@ public:
virtual void set_mouse_show(bool p_show);
virtual void set_mouse_grab(bool p_grab);
virtual bool is_mouse_grab_enabled() const;
+ virtual void warp_mouse_pos(const Point2& p_to);
virtual Point2 get_mouse_pos() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String& p_title);
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index 12f98cebe2..c09dadc066 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1067,6 +1067,12 @@ bool OS_OSX::is_mouse_grab_enabled() const {
return mouse_grab;
}
+
+void OS_OSX::warp_mouse_pos(const Point2& p_to) {
+
+//not done, must be done
+}
+
Point2 OS_OSX::get_mouse_pos() const {
return Vector2(mouse_x,mouse_y);
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index a12cd67403..78c40c56d9 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1323,11 +1323,25 @@ void OS_Windows::set_mouse_mode(MouseMode p_mode) {
OS_Windows::MouseMode OS_Windows::get_mouse_mode() const{
+
return mouse_mode;
}
+void OS_Windows::warp_mouse_pos(const Point2& p_to) {
+
+ if (p_mode==MOUSE_MODE_CAPTURED) {
+
+ old_x=p_to.x;
+ old_y=p_to.y;
+ } else {
+
+ SetCursorPos(p_to.x, p_to.y);
+ }
+
+}
+
Point2 OS_Windows::get_mouse_pos() const {
return Point2(old_x, old_y);
@@ -1836,7 +1850,7 @@ String OS_Windows::get_data_dir() const {
if (has_environment("APPDATA")) {
bool use_godot = Globals::get_singleton()->get("application/use_shared_user_dir");
- if (use_godot)
+ if (!use_godot)
return (OS::get_singleton()->get_environment("APPDATA")+"/"+an).replace("\\","/");
else
return (OS::get_singleton()->get_environment("APPDATA")+"/Godot/app_userdata/"+an).replace("\\","/");
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 1a41b9d77d..433d29a84d 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -209,6 +209,7 @@ public:
void set_mouse_mode(MouseMode p_mode);
MouseMode get_mouse_mode() const;
+ virtual void warp_mouse_pos(const Point2& p_to);
virtual Point2 get_mouse_pos() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String& p_title);
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index e0dc594441..4c45fcfaaf 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -461,6 +461,19 @@ void OS_X11::set_mouse_mode(MouseMode p_mode) {
}
+void OS_X11::warp_mouse_pos(const Point2& p_to) {
+
+ if (mouse_mode==MOUSE_MODE_CAPTURED) {
+
+ last_mouse_pos=p_to;
+ } else {
+
+ XWarpPointer(x11_display, None, x11_window,
+ 0,0,0,0, (int)p_to.x, (int)p_to.y);
+ }
+
+}
+
OS::MouseMode OS_X11::get_mouse_mode() const {
return mouse_mode;
diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h
index fedf41ad0f..2ffca0e042 100644
--- a/platform/x11/os_x11.h
+++ b/platform/x11/os_x11.h
@@ -179,6 +179,7 @@ public:
void set_mouse_mode(MouseMode p_mode);
MouseMode get_mouse_mode() const;
+ virtual void warp_mouse_pos(const Point2& p_to);
virtual Point2 get_mouse_pos() const;
virtual int get_mouse_button_state() const;
virtual void set_window_title(const String& p_title);