aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-05-27 23:49:08 -0400
committerDavid Robillard <d@drobilla.net>2023-05-29 20:07:29 -0400
commitfc1e6c60efcaaa9adce721441f842fd293e3d65f (patch)
tree47e5155c38212a65f8976a0dba3a3c80c246b134
parent6c41747975d22f35342791dbeb595d2a08f0950b (diff)
downloadpugl-fc1e6c60efcaaa9adce721441f842fd293e3d65f.tar.gz
pugl-fc1e6c60efcaaa9adce721441f842fd293e3d65f.tar.bz2
pugl-fc1e6c60efcaaa9adce721441f842fd293e3d65f.zip
Deprecate redundant key symbols
-rw-r--r--include/pugl/pugl.h20
-rw-r--r--src/mac.m8
-rw-r--r--src/win.c10
3 files changed, 21 insertions, 17 deletions
diff --git a/include/pugl/pugl.h b/include/pugl/pugl.h
index 9d29ed8..481754b 100644
--- a/include/pugl/pugl.h
+++ b/include/pugl/pugl.h
@@ -370,17 +370,13 @@ typedef enum {
PUGL_KEY_HOME,
PUGL_KEY_END,
PUGL_KEY_INSERT,
- PUGL_KEY_SHIFT,
- PUGL_KEY_SHIFT_L = PUGL_KEY_SHIFT,
+ PUGL_KEY_SHIFT_L,
PUGL_KEY_SHIFT_R,
- PUGL_KEY_CTRL,
- PUGL_KEY_CTRL_L = PUGL_KEY_CTRL,
+ PUGL_KEY_CTRL_L,
PUGL_KEY_CTRL_R,
- PUGL_KEY_ALT,
- PUGL_KEY_ALT_L = PUGL_KEY_ALT,
+ PUGL_KEY_ALT_L,
PUGL_KEY_ALT_R,
- PUGL_KEY_SUPER,
- PUGL_KEY_SUPER_L = PUGL_KEY_SUPER,
+ PUGL_KEY_SUPER_L,
PUGL_KEY_SUPER_R,
PUGL_KEY_MENU,
PUGL_KEY_CAPS_LOCK,
@@ -2142,6 +2138,14 @@ puglRequestAttention(PuglView* view)
puglGetViewStyle(view) | PUGL_VIEW_STYLE_DEMANDING);
}
+# define PUGL_KEY_SHIFT PUGL_KEY_SHIFT_L
+
+# define PUGL_KEY_CTRL PUGL_KEY_CTRL_L
+
+# define PUGL_KEY_ALT PUGL_KEY_ALT_L
+
+# define PUGL_KEY_SUPER PUGL_KEY_SUPER_L
+
#endif // PUGL_DISABLE_DEPRECATED
/**
diff --git a/src/mac.m b/src/mac.m
index 1683a05..ce90b9a 100644
--- a/src/mac.m
+++ b/src/mac.m
@@ -825,17 +825,17 @@ handleCrossing(PuglWrapperView* view, NSEvent* event, const PuglEventType type)
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;
+ special = 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;
+ special = 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;
+ special = 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;
+ special = PUGL_KEY_SUPER_L;
}
if (special != 0) {
diff --git a/src/win.c b/src/win.c
index 93d9eef..ed78baa 100644
--- a/src/win.c
+++ b/src/win.c
@@ -403,7 +403,7 @@ puglFreeWorldInternals(PuglWorld* world)
}
static PuglKey
-keySymToSpecial(WPARAM sym)
+keySymToSpecial(const WPARAM sym, const bool ext)
{
// clang-format off
switch (sym) {
@@ -430,13 +430,13 @@ keySymToSpecial(WPARAM sym)
case VK_HOME: return PUGL_KEY_HOME;
case VK_END: return PUGL_KEY_END;
case VK_INSERT: return PUGL_KEY_INSERT;
- case VK_SHIFT:
+ case VK_SHIFT: return ext ? PUGL_KEY_SHIFT_L : PUGL_KEY_SHIFT_R;
case VK_LSHIFT: return PUGL_KEY_SHIFT_L;
case VK_RSHIFT: return PUGL_KEY_SHIFT_R;
- case VK_CONTROL:
+ case VK_CONTROL: return ext ? PUGL_KEY_CTRL_L : PUGL_KEY_CTRL_R;
case VK_LCONTROL: return PUGL_KEY_CTRL_L;
case VK_RCONTROL: return PUGL_KEY_CTRL_R;
- case VK_MENU:
+ case VK_MENU: return ext ? PUGL_KEY_ALT_L : PUGL_KEY_ALT_R;
case VK_LMENU: return PUGL_KEY_ALT_L;
case VK_RMENU: return PUGL_KEY_ALT_R;
case VK_LWIN: return PUGL_KEY_SUPER_L;
@@ -563,7 +563,7 @@ initKeyEvent(PuglKeyEvent* event,
const PuglKey special = keySymToSpecial(vkey);
if (special) {
- if (ext && (special == PUGL_KEY_CTRL || special == PUGL_KEY_ALT)) {
+ if (ext && (special == PUGL_KEY_CTRL_L || special == PUGL_KEY_ALT_L)) {
event->key = (uint32_t)special + 1U; // Right hand key
} else {
event->key = (uint32_t)special;