Harald Albrecht
5 years ago
6 changed files with 253 additions and 13 deletions
@ -0,0 +1,69 @@ |
|||
-- An empty Multibow Keybow layout. Useful for "switching off" any active |
|||
-- keymaps, with only the permanent keymaps (SHIFT, etc) being still in place. |
|||
|
|||
--[[ |
|||
Copyright 2019 Harald Albrecht |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all |
|||
copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|||
SOFTWARE. |
|||
]]-- |
|||
|
|||
local km = {} -- module |
|||
|
|||
local mb = require("snippets/multibow") |
|||
|
|||
--[[ |
|||
The Keybow layout is as follows when in landscape orientation, with the USB |
|||
cable going off "northwards": |
|||
|
|||
┋┋ |
|||
┌╌╌╌╌┐ ┌╌╌╌╌┐ ┌╌╌╌╌┐ ┌╌╌╌╌┐ |
|||
┊ 11 ┊ ┊ 8 ┊ ┊ 7 ┊ ┊ 6 ┊ |
|||
└╌╌╌╌┘ └╌╌╌╌┘ └╌╌╌╌┘ └╌╌╌╌┘ |
|||
┌╌╌╌╌┐ ┌╌╌╌╌┐ ┌╌╌╌╌┐ ┌╌╌╌╌┐ |
|||
┊ 10 ┊ ┊ 7 ┊ ┊ 4 ┊ ┊ 1 ┊ |
|||
└╌╌╌╌┘ └╌╌╌╌┘ └╌╌╌╌┘ └╌╌╌╌┘ |
|||
┌╌╌╌╌┐ ┌╌╌╌╌┐ ┌╌╌╌╌┐ ┌╌╌╌╌┐ |
|||
┊ 9 ┊ ┊ 6 ┊ ┊ 3 ┊ ┊ 0 ┊ |
|||
└╌╌╌╌┘ └╌╌╌╌┘ └╌╌╌╌┘ └╌╌╌╌┘ |
|||
|
|||
]]-- |
|||
|
|||
-- Some action on a certain key press... |
|||
function km.mypress(keyno) |
|||
end |
|||
|
|||
-- Some action on a certain key release... |
|||
function km.myrelease(keyno) |
|||
end |
|||
|
|||
-- The keymap layout... |
|||
km.keymap = { |
|||
-- IMPORTANT: Make sure to change the keymap name to make it unique! |
|||
name="keymap-template", |
|||
|
|||
-- The index entries below are defining keys as to their LED color and |
|||
-- what key taps should be send to the USB host to which your Keybow is |
|||
-- connected to. |
|||
[0] = { c={r=1, g=1, b=1}, press=function() mb.tap("a") end}, |
|||
[1] = { c={r=1, g=1, b=1}, press=km.mypress}, |
|||
[2] = { c={r=1, g=1, b=1}, release=km.myrelease}, |
|||
} |
|||
mb.register_keymap(km.keymap) |
|||
|
|||
return km -- module |
@ -0,0 +1,55 @@ |
|||
--[[ |
|||
Copyright 2019 Harald Albrecht |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all |
|||
copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|||
SOFTWARE. |
|||
]]-- |
|||
|
|||
require "mocked-keybow" |
|||
|
|||
describe("template multibow keymap", function() |
|||
|
|||
local mb = require("snippets/multibow") |
|||
local hwk = require("spec/hwkeys") |
|||
local kmt = require("layouts/keymap-template") |
|||
|
|||
inslit("installs a single primary keymap", function() |
|||
assert.is_not_nil(kmt) -- we're going over the top here... |
|||
assert.is_not_nil(kmt.keymap) -- ...even more so. |
|||
|
|||
-- empty must register exactly one keymap, and it must be |
|||
-- a primary keymap, not permanent or secondary. |
|||
local kms = mb.registered_keymaps() |
|||
assert.is.equal(1, #kms) |
|||
local keymap = kms[1] |
|||
assert.is_falsy(keymap.permanent) |
|||
assert.is_falsy(keymap.secondary) |
|||
end) |
|||
|
|||
|
|||
inslit("calls press and release handlers", function() |
|||
local mp = spy.on(kmt.keymap[1], "press") |
|||
local mr = spy.on(kmt.keymap[2], "release") |
|||
|
|||
hwk.tap(1) |
|||
assert.spy(mp).was.called(1) |
|||
hwk.tap(2) |
|||
assert.spy(mr).was.called(1) |
|||
end) |
|||
|
|||
end) |
Loading…
Reference in new issue