Commit c54ab64e authored by hybrid's avatar hybrid

Fix for OSX mouse events in fullscreen by auria

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3960 dfc29bdd-3216-0410-991c-e03cc46cb475
parent ba4172de
...@@ -204,7 +204,6 @@ struct JoystickInfo ...@@ -204,7 +204,6 @@ struct JoystickInfo
int hats; int hats;
int axes; int axes;
int buttons; int buttons;
int numActiveJoysticks; int numActiveJoysticks;
irr::SEvent persistentData; irr::SEvent persistentData;
...@@ -278,7 +277,6 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo) ...@@ -278,7 +277,6 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo)
CFTypeRef refUsagePage = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsagePageKey)); CFTypeRef refUsagePage = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsagePageKey));
CFTypeRef refUsage = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsageKey)); CFTypeRef refUsage = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsageKey));
if ((refElementType) && (CFNumberGetValue ((CFNumberRef)refElementType, kCFNumberLongType, &elementType))) if ((refElementType) && (CFNumberGetValue ((CFNumberRef)refElementType, kCFNumberLongType, &elementType)))
{ {
/* look at types of interest */ /* look at types of interest */
...@@ -349,7 +347,6 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo) ...@@ -349,7 +347,6 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo)
} }
} }
} }
} }
static void getJoystickComponentArrayHandler (const void * value, void * parameter) static void getJoystickComponentArrayHandler (const void * value, void * parameter)
...@@ -1134,8 +1131,14 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent) ...@@ -1134,8 +1131,14 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
} }
else else
{ {
ievent.MouseInput.X = (int)[NSEvent mouseLocation].x; CGEventRef ourEvent = CGEventCreate(NULL);
ievent.MouseInput.Y = DeviceHeight - (int)[NSEvent mouseLocation].y; CGPoint point = CGEventGetLocation(ourEvent);
ievent.MouseInput.X = (int)point.x;
ievent.MouseInput.Y = (int)point.y;
if (ievent.MouseInput.Y < 0)
post = false;
} }
if (post) if (post)
...@@ -1147,22 +1150,35 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent) ...@@ -1147,22 +1150,35 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
void CIrrDeviceMacOSX::storeMouseLocation() void CIrrDeviceMacOSX::storeMouseLocation()
{ {
NSPoint p;
int x,y; int x,y;
p = [NSEvent mouseLocation];
if (Window != NULL) if (Window != NULL)
{ {
NSPoint p;
p = [NSEvent mouseLocation];
p = [Window convertScreenToBase:p]; p = [Window convertScreenToBase:p];
x = (int)p.x; x = (int)p.x;
y = DeviceHeight - (int)p.y; y = DeviceHeight - (int)p.y;
} }
else else
{ {
x = (int)p.x; CGEventRef ourEvent = CGEventCreate(NULL);
y = (int)p.y; CGPoint point = CGEventGetLocation(ourEvent);
y -= (ScreenHeight - DeviceHeight);
x = (int)point.x;
y = (int)point.y;
const core::position2di& curr = ((CCursorControl *)CursorControl)->getPosition();
if (curr.X != x || curr.Y != y)
{
// In fullscreen mode, events are not sent regularly so rely on polling
irr::SEvent ievent;
ievent.EventType = irr::EET_MOUSE_INPUT_EVENT;
ievent.MouseInput.Event = irr::EMIE_LMOUSE_PRESSED_DOWN;
ievent.MouseInput.X = x;
ievent.MouseInput.Y = y;
postEventFromUser(ievent);
}
} }
((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y); ((CCursorControl *)CursorControl)->updateInternalCursorPosition(x,y);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment