Checkpoint
This commit is contained in:
125 files changed
+59376
No files matched your search
@@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"git.maze.io/go/bragi/hardware/input"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
logrus.SetLevel(logrus.TraceLevel)
|
||||
|
||||
sources, err := input.Detect()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
var wait sync.WaitGroup
|
||||
for _, s := range sources {
|
||||
wait.Add(1)
|
||||
go test(s, &wait)
|
||||
}
|
||||
wait.Wait()
|
||||
}
|
||||
|
||||
func test(s input.Source, wait *sync.WaitGroup) {
|
||||
defer wait.Done()
|
||||
|
||||
events, err := s.Events()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
for e := range events {
|
||||
fmt.Println(e)
|
||||
switch e.Type {
|
||||
case input.RotaryClockwise:
|
||||
println("clockwise")
|
||||
case input.RotaryCounterClockwise:
|
||||
println("counter clockwise")
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user