Loading README.md +17 −14 Original line number Diff line number Diff line Loading @@ -27,19 +27,17 @@ Example: prints event info for pressing button #1 or moving hat#1.(with 10sec ti } fmt.Printf("HID#1:- Buttons:%d, Hats:%d\n", len(device.Buttons), len(device.HatAxes)/2) // make channels for specific events b1press := device.OnClose(1) h1move := device.OnMove(1) // feed OS events onto the event channels. go device.ParcelOutEvents() fmt.Println("Timeout in 10 secs.") loop: // handle event channels go func(){ for{ select { case <-time.After(time.Second*10): fmt.Println("Shutting down due to timeout.") break loop case <-b1press: fmt.Println("button #1 pressed") case h := <-h1move: Loading @@ -47,6 +45,11 @@ Example: prints event info for pressing button #1 or moving hat#1.(with 10sec ti fmt.Println("hat #1 moved too:", hpos.X,hpos.Y) } } }() fmt.Println("Timeout in 10 secs.") <-time.After(time.Second*10) fmt.Println("Shutting down due to timeout.") } Loading examples/basic/basic.go +22 −20 Original line number Diff line number Diff line Loading @@ -12,20 +12,18 @@ func main() { } fmt.Printf("HID#1:- Buttons:%d, Hats:%d\n", len(device.Buttons), len(device.HatAxes)/2) // make channels for specific events b1press := device.OnClose(1) b2press := device.OnClose(2) h1move := device.OnMove(1) // feed OS events onto the event channels. go device.ParcelOutEvents() fmt.Println("Timeout in 10 secs.") loop: // handle event channels go func(){ for{ select { case <-time.After(time.Second*10): fmt.Println("Shutting down due to timeout.") break loop case <-b1press: fmt.Println("button #1 pressed") case <-b2press: Loading @@ -33,11 +31,15 @@ loop: coords := make([]float32, 2) device.ReadHatPosition(1,coords) fmt.Println("current hat #1 position:",coords) case h := <-h1move: hpos:=h.(HatPositionEvent) fmt.Println("hat #1 moved too:", hpos.X,hpos.Y) } } }() fmt.Println("Timeout in 10 secs.") <-time.After(time.Second*10) fmt.Println("Shutting down due to timeout.") } joysticks.go +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import ( "fmt" ) // TODO integer axis position events // TODO divided position events // TODO drag event var LongPressDelay = time.Second Loading Loading
README.md +17 −14 Original line number Diff line number Diff line Loading @@ -27,19 +27,17 @@ Example: prints event info for pressing button #1 or moving hat#1.(with 10sec ti } fmt.Printf("HID#1:- Buttons:%d, Hats:%d\n", len(device.Buttons), len(device.HatAxes)/2) // make channels for specific events b1press := device.OnClose(1) h1move := device.OnMove(1) // feed OS events onto the event channels. go device.ParcelOutEvents() fmt.Println("Timeout in 10 secs.") loop: // handle event channels go func(){ for{ select { case <-time.After(time.Second*10): fmt.Println("Shutting down due to timeout.") break loop case <-b1press: fmt.Println("button #1 pressed") case h := <-h1move: Loading @@ -47,6 +45,11 @@ Example: prints event info for pressing button #1 or moving hat#1.(with 10sec ti fmt.Println("hat #1 moved too:", hpos.X,hpos.Y) } } }() fmt.Println("Timeout in 10 secs.") <-time.After(time.Second*10) fmt.Println("Shutting down due to timeout.") } Loading
examples/basic/basic.go +22 −20 Original line number Diff line number Diff line Loading @@ -12,20 +12,18 @@ func main() { } fmt.Printf("HID#1:- Buttons:%d, Hats:%d\n", len(device.Buttons), len(device.HatAxes)/2) // make channels for specific events b1press := device.OnClose(1) b2press := device.OnClose(2) h1move := device.OnMove(1) // feed OS events onto the event channels. go device.ParcelOutEvents() fmt.Println("Timeout in 10 secs.") loop: // handle event channels go func(){ for{ select { case <-time.After(time.Second*10): fmt.Println("Shutting down due to timeout.") break loop case <-b1press: fmt.Println("button #1 pressed") case <-b2press: Loading @@ -33,11 +31,15 @@ loop: coords := make([]float32, 2) device.ReadHatPosition(1,coords) fmt.Println("current hat #1 position:",coords) case h := <-h1move: hpos:=h.(HatPositionEvent) fmt.Println("hat #1 moved too:", hpos.X,hpos.Y) } } }() fmt.Println("Timeout in 10 secs.") <-time.After(time.Second*10) fmt.Println("Shutting down due to timeout.") }
joysticks.go +1 −1 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import ( "fmt" ) // TODO integer axis position events // TODO divided position events // TODO drag event var LongPressDelay = time.Second Loading