Default laptop key set to capslock. Keys that can be set to fenrir key or script key selectable via checkbox.
This commit is contained in:
1 parent
47f18fdd28
commit
15e04aa8f8
47 files changed
+1560
-351
No files matched your search
@@ -79,25 +79,16 @@ func Script_chord(keys []string) string {
|
||||
}
|
||||
|
||||
func (r *Router) Configure_scripts(keys []string, bindings []ScriptBinding) error {
|
||||
r.scriptKeys = make(map[uint16]bool)
|
||||
r.scriptBindings = make(map[string]command.ID)
|
||||
for _, name := range keys {
|
||||
code, ok := Key_code(name)
|
||||
if !ok {
|
||||
return fmt.Errorf("invalid script key %q", name)
|
||||
}
|
||||
r.scriptKeys[code] = true
|
||||
switch strings.ToUpper(name) {
|
||||
case "KEY_CTRL":
|
||||
r.scriptKeys[KeyRightCtrl] = true
|
||||
case "KEY_SHIFT":
|
||||
r.scriptKeys[KeyRightShift] = true
|
||||
case "KEY_ALT":
|
||||
r.scriptKeys[KeyRightAlt] = true
|
||||
case "KEY_META":
|
||||
r.scriptKeys[KeyRightMeta] = true
|
||||
scriptKeys, err := Modifier_codes(keys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for code := range scriptKeys {
|
||||
if r.reader_modifier(code, false) {
|
||||
return fmt.Errorf("%s cannot be both a Fenrir key and a script key", Key_name(code))
|
||||
}
|
||||
}
|
||||
scriptBindings := make(map[string]command.ID)
|
||||
for _, binding := range bindings {
|
||||
if binding.ID == "" {
|
||||
return fmt.Errorf("script binding has no command")
|
||||
@@ -108,11 +99,12 @@ func (r *Router) Configure_scripts(keys []string, bindings []ScriptBinding) erro
|
||||
}
|
||||
}
|
||||
chord := Script_chord(binding.Keys)
|
||||
if _, exists := r.scriptBindings[chord]; exists {
|
||||
if _, exists := scriptBindings[chord]; exists {
|
||||
return fmt.Errorf("duplicate script shortcut %s", chord)
|
||||
}
|
||||
r.scriptBindings[chord] = binding.ID
|
||||
scriptBindings[chord] = binding.ID
|
||||
}
|
||||
r.scriptKeys, r.scriptBindings = scriptKeys, scriptBindings
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -138,10 +130,10 @@ func (r *Router) script_name(key uint16, numLock bool) string {
|
||||
case KeyRightMeta:
|
||||
key = KeyMeta
|
||||
}
|
||||
if r.scriptKeys[physical] {
|
||||
if r.script_modifier(physical, numLock) {
|
||||
return "KEY_SCRIPT"
|
||||
}
|
||||
if reader_modifier(key, numLock) {
|
||||
if r.reader_modifier(physical, numLock) {
|
||||
return "KEY_FENRIR"
|
||||
}
|
||||
switch key {
|
||||
@@ -160,10 +152,10 @@ func (r *Router) script_name(key uint16, numLock bool) string {
|
||||
}
|
||||
|
||||
func (r *Router) script_binding(key uint16, numLock bool) (command.ID, bool) {
|
||||
active := r.scriptKeys[key]
|
||||
active := r.script_modifier(key, numLock)
|
||||
if !active {
|
||||
for scriptKey := range r.scriptKeys {
|
||||
if r.down(scriptKey) {
|
||||
if r.script_modifier(scriptKey, numLock) && r.down(scriptKey) {
|
||||
active = true
|
||||
break
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user