PolycodeView.mm 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587
  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. core->lockMutex(core->eventMutex);
  69. CocoaEvent newEvent;
  70. newEvent.eventGroup = CocoaEvent::FOCUS_EVENT;
  71. newEvent.eventCode = Core::EVENT_GAINED_FOCUS;
  72. core->cocoaEvents.push_back(newEvent);
  73. core->unlockMutex(core->eventMutex);
  74. }
  75. - (void) initKeymap {
  76. memset(modifierMap, 0, 512);
  77. keymap[0x00] = KEY_a;
  78. keymap[0x01] = KEY_s;
  79. keymap[0x02] = KEY_d;
  80. keymap[0x03] = KEY_f;
  81. keymap[0x05] = KEY_g;
  82. keymap[0x04] = KEY_h;
  83. keymap[0x06] = KEY_z;
  84. keymap[0x07] = KEY_x;
  85. keymap[0x08] = KEY_c;
  86. keymap[0x09] = KEY_v;
  87. keymap[0x0B] = KEY_b;
  88. keymap[0x0C] = KEY_q;
  89. keymap[0x0D] = KEY_w;
  90. keymap[0x0E] = KEY_e;
  91. keymap[0x0F] = KEY_r;
  92. keymap[0x10] = KEY_y;
  93. keymap[0x11] = KEY_t;
  94. keymap[0x12] = KEY_1;
  95. keymap[0x13] = KEY_2;
  96. keymap[0x14] = KEY_3;
  97. keymap[0x15] = KEY_4;
  98. keymap[0x16] = KEY_6;
  99. keymap[0x17] = KEY_5;
  100. keymap[0x18] = KEY_EQUALS;
  101. keymap[0x19] = KEY_9;
  102. keymap[0x1A] = KEY_7;
  103. keymap[0x1B] = KEY_MINUS;
  104. keymap[0x1C] = KEY_8;
  105. keymap[0x1D] = KEY_0;
  106. keymap[0x1E] = KEY_RIGHTBRACKET;
  107. keymap[0x1F] = KEY_o;
  108. keymap[0x20] = KEY_u;
  109. keymap[0x21] = KEY_LEFTBRACKET;
  110. keymap[0x22] = KEY_i;
  111. keymap[0x23] = KEY_p;
  112. keymap[0x25] = KEY_l;
  113. keymap[0x26] = KEY_j;
  114. keymap[0x27] = KEY_QUOTE;
  115. keymap[0x28] = KEY_k;
  116. keymap[0x29] = KEY_SEMICOLON;
  117. keymap[0x2A] = KEY_BACKSLASH;
  118. keymap[0x2B] = KEY_COMMA;
  119. keymap[0x2C] = KEY_SLASH;
  120. keymap[0x2D] = KEY_n;
  121. keymap[0x2E] = KEY_m;
  122. keymap[0x2F] = KEY_PERIOD;
  123. // keymap[0x32] = KEY_GRAVE;
  124. keymap[0x41] = KEY_KP_PERIOD;
  125. keymap[0x43] = KEY_KP_MULTIPLY;
  126. keymap[0x45] = KEY_KP_PLUS;
  127. // keymap[0x47] = KEY_KeypadClear;
  128. keymap[0x4B] = KEY_KP_DIVIDE;
  129. keymap[0x4C] = KEY_KP_ENTER;
  130. keymap[0x4E] = KEY_KP_MINUS;
  131. keymap[0x51] = KEY_KP_EQUALS;
  132. keymap[0x52] = KEY_KP0;
  133. keymap[0x53] = KEY_KP1;
  134. keymap[0x54] = KEY_KP2;
  135. keymap[0x55] = KEY_KP3;
  136. keymap[0x56] = KEY_KP4;
  137. keymap[0x57] = KEY_KP5;
  138. keymap[0x58] = KEY_KP6;
  139. keymap[0x59] = KEY_KP7;
  140. keymap[0x5B] = KEY_KP8;
  141. keymap[0x5C] = KEY_KP9;
  142. keymap[0x24] = KEY_RETURN;
  143. keymap[0x30] = KEY_TAB;
  144. keymap[0x31] = KEY_SPACE;
  145. keymap[0x33] = KEY_BACKSPACE;
  146. keymap[0x35] = KEY_ESCAPE;
  147. keymap[0x37] = KEY_LSUPER;
  148. keymap[0x36] = KEY_RSUPER;
  149. keymap[0x38] = KEY_LSHIFT;
  150. keymap[0x39] = KEY_CAPSLOCK;
  151. keymap[0x3A] = KEY_LALT;
  152. keymap[0x3D] = KEY_RALT;
  153. keymap[0x3B] = KEY_LCTRL;
  154. keymap[0x3C] = KEY_RSHIFT;
  155. keymap[0x3E] = KEY_RCTRL;
  156. keymap[0x3F] = KEY_COMPOSE;
  157. // keymap[0x40] = KEY_F17;
  158. // keymap[0x48] = KEY_VolumeUp;
  159. // keymap[0x49] = KEY_VolumeDown;
  160. // keymap[0x4A] = KEY_Mute;
  161. // keymap[0x4F] = KEY_F18;
  162. // keymap[0x50] = KEY_F19;
  163. // keymap[0x5A] = KEY_F20;
  164. keymap[0x60] = KEY_F5;
  165. keymap[0x61] = KEY_F6;
  166. keymap[0x62] = KEY_F7;
  167. keymap[0x63] = KEY_F3;
  168. keymap[0x64] = KEY_F8;
  169. keymap[0x65] = KEY_F9;
  170. keymap[0x67] = KEY_F11;
  171. keymap[0x69] = KEY_F13;
  172. // keymap[0x6A] = KEY_F16;
  173. keymap[0x6B] = KEY_F14;
  174. keymap[0x6D] = KEY_F10;
  175. keymap[0x6F] = KEY_F12;
  176. keymap[0x71] = KEY_F15;
  177. keymap[0x72] = KEY_HELP;
  178. keymap[0x73] = KEY_HOME;
  179. keymap[0x74] = KEY_PAGEUP;
  180. keymap[0x75] = KEY_DELETE;
  181. keymap[0x76] = KEY_F4;
  182. keymap[0x77] = KEY_END;
  183. keymap[0x78] = KEY_F2;
  184. keymap[0x79] = KEY_PAGEDOWN;
  185. keymap[0x7A] = KEY_F1;
  186. keymap[0x7B] = KEY_LEFT;
  187. keymap[0x7C] = KEY_RIGHT;
  188. keymap[0x7D] = KEY_DOWN;
  189. keymap[0x7E] = KEY_UP;
  190. // keymap[0x0A] = KEY_ISO_Section;
  191. // keymap[0x5D] = KEY_JIS_Yen;
  192. // keymap[0x5E] = KEY_JIS_Underscore;
  193. // keymap[0x5F] = KEY_JIS_KeypadComma;
  194. // keymap[0x66] = KEY_JIS_Eisu;
  195. // keymap[0x68] = KEY_JIS_Kana;
  196. }
  197. -(void) setCurrentCursor: (NSCursor*) newCursor
  198. {
  199. currentCursor = newCursor;
  200. }
  201. - (void)resetCursorRects
  202. {
  203. if(currentCursor)
  204. [self addCursorRect:[self bounds] cursor:currentCursor];
  205. }
  206. - (void) setCore: (CocoaCore*) newCore {
  207. [self initKeymap];
  208. core = newCore;
  209. }
  210. - (BOOL) lockFocusIfCanDraw {
  211. [contextLock lock];
  212. BOOL retVal = [super lockFocusIfCanDraw];
  213. [contextLock unlock];
  214. return retVal;
  215. }
  216. - (void) update {
  217. [contextLock lock];
  218. [super update];
  219. [contextLock unlock];
  220. }
  221. - (void) lockContext {
  222. [contextLock lock];
  223. }
  224. - (void) unlockContext {
  225. [contextLock unlock];
  226. }
  227. - (void)prepareOpenGL {
  228. contextReady = YES;
  229. }
  230. - (BOOL) isContextReady {
  231. return contextReady;
  232. }
  233. - (void)setOpenGLContext:(NSOpenGLContext *)context {
  234. contextReady = NO;
  235. [super setOpenGLContext:context];
  236. }
  237. - (BOOL)acceptsFirstResponder
  238. {
  239. return YES;
  240. }
  241. // ---------------------------------
  242. - (BOOL)becomeFirstResponder
  243. {
  244. return YES;
  245. }
  246. // ---------------------------------
  247. - (BOOL)resignFirstResponder
  248. {
  249. return YES;
  250. }
  251. - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent
  252. {
  253. return YES;
  254. }
  255. - (BOOL)mouseDownCanMoveWindow
  256. {
  257. return NO;
  258. }
  259. - (void) drawRect:(NSRect)rect {
  260. if(glSizeX != (int)[self frame].size.width || glSizeY != (int)[self frame].size.height) {
  261. glSizeX = (int)[self frame].size.width;
  262. glSizeY = (int)[self frame].size.height;
  263. if(core != NULL) {
  264. core->resizeTo(glSizeX, glSizeY);
  265. }
  266. }
  267. }
  268. -(void) windowResized: (NSNotification *) notification {
  269. }
  270. -(void) dealloc {
  271. [[NSNotificationCenter defaultCenter] removeObserver:self];
  272. [super dealloc];
  273. }
  274. - (void) resizeWithOldSuperviewSize: (NSSize) oldSize {
  275. [super resizeWithOldSuperviewSize: oldSize];
  276. // if(core == NULL)
  277. // return;
  278. // core->setVideoMode(oldSize.width, oldSize.height, core->isFullscreen(), core->getAALevel());
  279. }
  280. // INPUT
  281. - (void) otherMouseDown:(NSEvent *) event
  282. {
  283. if(core == NULL)
  284. return;
  285. core->lockMutex(core->eventMutex);
  286. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  287. CocoaEvent newEvent;
  288. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  289. newEvent.eventCode = InputEvent::EVENT_MOUSEDOWN;
  290. newEvent.mouseButton = CoreInput::MOUSE_BUTTON3;
  291. newEvent.mouseX = mouseLoc.x;
  292. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  293. core->cocoaEvents.push_back(newEvent);
  294. core->unlockMutex(core->eventMutex);
  295. }
  296. - (void) otherMouseUp:(NSEvent *) event
  297. {
  298. if(core == NULL)
  299. return;
  300. core->lockMutex(core->eventMutex);
  301. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  302. CocoaEvent newEvent;
  303. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  304. newEvent.eventCode = InputEvent::EVENT_MOUSEUP;
  305. newEvent.mouseButton = CoreInput::MOUSE_BUTTON3;
  306. newEvent.mouseX = mouseLoc.x;
  307. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  308. core->cocoaEvents.push_back(newEvent);
  309. core->unlockMutex(core->eventMutex);
  310. }
  311. - (void) rightMouseDown:(NSEvent *) event
  312. {
  313. if(core == NULL)
  314. return;
  315. core->lockMutex(core->eventMutex);
  316. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  317. CocoaEvent newEvent;
  318. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  319. newEvent.eventCode = InputEvent::EVENT_MOUSEDOWN;
  320. newEvent.mouseButton = CoreInput::MOUSE_BUTTON2;
  321. newEvent.mouseX = mouseLoc.x;
  322. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  323. core->cocoaEvents.push_back(newEvent);
  324. core->unlockMutex(core->eventMutex);
  325. }
  326. - (void) rightMouseUp:(NSEvent *) event
  327. {
  328. if(core == NULL)
  329. return;
  330. core->lockMutex(core->eventMutex);
  331. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  332. CocoaEvent newEvent;
  333. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  334. newEvent.eventCode = InputEvent::EVENT_MOUSEUP;
  335. newEvent.mouseButton = CoreInput::MOUSE_BUTTON2;
  336. newEvent.mouseX = mouseLoc.x;
  337. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  338. core->cocoaEvents.push_back(newEvent);
  339. core->unlockMutex(core->eventMutex);
  340. }
  341. - (void)scrollWheel:(NSEvent*) event {
  342. if(core == NULL || [event deltaY] == 0)
  343. return;
  344. core->lockMutex(core->eventMutex);
  345. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  346. CocoaEvent newEvent;
  347. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  348. if([event deltaY] > 0)
  349. newEvent.eventCode = InputEvent::EVENT_MOUSEWHEEL_UP;
  350. else
  351. newEvent.eventCode = InputEvent::EVENT_MOUSEWHEEL_DOWN;
  352. newEvent.mouseX = mouseLoc.x;
  353. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  354. core->cocoaEvents.push_back(newEvent);
  355. core->unlockMutex(core->eventMutex);
  356. }
  357. - (void) mouseDown:(NSEvent *) event
  358. {
  359. if(core == NULL)
  360. return;
  361. core->lockMutex(core->eventMutex);
  362. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  363. CocoaEvent newEvent;
  364. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  365. newEvent.eventCode = InputEvent::EVENT_MOUSEDOWN;
  366. newEvent.mouseButton = CoreInput::MOUSE_BUTTON1;
  367. newEvent.mouseX = mouseLoc.x;
  368. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  369. mouseX = mouseLoc.x;
  370. mouseY = mouseLoc.y;
  371. core->cocoaEvents.push_back(newEvent);
  372. core->unlockMutex(core->eventMutex);
  373. }
  374. - (void) mouseUp:(NSEvent *) event
  375. {
  376. if(core == NULL)
  377. return;
  378. core->lockMutex(core->eventMutex);
  379. NSPoint mouseLoc = [self convertPoint:[event locationInWindow] fromView:self];
  380. CocoaEvent newEvent;
  381. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  382. newEvent.eventCode = InputEvent::EVENT_MOUSEUP;
  383. newEvent.mouseButton = CoreInput::MOUSE_BUTTON1;
  384. newEvent.mouseX = mouseLoc.x;
  385. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  386. mouseX = mouseLoc.x;
  387. mouseY = mouseLoc.y;
  388. core->cocoaEvents.push_back(newEvent);
  389. core->unlockMutex(core->eventMutex);
  390. }
  391. - (void)flagsChanged:(NSEvent *)theEvent
  392. {
  393. if(core == NULL)
  394. return;
  395. // NSLog(@"KEY: %x\n", [theEvent keyCode]);
  396. if([theEvent keyCode] == 0) {
  397. return;
  398. }
  399. core->lockMutex(core->eventMutex);
  400. CocoaEvent newEvent;
  401. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  402. newEvent.keyCode = keymap[[theEvent keyCode]];
  403. if(modifierMap[[theEvent keyCode]] == 0) {
  404. modifierMap[[theEvent keyCode]] = 1;
  405. newEvent.eventCode = InputEvent::EVENT_KEYDOWN;
  406. } else {
  407. modifierMap[[theEvent keyCode]] = 0;
  408. newEvent.eventCode = InputEvent::EVENT_KEYUP;
  409. }
  410. newEvent.unicodeChar = 0;
  411. core->cocoaEvents.push_back(newEvent);
  412. core->unlockMutex(core->eventMutex);
  413. }
  414. - (void)keyDown: (NSEvent*) theEvent
  415. {
  416. if(core == NULL)
  417. return;
  418. core->lockMutex(core->eventMutex);
  419. CocoaEvent newEvent;
  420. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  421. newEvent.eventCode = InputEvent::EVENT_KEYDOWN;
  422. newEvent.keyCode = keymap[[theEvent keyCode]];
  423. NSString *chars = [theEvent characters];
  424. unsigned int numChars = [chars length];
  425. // NSLog(@"CHARS: %@", [chars characterAtIndex:0]);
  426. if(numChars > 0) {
  427. newEvent.unicodeChar = [chars characterAtIndex:0];
  428. } else {
  429. newEvent.unicodeChar = 0;
  430. }
  431. core->cocoaEvents.push_back(newEvent);
  432. core->unlockMutex(core->eventMutex);
  433. }
  434. - (void)keyUp: (NSEvent*) theEvent
  435. {
  436. if(core == NULL)
  437. return;
  438. core->lockMutex(core->eventMutex);
  439. NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:self];
  440. CocoaEvent newEvent;
  441. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  442. newEvent.eventCode = InputEvent::EVENT_KEYUP;
  443. newEvent.keyCode = keymap[[theEvent keyCode]];
  444. NSString *chars = [theEvent characters];
  445. unsigned int numChars = [chars length];
  446. if(numChars > 0)
  447. newEvent.unicodeChar = [chars characterAtIndex:0];
  448. else
  449. newEvent.unicodeChar = 0;
  450. core->cocoaEvents.push_back(newEvent);
  451. core->unlockMutex(core->eventMutex);
  452. }
  453. - (void)mouseDragged:(NSEvent *)theEvent
  454. {
  455. if(core == NULL)
  456. return;
  457. core->lockMutex(core->eventMutex);
  458. NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:self];
  459. CocoaEvent newEvent;
  460. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  461. newEvent.eventCode = InputEvent::EVENT_MOUSEMOVE;
  462. newEvent.mouseX = mouseLoc.x;
  463. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  464. core->cocoaEvents.push_back(newEvent);
  465. core->unlockMutex(core->eventMutex);
  466. }
  467. - (void)mouseMoved:(NSEvent *)theEvent
  468. {
  469. if(core == NULL)
  470. return;
  471. core->lockMutex(core->eventMutex);
  472. NSPoint mouseLoc = [self convertPoint:[theEvent locationInWindow] fromView:self];
  473. CocoaEvent newEvent;
  474. newEvent.eventGroup = CocoaEvent::INPUT_EVENT;
  475. newEvent.eventCode = InputEvent::EVENT_MOUSEMOVE;
  476. newEvent.mouseX = mouseLoc.x;
  477. newEvent.mouseY = core->getYRes() - mouseLoc.y;
  478. mouseX = mouseLoc.x;
  479. mouseY = mouseLoc.y;
  480. core->cocoaEvents.push_back(newEvent);
  481. core->unlockMutex(core->eventMutex);
  482. }
  483. @end