Skip to content

Commit

Permalink
fix macos shift (#79)
Browse files Browse the repository at this point in the history
  • Loading branch information
myrrc authored Oct 14, 2024
1 parent ddf0b74 commit 9b4b3f9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Scripts/install-reaper-keys.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 16 additions & 0 deletions internal/state_machine/state_machine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,29 @@ local aliases = {
[32813] = '<INS>',
[32814] = '<DEL>',
}
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:(.*):(.*)$"
local virt, ctrl, shift = mod:match "V", mod:match "C", mod:match "S"
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
Expand Down

0 comments on commit 9b4b3f9

Please # to comment.