func (t *trigger) handleEvent(val int) { if val >= t.threshold && !t.active { C.CGEventPost(C.kCGAnnotatedSessionEventTap, t.down) t.active = true } else if val < t.threshold && t.active { C.CGEventPost(C.kCGAnnotatedSessionEventTap, t.up) t.active = false } }
func (a *axis) handleEvent(val int) { if val <= -a.threshold && !a.negative { C.CGEventPost(C.kCGAnnotatedSessionEventTap, a.nDown) a.negative = true } else if val > -a.threshold && a.negative { C.CGEventPost(C.kCGAnnotatedSessionEventTap, a.nUp) a.negative = false } if val >= a.threshold && !a.positive { C.CGEventPost(C.kCGAnnotatedSessionEventTap, a.pDown) a.positive = true } else if val < a.threshold && a.positive { C.CGEventPost(C.kCGAnnotatedSessionEventTap, a.pUp) a.positive = false } }
func (b *button) handleDown() { C.CGEventPost(C.kCGAnnotatedSessionEventTap, b.down) }
func (b *button) handleUp() { C.CGEventPost(C.kCGAnnotatedSessionEventTap, b.up) }