mirror of
https://github.com/RoganDawes/P4wnP1_aloa.git
synced 2025-04-15 07:29:02 +02:00
Fixed LED state watcher to consider unknown initial state
This commit is contained in:
parent
4116893913
commit
055cb4e254
@ -32,6 +32,7 @@ type HIDKeyboardLEDStateWatcher struct {
|
||||
listeners *listenersmap
|
||||
listenerNonZeroCondLock *sync.Mutex
|
||||
listenerNonZeroCond *sync.Cond
|
||||
hasInitialSate bool
|
||||
}
|
||||
|
||||
type listenersmap struct {
|
||||
@ -149,6 +150,25 @@ func (watcher *HIDKeyboardLEDStateWatcher) dispatchListeners(state byte) {
|
||||
hasChanged = true
|
||||
}
|
||||
|
||||
if !watcher.hasInitialSate {
|
||||
//This is the first led state reported, so former state is undefined and we consider everything as a change
|
||||
watcher.ledState.NumLock = nNum
|
||||
watcher.ledState.CapsLock = nCaps
|
||||
watcher.ledState.ScrollLock = nScroll
|
||||
watcher.ledState.Compose = nCompose
|
||||
watcher.ledState.Kana = nKana
|
||||
|
||||
ledsChanged.NumLock = true
|
||||
ledsChanged.CapsLock = true
|
||||
ledsChanged.ScrollLock = true
|
||||
ledsChanged.Compose = true
|
||||
ledsChanged.Kana = true
|
||||
|
||||
hasChanged = true
|
||||
|
||||
watcher.hasInitialSate = true //don't do this again
|
||||
}
|
||||
|
||||
//check if we have listeners ready to remove
|
||||
rmList := make([]*HIDKeyboardLEDListener,0)
|
||||
for l,_ := range watcher.listeners.m {
|
||||
|
@ -80,8 +80,6 @@ func main() {
|
||||
}
|
||||
|
||||
|
||||
//keyboard, err := hid.NewKeyboard("/dev/hidg0", "keymaps")
|
||||
if err != nil { fmt.Println(err)}
|
||||
hidCtl.Keyboard.KeyDelay = 100
|
||||
// hidCtl.Keyboard.KeyDelayJitter = 200
|
||||
fmt.Printf("Available language maps:\n%v\n",hidCtl.Keyboard.ListLanguageMapNames())
|
||||
|
Loading…
x
Reference in New Issue
Block a user