diff --git a/keyboard.go b/keyboard.go index dd06324..c355289 100644 --- a/keyboard.go +++ b/keyboard.go @@ -54,11 +54,13 @@ type Modifiers struct { ShiftLock bool NumLock bool ModeSwitch bool - - Alt bool - Meta bool - Super bool - Hyper bool + + Shift bool + Control bool + Alt bool + Meta bool + Super bool + Hyper bool } // String returns a human-readable comma-separated list of all active modifiers. @@ -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, } }