From d35d8a20be840b6f665e5948256428af918e1189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Geis?= Date: Sun, 22 Nov 2020 12:56:28 +0100 Subject: [PATCH] Fix report never being read. --- cmd/main.go | 2 +- stadia.go | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index 8cf389a..242aea3 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -64,7 +64,7 @@ func run() error { if err != nil { if errors.Is(err, stadiacontroller.RetryError) { - time.Sleep(500 * time.Millisecond) + time.Sleep(1 * time.Second) continue } return err diff --git a/stadia.go b/stadia.go index 6d4ac79..9e02202 100644 --- a/stadia.go +++ b/stadia.go @@ -20,8 +20,8 @@ type StadiaController struct { } func NewStadiaController() *StadiaController { - ticker := time.NewTicker(500 * time.Millisecond) - controller := &StadiaController{nil, ticker, RetryError} + ticker := time.NewTicker(1 * time.Second) + controller := &StadiaController{nil, ticker, nil} go func() { for range ticker.C { @@ -83,7 +83,11 @@ func (c *StadiaController) GetReport() (Xbox360ControllerReport, error) { report := Xbox360ControllerReport{} if c.device == nil { - return report, c.err + err := c.err + if err == nil { + err = RetryError + } + return report, err } buf, ok := <-(*c.device).ReadCh()