From 7d9b901ab376a894cfe83841c878f60e03468238 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Mon, 12 Feb 2018 20:20:39 +0900 Subject: [PATCH] ui: Avoid creating empty slice at GamepadIDs --- internal/ui/input.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/ui/input.go b/internal/ui/input.go index 4356101fb..a160ce9f1 100644 --- a/internal/ui/input.go +++ b/internal/ui/input.go @@ -31,9 +31,14 @@ func (i *Input) CursorPosition() (x, y int) { return adjustCursorPosition(i.cursorX, i.cursorY) } +var emptyIDs = []int{} + func (i *Input) GamepadIDs() []int { i.m.RLock() defer i.m.RUnlock() + if len(i.gamepads) == 0 { + return emptyIDs + } r := []int{} for id, g := range i.gamepads { if g.valid {