mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-26 10:42:42 +01:00
parent
4be49230de
commit
d6d17a7e85
@ -83,7 +83,7 @@ func update(screen *ebiten.Image) error {
|
||||
str := ""
|
||||
if len(ids) > 0 {
|
||||
for _, id := range ids {
|
||||
str += fmt.Sprintf("Gamepad (ID: %d):\n", id)
|
||||
str += fmt.Sprintf("Gamepad (ID: %d, SDL ID: %s):\n", id, ebiten.GamepadSDLID(id))
|
||||
str += fmt.Sprintf(" Axes: %s\n", strings.Join(axes[id], ", "))
|
||||
str += fmt.Sprintf(" Buttons: %s\n", strings.Join(pressedButtons[id], ", "))
|
||||
str += "\n"
|
||||
|
@ -17,6 +17,7 @@
|
||||
package js
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"syscall/js"
|
||||
"unicode"
|
||||
|
||||
@ -58,9 +59,14 @@ func (i *Input) CursorPosition() (x, y int) {
|
||||
}
|
||||
|
||||
func (i *Input) GamepadSDLID(id int) string {
|
||||
// TODO: Implement this. See the implementation of SDL:
|
||||
// https://github.com/spurious/SDL-mirror/blob/master/src/joystick/emscripten/SDL_sysjoystick.c
|
||||
return ""
|
||||
// This emulates the implementation of EMSCRIPTEN_JoystickGetDeviceGUID.
|
||||
// https://hg.libsdl.org/SDL/file/bc90ce38f1e2/src/joystick/emscripten/SDL_sysjoystick.c#l385
|
||||
if len(i.gamepads) <= id {
|
||||
return ""
|
||||
}
|
||||
var sdlid [16]byte
|
||||
copy(sdlid[:], []byte(i.gamepads[id].name))
|
||||
return hex.EncodeToString(sdlid[:])
|
||||
}
|
||||
|
||||
// GamepadName returns a string containing some information about the controller.
|
||||
|
Loading…
Reference in New Issue
Block a user