From 9b4b3f9568340bd74b2f4c7b0ccd8bc8a9485eca Mon Sep 17 00:00:00 2001 From: Mikhail Kot Date: Mon, 14 Oct 2024 18:36:40 +0100 Subject: [PATCH] fix macos shift (#79) --- Scripts/install-reaper-keys.lua | 2 +- internal/state_machine/state_machine.lua | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Scripts/install-reaper-keys.lua b/Scripts/install-reaper-keys.lua index a6fb4d76..538b59fa 100644 --- a/Scripts/install-reaper-keys.lua +++ b/Scripts/install-reaper-keys.lua @@ -1,5 +1,5 @@ -- @description reaper-keys: map keystroke combinations to actions like in vim --- @version 2.0.0-a6 +-- @version 2.0.0-a7 -- @author gwatcha -- @links -- GitHub repository https://github.com/gwatcha/reaper-keys 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