Initial support for application specific overrides.
This commit is contained in:
1 parent
901fd58ba8
commit
b45f800489
37 files changed
+3909
-475
No files matched your search
@@ -0,0 +1,48 @@
|
||||
// Copyright (c) 2026 Storm Dragon
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
package input
|
||||
|
||||
import (
|
||||
"git.stormux.org/storm/fenrir/internal/command"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestApplicationsChordConsumesRepeatsAndBothReleaseOrders(t *testing.T) {
|
||||
for _, layout := range []string{"desktop", "laptop"} {
|
||||
bindings, _, err := Load_bindings([]string{"../../config/keyboard/" + layout + ".toml"})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, numLock := range []bool{false, true} {
|
||||
for _, modifierFirst := range []bool{false, true} {
|
||||
r, err := New_router(bindings)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
r.Key(0, KeyInsert, 1, numLock, false)
|
||||
if got := r.Key(0, 30, 1, numLock, false); got.Command != command.ApplicationsMenu || got.Forward {
|
||||
t.Fatal(got)
|
||||
}
|
||||
if got := r.Key(0, 30, 2, numLock, false); got.Command != "" || got.Forward {
|
||||
t.Fatal(got)
|
||||
}
|
||||
releases := []uint16{30, KeyInsert}
|
||||
if modifierFirst {
|
||||
releases = []uint16{KeyInsert, 30}
|
||||
}
|
||||
for _, key := range releases {
|
||||
if got := r.Key(0, key, 0, numLock, false); got.Forward || got.Command != "" {
|
||||
t.Fatal(got)
|
||||
}
|
||||
}
|
||||
if r.Held(0) {
|
||||
t.Fatal("held applications chord")
|
||||
}
|
||||
if got := r.Key(0, 48, 1, numLock, false); !got.Forward || got.Code != 48 {
|
||||
t.Fatal("subsequent application input", got)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ func TestAttributeBindingsNumLockRepeatsAndRelease(t *testing.T) {
|
||||
if layout == "laptop" {
|
||||
code = 30
|
||||
router.Key(0, KeyInsert, 1, numLock, false)
|
||||
router.Key(0, KeyShift, 1, numLock, false)
|
||||
}
|
||||
for range 2 {
|
||||
got := router.Key(0, code, 1, numLock, false)
|
||||
@@ -45,6 +46,9 @@ func TestAttributeBindingsNumLockRepeatsAndRelease(t *testing.T) {
|
||||
if !modifierFirst && layout == "laptop" {
|
||||
router.Key(0, KeyInsert, 0, numLock, false)
|
||||
}
|
||||
if layout == "laptop" {
|
||||
router.Key(0, KeyShift, 0, numLock, false)
|
||||
}
|
||||
if router.Held(0) {
|
||||
t.Fatal("stuck attributes chord", layout)
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ const (
|
||||
)
|
||||
|
||||
type Decision struct {
|
||||
Code uint16 // physical key code, for forwarded application press/repeat hooks
|
||||
Forward bool
|
||||
Interrupt bool
|
||||
Keypress bool // a fresh physical press, excluding repeats and state repair
|
||||
@@ -191,7 +192,7 @@ func (r *Router) key(device int, key uint16, value int32, numLock, syncEvent, re
|
||||
}
|
||||
if state.forwarded {
|
||||
typing := !syncEvent && r.typing_key(key, numLock)
|
||||
return Decision{Forward: true, Deletion: !syncEvent && deletion_key(key, numLock), Typing: typing, WordBoundary: typing && key == KeySpace, Interrupt: !syncEvent && !pure_modifier(key)}
|
||||
return Decision{Code: key, Forward: true, Deletion: !syncEvent && deletion_key(key, numLock), Typing: typing, WordBoundary: typing && key == KeySpace, Interrupt: !syncEvent && !pure_modifier(key)}
|
||||
}
|
||||
commandID := state.commandID
|
||||
if value == 2 && repeatable(commandID) && !syncEvent {
|
||||
@@ -237,7 +238,7 @@ func (r *Router) key(device int, key uint16, value int32, numLock, syncEvent, re
|
||||
return Decision{Forward: forwarded}
|
||||
}
|
||||
typing := forwarded && r.typing_key(key, numLock)
|
||||
return Decision{Keypress: true, Deletion: forwarded && deletion_key(key, numLock), Typing: typing, WordBoundary: typing && key == KeySpace, Forward: forwarded, Command: commandID, Interrupt: commandID != "" || forwarded && (!pure_modifier(key) || key == KeyCtrl || key == KeyRightCtrl)}
|
||||
return Decision{Code: key, Keypress: true, Deletion: forwarded && deletion_key(key, numLock), Typing: typing, WordBoundary: typing && key == KeySpace, Forward: forwarded, Command: commandID, Interrupt: commandID != "" || forwarded && (!pure_modifier(key) || key == KeyCtrl || key == KeyRightCtrl)}
|
||||
}
|
||||
|
||||
func (r *Router) typing_key(key uint16, numLock bool) bool {
|
||||
|
||||
Reference in new issue
Block a user