From 8119511b10aa66da531634573cda6ba8a02fd7d2 Mon Sep 17 00:00:00 2001 From: Mikhail Kot Date: Mon, 14 Oct 2024 18:20:04 +0100 Subject: [PATCH] fix macos shift --- internal/state_machine/state_machine.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/internal/state_machine/state_machine.lua b/internal/state_machine/state_machine.lua index 9f271b70..25e3a171 100644 --- a/internal/state_machine/state_machine.lua +++ b/internal/state_machine/state_machine.lua @@ -102,6 +102,17 @@ local aliases = { [32813] = '', [32814] = '', } +local macos = reaper.GetOS():match "OS" +local macos_shift_fix = { + [51] = 35, --# + [52] = 36, --$ + [53] = 37, --% + [54] = 94, --^ + [55] = 38, --& + [56] = 42, --* + [57] = 40, --( + [48] = 41, --) +} local function ctxToState(ctx) local _, _, mod, code = ctx:find "^key:(.*):(.*)$" @@ -109,6 +120,11 @@ local function ctxToState(ctx) local alt = mod:match "A" and "M" or nil code = tonumber(code) or -1 + local macos_shift_res = macos_shift_fix[code] + if macos and virt and shift and macos_shift_res then + virt, shift, code = false, false, macos_shift_res + end + if 65 <= code and code <= 90 then -- Reaper always transmits uppercase letters local key = string.char(code + (shift and 0 or 32)) if not ctrl and not alt then return key end