internal/gamepad: bug fix: wrong SDL ID on iOS

The gamepad database already worked well with this fix.

Closes #2311
This commit is contained in:
Hajime Hoshi 2022-09-11 22:28:01 +09:00
parent eec944f5ed
commit 4629306f4b

View File

@ -390,6 +390,10 @@ package gamepad
// } // }
import "C" import "C"
import (
"encoding/hex"
)
//export ebitenAddGamepad //export ebitenAddGamepad
func ebitenAddGamepad(controller C.uintptr_t, prop *C.struct_ControllerProperty) { func ebitenAddGamepad(controller C.uintptr_t, prop *C.struct_ControllerProperty) {
theGamepads.addIOSGamepad(controller, prop) theGamepads.addIOSGamepad(controller, prop)
@ -405,7 +409,7 @@ func (g *gamepads) addIOSGamepad(controller C.uintptr_t, prop *C.struct_Controll
defer g.m.Unlock() defer g.m.Unlock()
name := C.GoString(&prop.name[0]) name := C.GoString(&prop.name[0])
sdlID := C.GoStringN(&prop.guid[0], 16) sdlID := hex.EncodeToString([]byte(C.GoStringN(&prop.guid[0], 16)))
gp := g.add(name, sdlID) gp := g.add(name, sdlID)
gp.native = &nativeGamepadImpl{ gp.native = &nativeGamepadImpl{
controller: uintptr(controller), controller: uintptr(controller),