Checkpoint
This commit is contained in:
125 files changed
+59376
No files matched your search
@@ -0,0 +1,46 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"sync"
|
||||
|
||||
"git.maze.io/go/bragi/hardware/display/sdl"
|
||||
"git.maze.io/go/bragi/hardware/input"
|
||||
)
|
||||
|
||||
func main() {
|
||||
d, err := sdl.New()
|
||||
if err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
inputs, err := input.Detect()
|
||||
if err != nil {
|
||||
log.Fatalln("failed to detect input sources:", err)
|
||||
}
|
||||
log.Printf("detected %d input sources:", len(inputs))
|
||||
for _, input := range inputs {
|
||||
log.Println("input:", input.Name())
|
||||
}
|
||||
|
||||
var wait sync.WaitGroup
|
||||
for _, s := range inputs {
|
||||
wait.Add(1)
|
||||
go func(s input.Source, wait *sync.WaitGroup) {
|
||||
defer wait.Done()
|
||||
|
||||
events, err := s.Events()
|
||||
if err != nil {
|
||||
log.Println("failed to get events from source:", s.Name(), err)
|
||||
return
|
||||
}
|
||||
|
||||
for e := range events {
|
||||
log.Println("event:", e)
|
||||
}
|
||||
}(s, &wait)
|
||||
}
|
||||
|
||||
log.Fatalln(d.Run())
|
||||
wait.Wait()
|
||||
}
|
||||
Reference in new issue
Block a user