wip adds automatic unshifting to kdenlive layout
This commit is contained in:
parent
9848f34d27
commit
b608f2cc28
|
@ -28,6 +28,12 @@ local k = _G.kdenlive or {} -- module
|
||||||
local mb = require "snippets/multibow"
|
local mb = require "snippets/multibow"
|
||||||
|
|
||||||
|
|
||||||
|
-- Unshift to primary keymap. For simplification, use it with the "anykey"
|
||||||
|
-- release handlers, see below.
|
||||||
|
function k.unshift()
|
||||||
|
mb.activate_keymap(k.keymap.name)
|
||||||
|
end
|
||||||
|
|
||||||
-- Key colors for unshifted and shifted keys; keep them rather muted in order
|
-- Key colors for unshifted and shifted keys; keep them rather muted in order
|
||||||
-- to not distract your video editing work.
|
-- to not distract your video editing work.
|
||||||
k.UNSHIFTED_COLOR = {r=0, g=1, b=0}
|
k.UNSHIFTED_COLOR = {r=0, g=1, b=0}
|
||||||
|
@ -40,6 +46,7 @@ k.keymap = {
|
||||||
k.keymap_shifted = {
|
k.keymap_shifted = {
|
||||||
name="kdenlive-shifted",
|
name="kdenlive-shifted",
|
||||||
secondary=true,
|
secondary=true,
|
||||||
|
[-1] = {release=k.unshift},
|
||||||
[6] = {c=k.SHIFTED_COLOR},
|
[6] = {c=k.SHIFTED_COLOR},
|
||||||
[3] = {c=k.SHIFTED_COLOR},
|
[3] = {c=k.SHIFTED_COLOR},
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ SOFTWARE.
|
||||||
-- their correct handlers, depending on which keyboard layout currently
|
-- their correct handlers, depending on which keyboard layout currently
|
||||||
-- is active.
|
-- is active.
|
||||||
function mb.route(keyno, pressed)
|
function mb.route(keyno, pressed)
|
||||||
local keydef, grabbed_any_keydef
|
local keydef, grabbed_any_keydef, anykdeydef
|
||||||
-- Checks for a keymap grab being enforced at this time...
|
-- Checks for a keymap grab being enforced at this time...
|
||||||
if mb.grab_keymap then
|
if mb.grab_keymap then
|
||||||
keydef = mb.grab_keymap[keyno]
|
keydef = mb.grab_keymap[keyno]
|
||||||
|
@ -40,13 +40,16 @@ function mb.route(keyno, pressed)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Checks for key in current keymap if no persistent key was found yet.
|
-- Checks for key in current keymap if no persistent key was found yet.
|
||||||
if not keydef and mb.current_keymap then
|
if not keydef then
|
||||||
keydef = mb.current_keymap[keyno]
|
if mb.current_keymap then
|
||||||
|
keydef = mb.current_keymap[keyno]
|
||||||
|
anykeydef = mb.current_keymap[-1]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Bails out if no key definition to route to could be found.
|
-- Bails out if no key definition to route to could be found.
|
||||||
if not (keydef or grabbed_any_keydef) then
|
if not (keydef or anykeydef or grabbed_any_keydef) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,6 +67,9 @@ function mb.route(keyno, pressed)
|
||||||
if keydef and keydef.press then
|
if keydef and keydef.press then
|
||||||
keydef.press(keyno)
|
keydef.press(keyno)
|
||||||
end
|
end
|
||||||
|
if anykeydef and anykeydef.press then
|
||||||
|
anykeydef.press(keyno)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
if grabbed_any_keydef and grabbed_any_keydef.release then
|
if grabbed_any_keydef and grabbed_any_keydef.release then
|
||||||
grabbed_any_keydef.release(keyno)
|
grabbed_any_keydef.release(keyno)
|
||||||
|
@ -71,7 +77,10 @@ function mb.route(keyno, pressed)
|
||||||
if keydef and keydef.release then
|
if keydef and keydef.release then
|
||||||
keydef.release(keyno)
|
keydef.release(keyno)
|
||||||
end
|
end
|
||||||
mb.activate_leds()
|
if anykeydef and anykeydef.release then
|
||||||
|
anykeydef.release(keyno)
|
||||||
|
end
|
||||||
|
mb.activate_leds()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -37,17 +37,23 @@ describe("Kdenlive keymap", function()
|
||||||
|
|
||||||
describe("with setup", function()
|
describe("with setup", function()
|
||||||
|
|
||||||
local hwk, mb, k
|
local mb, shift, k
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
mb = require("snippets/multibow")
|
mb = require("snippets/multibow")
|
||||||
require("layouts/shift")
|
shift = require("layouts/shift")
|
||||||
k = require("layouts/kdenlive")
|
k = require("layouts/kdenlive")
|
||||||
_G.setup()
|
_G.setup()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
inslit("", function()
|
inslit("", function()
|
||||||
assert.is.equal(k.keymap.name, mb.current_keymap.name)
|
assert.is.equal(k.keymap.name, mb.current_keymap.name)
|
||||||
|
hwk.tap(shift.KEY_SHIFT)
|
||||||
|
assert.is.equal(k.keymap_shifted.name, mb.current_keymap.name)
|
||||||
|
hwk.tap(0) -- FIXME
|
||||||
|
assert.is.equal(k.keymap.name, mb.current_keymap.name)
|
||||||
|
hwk.tap(shift.KEY_SHIFT)
|
||||||
|
assert.is.equal(k.keymap_shifted.name, mb.current_keymap.name)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue