mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-13 22:47:26 +01:00
cmd/ebitenmobileview: Bug fix: Crash when removing a gamepad
Fixes #1185
This commit is contained in:
parent
a2b97be266
commit
f350b03232
@ -675,13 +675,8 @@ public class EbitenView extends ViewGroup implements InputManager.InputDeviceLis
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInputDeviceRemoved(int deviceId) {
|
public void onInputDeviceRemoved(int deviceId) {
|
||||||
InputDevice inputDevice = this.inputManager.getInputDevice(deviceId);
|
// Do not call inputManager.getInputDevice(), which returns null (#1185).
|
||||||
int sources = inputDevice.getSources();
|
Ebitenmobileview.onInputDeviceRemoved(deviceId);
|
||||||
if ((sources & InputDevice.SOURCE_GAMEPAD) != InputDevice.SOURCE_GAMEPAD &&
|
|
||||||
(sources & InputDevice.SOURCE_JOYSTICK) != InputDevice.SOURCE_JOYSTICK) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Ebitenmobileview.onGamepadRemoved(deviceId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// suspendGame suspends the game.
|
// suspendGame suspends the game.
|
||||||
|
File diff suppressed because one or more lines are too long
@ -315,7 +315,9 @@ func OnGamepadAdded(deviceID int, name string, buttonNum int, axisNum int, descr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func OnGamepadRemoved(deviceID int) {
|
func OnInputDeviceRemoved(deviceID int) {
|
||||||
id := gamepadIDFromDeviceID(deviceID)
|
if id, ok := deviceIDToGamepadID[deviceID]; ok {
|
||||||
delete(gamepads, id)
|
delete(gamepads, id)
|
||||||
|
delete(deviceIDToGamepadID, deviceID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user