After commit c018f5fd29 Fenrir is being switched over to go. If you do not want to be part of the testing process, please switch to master.

This commit is contained in:
Storm Dragon committed 2026-10-27 20:30:55 -04:00
1 parent c018f5fd29
commit 0e50de4c76
1047 files changed
+58364 -63747

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
// Copyright (c) 2026 Storm Dragon
// SPDX-License-Identifier: GPL-3.0-or-later
package input
import (
"slices"
"git.stormux.org/storm/fenrir/internal/command"
)
// LearnKey describes a captured fresh press. Command is metadata only: it is
// never placed in Decision.Command and cannot launch an action or script.
type LearnKey struct {
Code uint16
Held []uint16
Command command.ID
Bare bool
}
func (r *Router) learn_key(device int, key uint16, numLock bool) *LearnKey {
pressed := &LearnKey{Code: key, Bare: r.empty()}
seen := map[uint16]bool{}
for _, held := range r.keys {
for code := range held {
seen[code] = true
}
}
for code := range seen {
pressed.Held = append(pressed.Held, code)
}
slices.Sort(pressed.Held)
id, scriptChord := r.script_binding(key, numLock)
if !scriptChord {
id = r.binding(key, numLock)
}
if !pure_modifier(key) && !reader_modifier(key, numLock) {
id = r.multi_press(device, r.binding_chord(key, numLock), id, scriptChord)
}
pressed.Command = id
return pressed
}