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
int hats;
int axes;
int buttons;
int numActiveJoysticks;
irr::SEvent persistentData;
......@@ -278,7 +277,6 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo)
CFTypeRef refUsagePage = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsagePageKey));
CFTypeRef refUsage = CFDictionaryGetValue ((CFDictionaryRef)refElement, CFSTR(kIOHIDElementUsageKey));
if ((refElementType) && (CFNumberGetValue ((CFNumberRef)refElementType, kCFNumberLongType, &elementType)))
{
/* look at types of interest */
......@@ -349,7 +347,6 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo)
}
}
}
}
static void getJoystickComponentArrayHandler (const void * value, void * parameter)
......@@ -1134,8 +1131,14 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
}
else
{
ievent.MouseInput.X = (int)[NSEvent mouseLocation].x;
ievent.MouseInput.Y = DeviceHeight - (int)[NSEvent mouseLocation].y;
CGEventRef ourEvent = CGEventCreate(NULL);
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)
......@@ -1147,22 +1150,35 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
void CIrrDeviceMacOSX::storeMouseLocation()
{
NSPoint p;
int x,y;
p = [NSEvent mouseLocation];
if (Window != NULL)
{
NSPoint p;
p = [NSEvent mouseLocation];
p = [Window convertScreenToBase:p];
x = (int)p.x;
y = DeviceHeight - (int)p.y;
}
else
{
x = (int)p.x;
y = (int)p.y;
y -= (ScreenHeight - DeviceHeight);
CGEventRef ourEvent = CGEventCreate(NULL);
CGPoint point = CGEventGetLocation(ourEvent);
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);
......
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