Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

You can add a second layer #176

Open
VanilleUwU opened this issue Feb 10, 2024 · 1 comment
Open

You can add a second layer #176

VanilleUwU opened this issue Feb 10, 2024 · 1 comment

Comments

@VanilleUwU
Copy link

VanilleUwU commented Feb 10, 2024

Not an issue but maybe a lifesaver :)

-- Assign logical name to macro keyboard
lmc_assign_keyboard('MACROS')

-- Define current active layer
local currentLayer = 1

-- Define keybindings for each layer
local layers = {
{
-- Layer 1: Default layer
['A'] = function() lmc_spawn("C:/Path/To/Application.exe") end,
['B'] = function() lmc_spawn("C:/Another/Path/To/Application.exe") end,
['C'] = function() lmc_spawn("C:/Yet/Another/Path/To/Application.exe") end,
['D'] = function() lmc_spawn("C:/One/More/Path/To/Application.exe") end,
},
{
-- Layer 2: Secondary layer
['E'] = function() lmc_spawn("C:/Path/To/Application.exe") end,
['F'] = function() lmc_spawn("C:/Another/Path/To/Application.exe") end,
['G'] = function() lmc_spawn("C:/Yet/Another/Path/To/Application.exe") end,
['H'] = function() lmc_spawn("C:/One/More/Path/To/Application.exe") end,
},
}

-- Define callback for whole device
lmc_set_handler('MACROS', function(button, direction)
if (direction == 1) then return end -- ignore key down events

if (button == 13) then -- Enter key on numpad
    switchLayer()
else
    local action = layers[currentLayer][string.char(button)]
    if action then
        action()
    else
        print('Not yet assigned: ' .. string.char(button))
    end
end

end)

-- Function to switch to the next layer
function switchLayer()
currentLayer = currentLayer % #layers + 1
print('Switched to layer ' .. currentLayer)
end

@VanilleUwU
Copy link
Author

wierd format Github but okey

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant