aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-11-11 11:57:04 -0500
committerDavid Robillard <d@drobilla.net>2023-11-11 12:28:16 -0500
commit633c151e08a8e2ce81eb5512b7c1f9baa4c44c04 (patch)
treed8745632a4802295f4f3b080644b6fc3756865c1
parente3f81660f60b741e2a71cfdb1307be84232c26a5 (diff)
downloadpugl-633c151e08a8e2ce81eb5512b7c1f9baa4c44c04.tar.gz
pugl-633c151e08a8e2ce81eb5512b7c1f9baa4c44c04.tar.bz2
pugl-633c151e08a8e2ce81eb5512b7c1f9baa4c44c04.zip
MacOS: Support left/right shift, control, and option keys
-rw-r--r--src/mac.m10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mac.m b/src/mac.m
index dcc2ee3..8a89b18 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -15,6 +15,7 @@
#include <mach/mach_time.h>
+#include <stdint.h>
#include <stdlib.h>
#ifndef __MAC_10_10
@@ -842,19 +843,20 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
PuglEventType type = PUGL_NOTHING;
PuglKey special = (PuglKey)0;
+ const uint16_t keyCode = [event keyCode];
if ((mods & PUGL_MOD_SHIFT) != (puglview->impl->mods & PUGL_MOD_SHIFT)) {
type = mods & PUGL_MOD_SHIFT ? PUGL_KEY_PRESS : PUGL_KEY_RELEASE;
- special = PUGL_KEY_SHIFT_L;
+ special = (keyCode == 0x3C) ? PUGL_KEY_SHIFT_R : PUGL_KEY_SHIFT_L;
} else if ((mods & PUGL_MOD_CTRL) != (puglview->impl->mods & PUGL_MOD_CTRL)) {
type = mods & PUGL_MOD_CTRL ? PUGL_KEY_PRESS : PUGL_KEY_RELEASE;
- special = PUGL_KEY_CTRL_L;
+ special = (keyCode == 0x3E) ? PUGL_KEY_CTRL_R : PUGL_KEY_CTRL_L;
} else if ((mods & PUGL_MOD_ALT) != (puglview->impl->mods & PUGL_MOD_ALT)) {
type = mods & PUGL_MOD_ALT ? PUGL_KEY_PRESS : PUGL_KEY_RELEASE;
- special = PUGL_KEY_ALT_L;
+ special = (keyCode == 0x3D) ? PUGL_KEY_ALT_R : PUGL_KEY_ALT_L;
} else if ((mods & PUGL_MOD_SUPER) !=
(puglview->impl->mods & PUGL_MOD_SUPER)) {
type = mods & PUGL_MOD_SUPER ? PUGL_KEY_PRESS : PUGL_KEY_RELEASE;
- special = PUGL_KEY_SUPER_L;
+ special = PUGL_KEY_SUPER_L; // Left and right command are identical
}
if (special != 0) {