mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
ui: Avoid creating empty slice at GamepadIDs
This commit is contained in:
parent
57dd7db893
commit
7d9b901ab3
@ -31,9 +31,14 @@ func (i *Input) CursorPosition() (x, y int) {
|
|||||||
return adjustCursorPosition(i.cursorX, i.cursorY)
|
return adjustCursorPosition(i.cursorX, i.cursorY)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var emptyIDs = []int{}
|
||||||
|
|
||||||
func (i *Input) GamepadIDs() []int {
|
func (i *Input) GamepadIDs() []int {
|
||||||
i.m.RLock()
|
i.m.RLock()
|
||||||
defer i.m.RUnlock()
|
defer i.m.RUnlock()
|
||||||
|
if len(i.gamepads) == 0 {
|
||||||
|
return emptyIDs
|
||||||
|
}
|
||||||
r := []int{}
|
r := []int{}
|
||||||
for id, g := range i.gamepads {
|
for id, g := range i.gamepads {
|
||||||
if g.valid {
|
if g.valid {
|
||||||
|
Loading…
Reference in New Issue
Block a user