diff --git a/src/SFML/Window/CMakeLists.txt b/src/SFML/Window/CMakeLists.txt index 30cc2ec7..3f49678d 100644 --- a/src/SFML/Window/CMakeLists.txt +++ b/src/SFML/Window/CMakeLists.txt @@ -67,7 +67,7 @@ else() # MACOSX ${SRCROOT}/OSX/cpp_objc_conversion.mm ${SRCROOT}/OSX/cg_sf_conversion.hpp ${SRCROOT}/OSX/cg_sf_conversion.cpp - ${SRCROOT}/OSX/InputImpl.cpp + ${SRCROOT}/OSX/InputImpl.mm ${SRCROOT}/OSX/InputImpl.hpp ${SRCROOT}/OSX/JoystickImpl.cpp ${SRCROOT}/OSX/JoystickImpl.hpp diff --git a/src/SFML/Window/OSX/InputImpl.cpp b/src/SFML/Window/OSX/InputImpl.mm similarity index 88% rename from src/SFML/Window/OSX/InputImpl.cpp rename to src/SFML/Window/OSX/InputImpl.mm index bfd635c6..5c7654fb 100644 --- a/src/SFML/Window/OSX/InputImpl.cpp +++ b/src/SFML/Window/OSX/InputImpl.mm @@ -26,7 +26,8 @@ // Headers //////////////////////////////////////////////////////////// #include - +#include +#import namespace sf { @@ -51,8 +52,11 @@ bool InputImpl::IsMouseButtonPressed(Mouse::Button button) //////////////////////////////////////////////////////////// Vector2i InputImpl::GetMousePosition() { - // @to be implemented - return Vector2i(); + // Reverse Y axis to match SFML coord. + NSPoint pos = [NSEvent mouseLocation]; + pos.y = sf::VideoMode::GetDesktopMode().Height - pos.y; + + return Vector2i(pos.x, pos.y); } } // namespace priv diff --git a/src/SFML/Window/OSX/SFOpenGLView.mm b/src/SFML/Window/OSX/SFOpenGLView.mm index d9704b24..2b25185d 100644 --- a/src/SFML/Window/OSX/SFOpenGLView.mm +++ b/src/SFML/Window/OSX/SFOpenGLView.mm @@ -192,7 +192,8 @@ sf::Keyboard::Key NonLocalizedKeys(unsigned short keycode); // Place the cursor. CGEventRef event = CGEventCreateMouseEvent(NULL, kCGEventMouseMoved, - CGPointMake(screenCoord.x, screenCoord.y), + CGPointMake(screenCoord.x, + screenCoord.y), /*we don't care about this : */0); CGEventPost(kCGHIDEventTap, event); CFRelease(event);