map keys and handle key events on Android and OS X

This commit is contained in:
2017-04-17 19:35:48 +02:00
parent 54082591f1
commit 45cf8c9168
11 changed files with 595 additions and 68 deletions

View File

@@ -5,6 +5,7 @@
#include "texture.h"
#include "image.h"
#include "app.h"
#include "keymap.h"
#ifdef __APPLE__
#include <CoreFoundation/CoreFoundation.h>
@@ -252,6 +253,22 @@ static CVReturn MyDisplayLinkCallback(CVDisplayLinkRef displayLink, const CVTime
App::I.mouse_scroll(mouseLoc.x, App::I.height - mouseLoc.y - 1, [theEvent deltaY]);
CGLUnlockContext([[self openGLContext] CGLContextObj]);
}
- (void)keyDown:(NSEvent *)theEvent
{
CGLLockContext([[self openGLContext] CGLContextObj]);
auto keyCode = [theEvent keyCode];
auto chars = [theEvent characters];
App::I.key_down(convert_key(keyCode));
CGLUnlockContext([[self openGLContext] CGLContextObj]);
}
- (void)keyUp:(NSEvent *)theEvent
{
CGLLockContext([[self openGLContext] CGLContextObj]);
auto keyCode = [theEvent keyCode];
auto chars = [theEvent characters];
App::I.key_up(convert_key(keyCode));
CGLUnlockContext([[self openGLContext] CGLContextObj]);
}
@end
@interface Window : NSWindow