Slaves forward configured tap kinds to the master; goTool exposes CLI, dashboard, REST, and WebSocket with separate notify vs receive and 2s display cache. Co-authored-by: Cursor <cursoragent@cursor.com>
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
package main
|
|
|
|
import "sync"
|
|
|
|
// tapNotifyCtl tracks which slaves have tap notify enabled (mirrors firmware / dashboard).
|
|
type tapNotifyCtl struct {
|
|
mu sync.Mutex
|
|
flags map[uint32]tapNotifyFlags
|
|
}
|
|
|
|
type tapNotifyFlags struct {
|
|
single bool
|
|
doubleTap bool
|
|
triple bool
|
|
}
|
|
|
|
func newTapNotifyCtl() *tapNotifyCtl {
|
|
return &tapNotifyCtl{flags: make(map[uint32]tapNotifyFlags)}
|
|
}
|
|
|
|
func (c *tapNotifyCtl) Set(clientID uint32, single, doubleTap, triple bool) {
|
|
c.mu.Lock()
|
|
defer c.mu.Unlock()
|
|
if !single && !doubleTap && !triple {
|
|
delete(c.flags, clientID)
|
|
return
|
|
}
|
|
c.flags[clientID] = tapNotifyFlags{single: single, doubleTap: doubleTap, triple: triple}
|
|
}
|
|
|
|
func (c *tapNotifyCtl) Any() bool {
|
|
c.mu.Lock()
|
|
defer c.mu.Unlock()
|
|
return len(c.flags) > 0
|
|
}
|
|
|
|
func (c *tapNotifyCtl) SyncFromClients(clients []ClientView) {
|
|
c.mu.Lock()
|
|
defer c.mu.Unlock()
|
|
c.flags = make(map[uint32]tapNotifyFlags)
|
|
for _, cl := range clients {
|
|
if cl.TapNotifySingle || cl.TapNotifyDouble || cl.TapNotifyTriple {
|
|
c.flags[cl.ID] = tapNotifyFlags{
|
|
single: cl.TapNotifySingle,
|
|
doubleTap: cl.TapNotifyDouble,
|
|
triple: cl.TapNotifyTriple,
|
|
}
|
|
}
|
|
}
|
|
}
|