summaryrefslogtreecommitdiff
path: root/platform/osx
diff options
context:
space:
mode:
authormarcelofg55 <marcelofg55@gmail.com>2016-05-31 00:02:14 -0300
committermarcelofg55 <marcelofg55@gmail.com>2016-05-31 00:02:14 -0300
commitbb223869e0d016d372d8f3d98b3d5680cc069368 (patch)
treed4477915ce1d81d7f97c7a4fbf9dd23a21e5e069 /platform/osx
parent4d6d6fcbfc9cd7e37ad38bb83c05f9260e50d5bc (diff)
Key modifiers (Ctrl, Alt, Meta and Shift) may be used as Input keys now on OSX
Diffstat (limited to 'platform/osx')
-rw-r--r--platform/osx/os_osx.mm50
1 files changed, 39 insertions, 11 deletions
diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm
index b614dd57aa..7a174c233e 100644
--- a/platform/osx/os_osx.mm
+++ b/platform/osx/os_osx.mm
@@ -736,20 +736,48 @@ static int translateKey(unsigned int key)
- (void)flagsChanged:(NSEvent *)event
{
- /* int action;
- unsigned int newModifierFlags =
- [event modifierFlags] & NSDeviceIndependentModifierFlagsMask;
+ InputEvent ev;
+ int key = [event keyCode];
+ int mod = [event modifierFlags];
- if (newModifierFlags > window->ns.modifierFlags)
- action = GLFW_PRESS;
- else
- action = GLFW_RELEASE;
+ ev.type=InputEvent::KEY;
- window->ns.modifierFlags = newModifierFlags;
+ if (key == 0x36 || key == 0x37) {
+ if (mod & NSCommandKeyMask) {
+ mod&= ~NSCommandKeyMask;
+ ev.key.pressed = true;
+ } else {
+ ev.key.pressed = false;
+ }
+ } else if (key == 0x38 || key == 0x3c) {
+ if (mod & NSShiftKeyMask) {
+ mod&= ~NSShiftKeyMask;
+ ev.key.pressed = true;
+ } else {
+ ev.key.pressed = false;
+ }
+ } else if (key == 0x3a || key == 0x3d) {
+ if (mod & NSAlternateKeyMask) {
+ mod&= ~NSAlternateKeyMask;
+ ev.key.pressed = true;
+ } else {
+ ev.key.pressed = false;
+ }
+ } else if (key == 0x3b || key == 0x3e) {
+ if (mod & NSControlKeyMask) {
+ mod&= ~NSControlKeyMask;
+ ev.key.pressed = true;
+ } else {
+ ev.key.pressed = false;
+ }
+ } else {
+ return;
+ }
- const int key = translateKey([event keyCode]);
- const int mods = translateFlags([event modifierFlags]);
- _glfwInputKey(window, key, [event keyCode], action, mods);*/
+ ev.key.mod=translateFlags(mod);
+ ev.key.scancode = latin_keyboard_keycode_convert(translateKey(key));
+
+ OS_OSX::singleton->push_input(ev);
}
- (void)keyUp:(NSEvent *)event