mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
mobile/ebitenmobileview: bug fix: gamepads didn't work on Android
Closes #1934
This commit is contained in:
parent
3b0ce21a56
commit
7e08333dd9
@ -302,7 +302,7 @@ func OnGamepadAdded(deviceID int, name string, buttonNum int, axisNum int, descr
|
|||||||
sdlid[15] = byte(axisMask >> 8)
|
sdlid[15] = byte(axisMask >> 8)
|
||||||
|
|
||||||
id := gamepadIDFromDeviceID(deviceID)
|
id := gamepadIDFromDeviceID(deviceID)
|
||||||
gamepads[id] = mobile.Gamepad{
|
gamepads[id] = &mobile.Gamepad{
|
||||||
ID: id,
|
ID: id,
|
||||||
SDLID: hex.EncodeToString(sdlid[:]),
|
SDLID: hex.EncodeToString(sdlid[:]),
|
||||||
Name: name,
|
Name: name,
|
||||||
@ -321,14 +321,14 @@ func OnInputDeviceRemoved(deviceID int) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
gamepads = map[driver.GamepadID]mobile.Gamepad{}
|
gamepads = map[driver.GamepadID]*mobile.Gamepad{}
|
||||||
gamepadSlice []mobile.Gamepad
|
gamepadSlice []mobile.Gamepad
|
||||||
)
|
)
|
||||||
|
|
||||||
func updateGamepads() {
|
func updateGamepads() {
|
||||||
gamepadSlice = gamepadSlice[:0]
|
gamepadSlice = gamepadSlice[:0]
|
||||||
for _, g := range gamepads {
|
for _, g := range gamepads {
|
||||||
gamepadSlice = append(gamepadSlice, g)
|
gamepadSlice = append(gamepadSlice, *g)
|
||||||
}
|
}
|
||||||
mobile.Get().UpdateGamepads(gamepadSlice)
|
mobile.Get().UpdateGamepads(gamepadSlice)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user