Skip to content

Commit

Permalink
fix macos shift
Browse files Browse the repository at this point in the history
  • Loading branch information
myrrc committed Oct 14, 2024
1 parent ddf0b74 commit 8119511
Showing 1 changed file with 16 additions and 0 deletions.
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 8119511

Please sign in to comment.