|
|
@@ -972,10 +972,12 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
|
|
|
|
|
- (void) mouse: (Mouse::MouseEvent) mouseEvent orTouchEvent: (Touch::TouchEvent) touchEvent x: (float) x y: (float) y s: (int) s
|
|
|
{
|
|
|
+ [__view->gameLock lock];
|
|
|
if (!gameplay::Platform::mouseEventInternal(mouseEvent, x, y, s))
|
|
|
{
|
|
|
gameplay::Platform::touchEventInternal(touchEvent, x, y, 0);
|
|
|
}
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
- (void) mouseDown: (NSEvent*) event
|
|
|
@@ -1024,7 +1026,9 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
|
|
y = __height - point.y;
|
|
|
}
|
|
|
|
|
|
+ [__view->gameLock lock];
|
|
|
gameplay::Platform::mouseEventInternal(Mouse::MOUSE_MOVE, point.x, y, 0);
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
- (void) mouseDragged: (NSEvent*) event
|
|
|
@@ -1043,7 +1047,9 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
|
|
__lx = point.x;
|
|
|
__ly = __height - point.y;
|
|
|
|
|
|
+ [__view->gameLock lock];
|
|
|
gameplay::Platform::mouseEventInternal(Mouse::MOUSE_PRESS_RIGHT_BUTTON, point.x, __height - point.y, 0);
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
- (void) rightMouseUp: (NSEvent*) event
|
|
|
@@ -1051,7 +1057,9 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
|
|
__rightMouseDown = false;
|
|
|
NSPoint point = [event locationInWindow];
|
|
|
|
|
|
+ [__view->gameLock lock];
|
|
|
gameplay::Platform::mouseEventInternal(Mouse::MOUSE_RELEASE_RIGHT_BUTTON, point.x, __height - point.y, 0);
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
- (void) rightMouseDragged: (NSEvent*) event
|
|
|
@@ -1074,27 +1082,38 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
|
|
|
|
|
// In right-mouse case, whether __rightMouseDown is true or false
|
|
|
// this should not matter, mouse move is still occuring
|
|
|
+ [__view->gameLock lock];
|
|
|
gameplay::Platform::mouseEventInternal(Mouse::MOUSE_MOVE, point.x, __height - point.y, 0);
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
- (void)otherMouseDown: (NSEvent*) event
|
|
|
{
|
|
|
__otherMouseDown = true;
|
|
|
NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
|
|
|
+
|
|
|
+ [__view->gameLock lock];
|
|
|
gameplay::Platform::mouseEventInternal(Mouse::MOUSE_PRESS_MIDDLE_BUTTON, point.x, __height - point.y, 0);
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
- (void)otherMouseUp: (NSEvent*) event
|
|
|
{
|
|
|
__otherMouseDown = false;
|
|
|
NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
|
|
|
+
|
|
|
+ [__view->gameLock lock];
|
|
|
gameplay::Platform::mouseEventInternal(Mouse::MOUSE_RELEASE_MIDDLE_BUTTON, point.x, __height - point.y, 0);
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
- (void)otherMouseDragged: (NSEvent*) event
|
|
|
{
|
|
|
NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
|
|
|
+
|
|
|
+ [__view->gameLock lock];
|
|
|
gameplay::Platform::mouseEventInternal(Mouse::MOUSE_MOVE, point.x, __height - point.y, 0);
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
- (void) mouseEntered: (NSEvent*)event
|
|
|
@@ -1105,7 +1124,10 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
|
|
|
- (void)scrollWheel: (NSEvent*) event
|
|
|
{
|
|
|
NSPoint point = [self convertPoint:[event locationInWindow] fromView:nil];
|
|
|
+
|
|
|
+ [__view->gameLock lock];
|
|
|
gameplay::Platform::mouseEventInternal(Mouse::MOUSE_WHEEL, point.x, __height - point.y, (int)([event deltaY] * 10.0f));
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
- (void) mouseExited: (NSEvent*)event
|
|
|
@@ -1441,6 +1463,8 @@ int getUnicode(int key)
|
|
|
{
|
|
|
unsigned int keyCode = [event keyCode];
|
|
|
unsigned int flags = [event modifierFlags];
|
|
|
+
|
|
|
+ [__view->gameLock lock];
|
|
|
switch (keyCode)
|
|
|
{
|
|
|
case 0x39:
|
|
|
@@ -1471,6 +1495,7 @@ int getUnicode(int key)
|
|
|
gameplay::Platform::keyEventInternal((flags & NSCommandKeyMask) ? Keyboard::KEY_PRESS : Keyboard::KEY_RELEASE, Keyboard::KEY_HYPER);
|
|
|
break;
|
|
|
}
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
- (void) keyDown: (NSEvent*) event
|
|
|
@@ -1478,6 +1503,8 @@ int getUnicode(int key)
|
|
|
if ([event isARepeat] == NO)
|
|
|
{
|
|
|
int key = getKey([event keyCode], [event modifierFlags]);
|
|
|
+
|
|
|
+ [__view->gameLock lock];
|
|
|
gameplay::Platform::keyEventInternal(Keyboard::KEY_PRESS, key);
|
|
|
|
|
|
int character = getUnicode(key);
|
|
|
@@ -1485,12 +1512,16 @@ int getUnicode(int key)
|
|
|
{
|
|
|
gameplay::Platform::keyEventInternal(Keyboard::KEY_CHAR, character);
|
|
|
}
|
|
|
+
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- (void) keyUp: (NSEvent*) event
|
|
|
-{
|
|
|
+{
|
|
|
+ [__view->gameLock lock];
|
|
|
gameplay::Platform::keyEventInternal(Keyboard::KEY_RELEASE, getKey([event keyCode], [event modifierFlags]));
|
|
|
+ [__view->gameLock unlock];
|
|
|
}
|
|
|
|
|
|
// Gesture support for Mac OS X Trackpads
|
|
|
@@ -1848,62 +1879,6 @@ void Platform::displayKeyboard(bool display)
|
|
|
// Do nothing.
|
|
|
}
|
|
|
|
|
|
-void Platform::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
|
|
|
-{
|
|
|
- [__view->gameLock lock];
|
|
|
- if (!Form::touchEventInternal(evt, x, y, contactIndex))
|
|
|
- {
|
|
|
- Game::getInstance()->touchEvent(evt, x, y, contactIndex);
|
|
|
- Game::getInstance()->getScriptController()->touchEvent(evt, x, y, contactIndex);
|
|
|
- }
|
|
|
- [__view->gameLock unlock];
|
|
|
-}
|
|
|
-
|
|
|
-void Platform::keyEventInternal(Keyboard::KeyEvent evt, int key)
|
|
|
-{
|
|
|
- [__view->gameLock lock];
|
|
|
- if (!Form::keyEventInternal(evt, key))
|
|
|
- {
|
|
|
- Game::getInstance()->keyEvent(evt, key);
|
|
|
- Game::getInstance()->getScriptController()->keyEvent(evt, key);
|
|
|
- }
|
|
|
- [__view->gameLock unlock];
|
|
|
-}
|
|
|
-
|
|
|
-bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheelDelta)
|
|
|
-{
|
|
|
- [__view->gameLock lock];
|
|
|
-
|
|
|
- bool result;
|
|
|
- if (Form::mouseEventInternal(evt, x, y, wheelDelta))
|
|
|
- {
|
|
|
- result = true;
|
|
|
- }
|
|
|
- else if (Game::getInstance()->mouseEvent(evt, x, y, wheelDelta))
|
|
|
- {
|
|
|
- result = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- result = Game::getInstance()->getScriptController()->mouseEvent(evt, x, y, wheelDelta);
|
|
|
- }
|
|
|
-
|
|
|
- [__view->gameLock unlock];
|
|
|
-
|
|
|
- return result;
|
|
|
-}
|
|
|
-
|
|
|
-void Platform::gamepadEventConnectedInternal(GamepadHandle handle, unsigned int buttonCount, unsigned int joystickCount, unsigned int triggerCount,
|
|
|
- unsigned int vendorId, unsigned int productId, const char* vendorString, const char* productString)
|
|
|
-{
|
|
|
- Gamepad::add(handle, buttonCount, joystickCount, triggerCount, vendorId, productId, vendorString, productString);
|
|
|
-}
|
|
|
-
|
|
|
-void Platform::gamepadEventDisconnectedInternal(GamepadHandle handle)
|
|
|
-{
|
|
|
- Gamepad::remove(handle);
|
|
|
-}
|
|
|
-
|
|
|
void Platform::shutdownInternal()
|
|
|
{
|
|
|
Game::getInstance()->shutdown();
|