2
0

PolycodeView.mm 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589
  1. /*
  2. Copyright (C) 2011 by Ivan Safrin
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.
  18. */
  19. #import "PolycodeView.h"
  20. @implementation PolycodeView
  21. @synthesize viewReady;
  22. @synthesize mouseX;
  23. @synthesize mouseY;
  24. - (id)initWithFrame:(NSRect)frameRect pixelFormat:(NSOpenGLPixelFormat *)format
  25. {
  26. self = [super initWithFrame:frameRect pixelFormat:format];
  27. if(self) {
  28. glSizeX = 0;
  29. glSizeY = 0;
  30. viewReady = NO;
  31. currentCursor = NULL;
  32. contextLock = [[NSLock alloc] init];
  33. }
  34. return self;
  35. }
  36. - (void) awakeFromNib {
  37. contextLock = [[NSLock alloc] init];
  38. [[self window] setAcceptsMouseMovedEvents:YES];
  39. [[self window] makeFirstResponder:self];
  40. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowResized:) name:NSWindowDidResizeNotification object:[self window]];
  41. [self setAutoresizesSubviews: YES];
  42. }
  43. -(void) viewDidMoveToWindow
  44. {
  45. [super viewDidMoveToWindow];
  46. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResignMain:) name:NSWindowDidResignKeyNotification object:[self window]];
  47. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidResignMain:) name:NSWindowDidResignMainNotification object:[self window]];
  48. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeMain:) name:NSWindowDidBecomeKeyNotification object:[self window]];
  49. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowDidBecomeMain:) name:NSWindowDidBecomeMainNotification object:[self window]];
  50. viewReady = YES;
  51. }
  52. - (void)windowDidResignMain:(NSNotification *)notification
  53. {
  54. if(core == NULL)
  55. return;
  56. memset(modifierMap, 0, 512);
  57. core->lockMutex(core->eventMutex);
  58. CocoaEvent newEvent;
  59. newEvent.eventGroup = CocoaEvent::FOCUS_EVENT;
  60. newEvent.eventCode = Core::EVENT_LOST_FOCUS;
  61. core->cocoaEvents.push_back(newEvent);
  62. core->unlockMutex(core->eventMutex);
  63. }
  64. - (void)windowDidBecomeMain:(NSNotification *)notification
  65. {
  66. if(core == NULL)
  67. return;
  68. memset(modifierMap, 0, 512);
  69. core->lockMutex(core->eventMutex);
  70. CocoaEvent newEvent;
  71. newEvent.eventGroup = CocoaEvent::FOCUS_EVENT;
  72. newEvent.eventCode = Core::EVENT_GAINED_FOCUS;
  73. core->cocoaEvents.push_back(newEvent);
  74. core->unlockMutex(core->eventMutex);
  75. }
  76. - (void) initKeymap {
  77. memset(modifierMap, 0, 512);
  78. keymap[0x00] = KEY_a;
  79. keymap[0x01] = KEY_s;
  80. keymap[0x02] = KEY_d;
  81. keymap[0x03] = KEY_f;
  82. keymap[0x05] = KEY_g;
  83. keymap[0x04] = KEY_h;
  84. keymap[0x06] = KEY_z;
  85. keymap[0x07] = KEY_x;
  86. keymap[0x08] = KEY_c;
  87. keymap[0x09] = KEY_v;
  88. keymap[0x0B] = KEY_b;
  89. keymap[0x0C] = KEY_q;
  90. keymap[0x0D] = KEY_w;
  91. keymap[0x0E] = KEY_e;
  92. keymap[0x0F] = KEY_r;
  93. keymap[0x10] = KEY_y;
  94. keymap[0x11] = KEY_t;
  95. keymap[0x12] = KEY_1;
  96. keymap[0x13] = KEY_2;
  97. keymap[0x14] = KEY_3;
  98. keymap[0x15] = KEY_4;
  99. keymap[0x16] = KEY_6;
  100. keymap[0x17] = KEY_5;
  101. keymap[0x18] = KEY_EQUALS;
  102. keymap[0x19] = KEY_9;
  103. keymap[0x1A] = KEY_7;
  104. keymap[0x1B] = KEY_MINUS;
  105. keymap[0x1C] = KEY_8;
  106. keymap[0x1D] = KEY_0;
  107. keymap[0x1E] = KEY_RIGHTBRACKET;
  108. keymap[0x1F] = KEY_o;
  109. keymap[0x20] = KEY_u;
  110. keymap[0x21] = KEY_LEFTBRACKET;
  111. keymap[0x22] = KEY_i;
  112. keymap[0x23] = KEY_p;
  113. keymap[0x25] = KEY_l;
  114. keymap[0x26] = KEY_j;
  115. keymap[0x27] = KEY_QUOTE;
  116. keymap[0x28] = KEY_k;
  117. keymap[0x29] = KEY_SEMICOLON;
  118. keymap[0x2A] = KEY_BACKSLASH;
  119. keymap[0x2B] = KEY_COMMA;
  120. keymap[0x2C] = KEY_SLASH;
  121. keymap[0x2D] = KEY_n;
  122. keymap[0x2E] = KEY_m;
  123. keymap[0x2F] = KEY_PERIOD;
  124. // keymap[0x32] = KEY_GRAVE;
  125. keymap[0x41] = KEY_KP_PERIOD;
  126. keymap[0x43] = KEY_KP_MULTIPLY;
  127. keymap[0x45] = KEY_KP_PLUS;
  128. // keymap[0x47] = KEY_KeypadClear;
  129. keymap[0x4B] = KEY_KP_DIVIDE;
  130. keymap[0x4C] = KEY_KP_ENTER;
  131. keymap[0x4E] = KEY_KP_MINUS;
  132. keymap[0x51] = KEY_KP_EQUALS;
  133. keymap[0x52] = KEY_KP0;
  134. keymap[0x53] = KEY_KP1;
  135. keymap[0x54] = KEY_KP2;
  136. keymap[0x55] = KEY_KP3;
  137. keymap[0x56] = KEY_KP4;
  138. keymap[0x57] = KEY_KP5;
  139. keymap[0x58] = KEY_KP6;
  140. keymap[0x59] = KEY_KP7;
  141. keymap[0x5B] = KEY_KP8;
  142. keymap[0x5C] = KEY_KP9;
  143. keymap[0x24] = KEY_RETURN;
  144. keymap[0x30] = KEY_TAB;
  145. keymap[0x31] = KEY_SPACE;
  146. keymap[0x33] = KEY_BACKSPACE;
  147. keymap[0x35] = KEY_ESCAPE;
  148. keymap[0x37] = KEY_LSUPER;
  149. keymap[0x36] = KEY_RSUPER;
  150. keymap[0x38] = KEY_LSHIFT;
  151. keymap[0x39] = KEY_CAPSLOCK;
  152. keymap[0x3A] = KEY_LALT;
  153. keymap[0x3D] = KEY_RALT;
  154. keymap[0x3B] = KEY_LCTRL;
  155. keymap[0x3C] = KEY_RSHIFT;
  156. keymap[0x3E] = KEY_RCTRL;
  157. keymap[0x3F] = KEY_COMPOSE;
  158. // keymap[0x40] = KEY_F17;
  159. // keymap[0x48] = KEY_VolumeUp;
  160. // keymap[0x49] = KEY_VolumeDown;
  161. // keymap[0x4A] = KEY_Mute;
  162. // keymap[0x4F] = KEY_F18;
  163. // keymap[0x50] = KEY_F19;
  164. // keymap[0x5A] = KEY_F20;
  165. keymap[0x60] = KEY_F5;
  166. keymap[0x61] = KEY_F6;
  167. keymap[0x62] = KEY_F7;
  168. keymap[0x63] = KEY_F3;
  169. keymap[0x64] = KEY_F8;
  170. keymap[0x65] = KEY_F9;
  171. keymap[0x67] = KEY_F11;
  172. keymap[0x69] = KEY_F13;
  173. // keymap[0x6A] = KEY_F16;
  174. keymap[0x6B] = KEY_F14;
  175. keymap[0x6D] = KEY_F10;
  176. keymap[0x6F] = KEY_F12;
  177. keymap[0x71] = KEY_F15;
  178. keymap[0x72] = KEY_HELP;
  179. keymap[0x73] = KEY_HOME;
  180. keymap[0x74] = KEY_PAGEUP;
  181. keymap[0x75] = KEY_DELETE;
  182. keymap[0x76] = KEY_F4;
  183. keymap[0x77] = KEY_END;
  184. keymap[0x78] = KEY_F2;
  185. keymap[0x79] = KEY_PAGEDOWN;
  186. keymap[0x7A] = KEY_F1;
  187. keymap[0x7B] = KEY_LEFT;
  188. keymap[0x7C] = KEY_RIGHT;
  189. keymap[0x7D] = KEY_DOWN;
  190. keymap[0x7E] = KEY_UP;
  191. // keymap[0x0A] = KEY_ISO_Section;
  192. // keymap[0x5D] = KEY_JIS_Yen;
  193. // keymap[0x5E] = KEY_JIS_Underscore;
  194. // keymap[0x5F] = KEY_JIS_KeypadComma;
  195. // keymap[0x66] = KEY_JIS_Eisu;
  196. // keymap[0x68] = KEY_JIS_Kana;
  197. }
  198. -(void) setCurrentCursor: (NSCursor*) newCursor
  199. {
  200. currentCursor = newCursor;
  201. }
  202. - (void)resetCursorRects
  203. {
  204. if(currentCursor)
  205. [self addCursorRect:[self bounds] cursor:currentCursor];
  206. }
  207. - (void) setCore: (CocoaCore*) newCore {
  208. [self initKeymap];
  209. core = newCore;
  210. }
  211. - (BOOL) lockFocusIfCanDraw {
  212. [contextLock lock];
  213. BOOL retVal = [super lockFocusIfCanDraw];
  214. [contextLock unlock];
  215. return retVal;
  216. }
  217. - (void) update {
  218. [contextLock lock];
  219. [super update];
  220. [contextLock unlock];
  221. }
  222. - (void) lockContext {
  223. [contextLock lock];
  224. }
  225. - (void) unlockContext {
  226. [contextLock unlock];
  227. }
  228. - (void)prepareOpenGL {
  229. contextReady = YES;
  230. }
  231. - (BOOL) isContextReady {
  232. return contextReady;
  233. }
  234. - (void)setOpenGLContext:(NSOpenGLContext *)context {
  235. contextReady = NO;
  236. [super setOpenGLContext:context];
  237. }
  238. - (BOOL)acceptsFirstResponder
  239. {
  240. return YES;
  241. }
  242. // ---------------------------------
  243. - (BOOL)becomeFirstResponder
  244. {
  245. return YES;
  246. }
  247. // ---------------------------------
  248. - (BOOL)resignFirstResponder
  249. {
  250. return YES;
  251. }
  252. - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
  253. {
  254. return YES;
  255. }
  256. - (BOOL)mouseDownCanMoveWindow
  257. {
  258. return NO;
  259. }
  260. - (void) drawRect:(NSRect)rect {
  261. if(glSizeX != (int)[self frame].size.width || glSizeY != (int)[self frame].size.height) {
  262. glSizeX = (int)[self frame].size.width;
  263. glSizeY = (int)[self frame].size.height;
  264. if(core != NULL) {
  265. core->resizeTo(glSizeX, glSizeY);
  266. }
  267. }
  268. }
  269. -(void) windowResized: (NSNotification *) notification {
  270. }
  271. -(void) dealloc {
  272. [[NSNotificationCenter defaultCenter] removeObserver:self];
  273. [super dealloc];
  274. }
  275. - (void) resizeWithOldSuperviewSize: (NSSize) oldSize {
  276. [super resizeWithOldSuperviewSize: oldSize];
  277. // if(core == NULL)
  278. // return;
  279. // core->setVideoMode(oldSize.width, oldSize.height, core->isFullscreen(), core->getAALevel());
  280. }
  281. // INPUT
  282. - (void) otherMouseDown:(NSEvent *) event
  283. {
  284. if(core == NULL)
  285. return;
  286. core->lockMutex(core->eventMutex);
  287. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  288. CocoaEvent newEvent;
  289. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  290. newEvent.eventCode = InputEvent::EVENT_MOUSEDOWN;
  291. newEvent.mouseButton = CoreInput::MOUSE_BUTTON3;
  292. newEvent.mouseX = mouseLoc.x;
  293. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  294. core->cocoaEvents.push_back(newEvent);
  295. core->unlockMutex(core->eventMutex);
  296. }
  297. - (void) otherMouseUp:(NSEvent *) event
  298. {
  299. if(core == NULL)
  300. return;
  301. core->lockMutex(core->eventMutex);
  302. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  303. CocoaEvent newEvent;
  304. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  305. newEvent.eventCode = InputEvent::EVENT_MOUSEUP;
  306. newEvent.mouseButton = CoreInput::MOUSE_BUTTON3;
  307. newEvent.mouseX = mouseLoc.x;
  308. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  309. core->cocoaEvents.push_back(newEvent);
  310. core->unlockMutex(core->eventMutex);
  311. }
  312. - (void) rightMouseDown:(NSEvent *) event
  313. {
  314. if(core == NULL)
  315. return;
  316. core->lockMutex(core->eventMutex);
  317. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  318. CocoaEvent newEvent;
  319. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  320. newEvent.eventCode = InputEvent::EVENT_MOUSEDOWN;
  321. newEvent.mouseButton = CoreInput::MOUSE_BUTTON2;
  322. newEvent.mouseX = mouseLoc.x;
  323. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  324. core->cocoaEvents.push_back(newEvent);
  325. core->unlockMutex(core->eventMutex);
  326. }
  327. - (void) rightMouseUp:(NSEvent *) event
  328. {
  329. if(core == NULL)
  330. return;
  331. core->lockMutex(core->eventMutex);
  332. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  333. CocoaEvent newEvent;
  334. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  335. newEvent.eventCode = InputEvent::EVENT_MOUSEUP;
  336. newEvent.mouseButton = CoreInput::MOUSE_BUTTON2;
  337. newEvent.mouseX = mouseLoc.x;
  338. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  339. core->cocoaEvents.push_back(newEvent);
  340. core->unlockMutex(core->eventMutex);
  341. }
  342. - (void)scrollWheel:(NSEvent*) event {
  343. if(core == NULL || [event deltaY] == 0)
  344. return;
  345. core->lockMutex(core->eventMutex);
  346. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  347. CocoaEvent newEvent;
  348. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  349. if([event deltaY] > 0)
  350. newEvent.eventCode = InputEvent::EVENT_MOUSEWHEEL_UP;
  351. else
  352. newEvent.eventCode = InputEvent::EVENT_MOUSEWHEEL_DOWN;
  353. newEvent.mouseX = mouseLoc.x;
  354. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  355. core->cocoaEvents.push_back(newEvent);
  356. core->unlockMutex(core->eventMutex);
  357. }
  358. - (void) mouseDown:(NSEvent *) event
  359. {
  360. if(core == NULL)
  361. return;
  362. core->lockMutex(core->eventMutex);
  363. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  364. CocoaEvent newEvent;
  365. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  366. newEvent.eventCode = InputEvent::EVENT_MOUSEDOWN;
  367. newEvent.mouseButton = CoreInput::MOUSE_BUTTON1;
  368. newEvent.mouseX = mouseLoc.x;
  369. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  370. mouseX = mouseLoc.x;
  371. mouseY = mouseLoc.y;
  372. core->cocoaEvents.push_back(newEvent);
  373. core->unlockMutex(core->eventMutex);
  374. }
  375. - (void) mouseUp:(NSEvent *) event
  376. {
  377. if(core == NULL)
  378. return;
  379. core->lockMutex(core->eventMutex);
  380. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  381. CocoaEvent newEvent;
  382. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  383. newEvent.eventCode = InputEvent::EVENT_MOUSEUP;
  384. newEvent.mouseButton = CoreInput::MOUSE_BUTTON1;
  385. newEvent.mouseX = mouseLoc.x;
  386. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  387. mouseX = mouseLoc.x;
  388. mouseY = mouseLoc.y;
  389. core->cocoaEvents.push_back(newEvent);
  390. core->unlockMutex(core->eventMutex);
  391. }
  392. - (void)flagsChanged:(NSEvent *)theEvent
  393. {
  394. if(core == NULL)
  395. return;
  396. // NSLog(@"KEY: %x\n", [theEvent keyCode]);
  397. if([theEvent keyCode] == 0) {
  398. return;
  399. }
  400. core->lockMutex(core->eventMutex);
  401. CocoaEvent newEvent;
  402. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  403. newEvent.keyCode = keymap[[theEvent keyCode]];
  404. if(modifierMap[[theEvent keyCode]] == 0) {
  405. modifierMap[[theEvent keyCode]] = 1;
  406. newEvent.eventCode = InputEvent::EVENT_KEYDOWN;
  407. } else {
  408. modifierMap[[theEvent keyCode]] = 0;
  409. newEvent.eventCode = InputEvent::EVENT_KEYUP;
  410. }
  411. newEvent.unicodeChar = 0;
  412. core->cocoaEvents.push_back(newEvent);
  413. core->unlockMutex(core->eventMutex);
  414. }
  415. - (void)keyDown: (NSEvent*) theEvent
  416. {
  417. if(core == NULL)
  418. return;
  419. core->lockMutex(core->eventMutex);
  420. CocoaEvent newEvent;
  421. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  422. newEvent.eventCode = InputEvent::EVENT_KEYDOWN;
  423. newEvent.keyCode = keymap[[theEvent keyCode]];
  424. NSString *chars = [theEvent characters];
  425. unsigned int numChars = [chars length];
  426. // NSLog(@"CHARS: %@", [chars characterAtIndex:0]);
  427. if(numChars > 0) {
  428. newEvent.unicodeChar = [chars characterAtIndex:0];
  429. } else {
  430. newEvent.unicodeChar = 0;
  431. }
  432. core->cocoaEvents.push_back(newEvent);
  433. core->unlockMutex(core->eventMutex);
  434. }
  435. - (void)keyUp: (NSEvent*) theEvent
  436. {
  437. if(core == NULL)
  438. return;
  439. core->lockMutex(core->eventMutex);
  440. NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:self];
  441. CocoaEvent newEvent;
  442. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  443. newEvent.eventCode = InputEvent::EVENT_KEYUP;
  444. newEvent.keyCode = keymap[[theEvent keyCode]];
  445. NSString *chars = [theEvent characters];
  446. unsigned int numChars = [chars length];
  447. if(numChars > 0)
  448. newEvent.unicodeChar = [chars characterAtIndex:0];
  449. else
  450. newEvent.unicodeChar = 0;
  451. core->cocoaEvents.push_back(newEvent);
  452. core->unlockMutex(core->eventMutex);
  453. }
  454. - (void)mouseDragged:(NSEvent *)theEvent
  455. {
  456. if(core == NULL)
  457. return;
  458. core->lockMutex(core->eventMutex);
  459. NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:self];
  460. CocoaEvent newEvent;
  461. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  462. newEvent.eventCode = InputEvent::EVENT_MOUSEMOVE;
  463. newEvent.mouseX = mouseLoc.x;
  464. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  465. core->cocoaEvents.push_back(newEvent);
  466. core->unlockMutex(core->eventMutex);
  467. }
  468. - (void)mouseMoved:(NSEvent *)theEvent
  469. {
  470. if(core == NULL)
  471. return;
  472. core->lockMutex(core->eventMutex);
  473. NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:self];
  474. CocoaEvent newEvent;
  475. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  476. newEvent.eventCode = InputEvent::EVENT_MOUSEMOVE;
  477. newEvent.mouseX = mouseLoc.x;
  478. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  479. mouseX = mouseLoc.x;
  480. mouseY = mouseLoc.y;
  481. core->cocoaEvents.push_back(newEvent);
  482. core->unlockMutex(core->eventMutex);
  483. }
  484. @end