Add function to deal with modifier state info
This commit is contained in:
parent
0009d2d1d0
commit
e114c6d700
28
keyboard.go
28
keyboard.go
@ -48,6 +48,34 @@ func Initialize (connection *xgbutil.XUtil) {
|
|||||||
modifierMasks.alt = KeysymToMask(0xffe9)
|
modifierMasks.alt = KeysymToMask(0xffe9)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Modifiers lists which modifier keys are toggled on or being pressed.
|
||||||
|
type Modifiers struct {
|
||||||
|
CapsLock bool
|
||||||
|
ShiftLock bool
|
||||||
|
NumLock bool
|
||||||
|
ModeSwitch bool
|
||||||
|
|
||||||
|
Alt bool
|
||||||
|
Meta bool
|
||||||
|
Super bool
|
||||||
|
Hyper bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// StateToModifiers converts a modifier state given by a keyboard or mouse event
|
||||||
|
// 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,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// KeysymToKeycode converts an X keysym to an X keycode, instead of the other
|
// KeysymToKeycode converts an X keysym to an X keycode, instead of the other
|
||||||
// way around.
|
// way around.
|
||||||
func KeysymToKeycode (
|
func KeysymToKeycode (
|
||||||
|
Loading…
Reference in New Issue
Block a user