I forgor about shift and ctrl
This commit is contained in:
parent
aa46cada1f
commit
fc8a34ab07
36
keyboard.go
36
keyboard.go
@ -55,6 +55,8 @@ type Modifiers struct {
|
||||
NumLock bool
|
||||
ModeSwitch bool
|
||||
|
||||
Shift bool
|
||||
Control bool
|
||||
Alt bool
|
||||
Meta bool
|
||||
Super bool
|
||||
@ -69,14 +71,16 @@ func (modifiers Modifiers) String () (out string) {
|
||||
}
|
||||
out += name
|
||||
}
|
||||
if modifiers.Hyper { add("Hyper") }
|
||||
if modifiers.Super { add("Super") }
|
||||
if modifiers.Meta { add("Meta") }
|
||||
if modifiers.Alt { add("Alt") }
|
||||
if modifiers.ModeSwitch { add("ModeSwitch") }
|
||||
if modifiers.NumLock { add("NumLock") }
|
||||
if modifiers.ShiftLock { add("ShiftLock") }
|
||||
if modifiers.CapsLock { add("CapsLock") }
|
||||
if modifiers.ShiftLock { add("ShiftLock") }
|
||||
if modifiers.NumLock { add("NumLock") }
|
||||
if modifiers.ModeSwitch { add("ModeSwitch") }
|
||||
if modifiers.Shift { add("Shift") }
|
||||
if modifiers.Control { add("Control") }
|
||||
if modifiers.Alt { add("Alt") }
|
||||
if modifiers.Meta { add("Meta") }
|
||||
if modifiers.Super { add("Super") }
|
||||
if modifiers.Hyper { add("Hyper") }
|
||||
return
|
||||
}
|
||||
|
||||
@ -84,14 +88,16 @@ func (modifiers Modifiers) String () (out string) {
|
||||
// to a Modifiers struct.
|
||||
func StateToModifiers (state uint16) Modifiers {
|
||||
return Modifiers {
|
||||
CapsLock: 0 < state & modifierMasks.capsLock,
|
||||
ShiftLock: 0 < state & modifierMasks.shiftLock,
|
||||
NumLock: 0 < state & modifierMasks.numLock,
|
||||
ModeSwitch: 0 < state & modifierMasks.modeSwitch,
|
||||
Alt: 0 < state & modifierMasks.alt,
|
||||
Meta: 0 < state & modifierMasks.meta,
|
||||
Super: 0 < state & modifierMasks.super,
|
||||
Hyper: 0 < state & modifierMasks.hyper,
|
||||
CapsLock: (state & modifierMasks.capsLock) > 0,
|
||||
ShiftLock: (state & modifierMasks.shiftLock) > 0,
|
||||
NumLock: (state & modifierMasks.numLock) > 0,
|
||||
ModeSwitch: (state & modifierMasks.modeSwitch) > 0,
|
||||
Shift: (state & xproto.ModMaskShift) > 0,
|
||||
Control: (state & xproto.ModMaskControl) > 0,
|
||||
Alt: (state & modifierMasks.alt) > 0,
|
||||
Meta: (state & modifierMasks.meta) > 0,
|
||||
Super: (state & modifierMasks.super) > 0,
|
||||
Hyper: (state & modifierMasks.hyper) > 0,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user