Skip to content

Commit

Permalink
Fix report never being read.
Browse files Browse the repository at this point in the history
  • Loading branch information
71 committed Nov 22, 2020
1 parent e1ad48c commit d35d8a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions stadia.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit d35d8a2

Please sign in to comment.