diff options
author | David Robillard <d@drobilla.net> | 2023-11-11 11:57:04 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-11-11 12:28:16 -0500 |
commit | 633c151e08a8e2ce81eb5512b7c1f9baa4c44c04 (patch) | |
tree | d8745632a4802295f4f3b080644b6fc3756865c1 /src | |
parent | e3f81660f60b741e2a71cfdb1307be84232c26a5 (diff) | |
download | pugl-633c151e08a8e2ce81eb5512b7c1f9baa4c44c04.tar.gz pugl-633c151e08a8e2ce81eb5512b7c1f9baa4c44c04.tar.bz2 pugl-633c151e08a8e2ce81eb5512b7c1f9baa4c44c04.zip |
MacOS: Support left/right shift, control, and option keys
Diffstat (limited to 'src')
-rw-r--r-- | src/mac.m | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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) { |