init modifiers

This commit is contained in:
John Gebbie 2023-09-12 12:49:35 +01:00
parent 29f30ad52b
commit d5a6aeef74
2 changed files with 17 additions and 10 deletions

View file

@ -113,38 +113,38 @@ func parseChord(keymap *xkb.Keymap, chord string) (Chord, error) {
func (c *Chord) KeyDown(kb uinput.Keyboard) {
if c.Super {
log(kb.KeyDown(uinput.KeyLeftmeta))
log(kb.KeyDown(super))
}
if c.AltGr {
log(kb.KeyDown(84))
log(kb.KeyDown(altgr))
}
if c.Ctrl {
log(kb.KeyDown(uinput.KeyLeftctrl))
log(kb.KeyDown(ctrl))
}
if c.Alt {
log(kb.KeyDown(uinput.KeyLeftalt))
log(kb.KeyDown(alt))
}
if c.Shift {
log(kb.KeyDown(uinput.KeyLeftshift))
log(kb.KeyDown(shift))
}
log(kb.KeyDown(c.Key))
}
func (c *Chord) KeyUp(kb uinput.Keyboard) {
if c.Super {
log(kb.KeyUp(uinput.KeyLeftmeta))
log(kb.KeyUp(super))
}
if c.AltGr {
log(kb.KeyUp(84))
log(kb.KeyUp(altgr))
}
if c.Ctrl {
log(kb.KeyUp(uinput.KeyLeftctrl))
log(kb.KeyUp(ctrl))
}
if c.Alt {
log(kb.KeyUp(uinput.KeyLeftalt))
log(kb.KeyUp(alt))
}
if c.Shift {
log(kb.KeyUp(uinput.KeyLeftshift))
log(kb.KeyUp(shift))
}
log(kb.KeyUp(c.Key))
}

View file

@ -6,6 +6,8 @@ import (
"unicode"
)
var super, altgr, ctrl, alt, shift int
var LinuxKeys = map[string]Chord{
// Linux Only
"micmute": Chord{Key: uinput.KeyMicmute},
@ -641,6 +643,11 @@ func initKeys(keymap *xkb.Keymap) {
}
}
}
super = XKeys["Super_L"].Key
altgr = XKeys["ISO_Level3_Shift"].Key
ctrl = XKeys["Control_L"].Key
alt = XKeys["Alt_L"].Key
shift = XKeys["Shift_L"].Key
}
func getChord(keymap *xkb.Keymap, keysym uint32) Chord {