From 633c151e08a8e2ce81eb5512b7c1f9baa4c44c04 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 11 Nov 2023 11:57:04 -0500 Subject: MacOS: Support left/right shift, control, and option keys --- src/mac.m | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') 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 +#include #include #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) { -- cgit v1.2.1