summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Emselle <james.e.0111.2@gmail.com>2014-06-26 22:14:37 +1000
committerJames Emselle <james.e.0111.2@gmail.com>2014-06-26 22:14:37 +1000
commit911914adad997b6ab6ceba9bd45349254498ed37 (patch)
treefca2ce83bacfa89b3c5a98c3f07f87c98118f9e7
parente086bccd63e64b8d3bd2b6b5ce000ef8abd71584 (diff)
mouse_mode implementation on OS X
-rw-r--r--platform/osx/os_osx.h4
-rw-r--r--platform/osx/os_osx.mm26
2 files changed, 29 insertions, 1 deletions
diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h
index b9e381d6ec..5b203f1560 100644
--- a/platform/osx/os_osx.h
+++ b/platform/osx/os_osx.h
@@ -98,7 +98,7 @@ public:
id context;
CursorShape cursor_shape;
-
+ MouseMode mouse_mode;
protected:
virtual int get_video_driver_count() const;
@@ -159,6 +159,8 @@ public:
void run();
+ void set_mouse_mode(MouseMode p_mode);
+ MouseMode get_mouse_mode() const;
OS_OSX();
};
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index dda3527618..c09a45bbad 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -1280,6 +1280,32 @@ void OS_OSX::run() {
main_loop->finish();
}
+void OS_OSX::set_mouse_mode(MouseMode p_mode) {
+
+ if (p_mode==mouse_mode)
+ return;
+
+ if (p_mode==MOUSE_MODE_CAPTURED) {
+ // Apple Docs state that the display parameter is not used.
+ // "This parameter is not used. By default, you may pass kCGDirectMainDisplay."
+ // https://developer.apple.com/library/mac/documentation/graphicsimaging/reference/Quartz_Services_Ref/Reference/reference.html
+ CGDisplayHideCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(false);
+ } else if (p_mode==MOUSE_MODE_HIDDEN) {
+ CGDisplayHideCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ } else {
+ CGDisplayShowCursor(kCGDirectMainDisplay);
+ CGAssociateMouseAndMouseCursorPosition(true);
+ }
+
+ mouse_mode=p_mode;
+}
+
+OS::MouseMode OS_OSX::get_mouse_mode() const {
+
+ return mouse_mode;
+}
OS_OSX* OS_OSX::singleton=NULL;