mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-24 01:42:05 +01:00
examples/gamepad: Sort gamepad ids when showing the states
This commit is contained in:
parent
f3ef2e2af5
commit
8cb037e902
@ -19,6 +19,7 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -85,7 +86,12 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
|||||||
// Draw the current gamepad status.
|
// Draw the current gamepad status.
|
||||||
str := ""
|
str := ""
|
||||||
if len(g.gamepadIDs) > 0 {
|
if len(g.gamepadIDs) > 0 {
|
||||||
|
ids := make([]int, 0, len(g.gamepadIDs))
|
||||||
for id := range g.gamepadIDs {
|
for id := range g.gamepadIDs {
|
||||||
|
ids = append(ids, id)
|
||||||
|
}
|
||||||
|
sort.Ints(ids)
|
||||||
|
for id := range ids {
|
||||||
str += fmt.Sprintf("Gamepad (ID: %d, SDL ID: %s):\n", id, ebiten.GamepadSDLID(id))
|
str += fmt.Sprintf("Gamepad (ID: %d, SDL ID: %s):\n", id, ebiten.GamepadSDLID(id))
|
||||||
str += fmt.Sprintf(" Axes: %s\n", strings.Join(g.axes[id], ", "))
|
str += fmt.Sprintf(" Axes: %s\n", strings.Join(g.axes[id], ", "))
|
||||||
str += fmt.Sprintf(" Buttons: %s\n", strings.Join(g.pressedButtons[id], ", "))
|
str += fmt.Sprintf(" Buttons: %s\n", strings.Join(g.pressedButtons[id], ", "))
|
||||||
|
Loading…
Reference in New Issue
Block a user