TaranVH / 2nd-keyboard

ALL of Taran's scripts - not just for the 2nd keyboard.
https://www.youtube.com/watch?v=O6ERELse_QY
1.65k stars 538 forks source link

You can add a second layer #176

Open VanilleUwU opened 4 months ago

VanilleUwU commented 4 months ago

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 commented 4 months ago

wierd format Github but okey