mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
cmd/ebitenmobileview: Bug fix: Crash when removing a gamepad
Fixes #1185
This commit is contained in:
parent
a66867007a
commit
be54f1d33c
@ -675,13 +675,8 @@ public class EbitenView extends ViewGroup implements InputManager.InputDeviceLis
|
||||
|
||||
@Override
|
||||
public void onInputDeviceRemoved(int deviceId) {
|
||||
InputDevice inputDevice = this.inputManager.getInputDevice(deviceId);
|
||||
int sources = inputDevice.getSources();
|
||||
if ((sources & InputDevice.SOURCE_GAMEPAD) != InputDevice.SOURCE_GAMEPAD &&
|
||||
(sources & InputDevice.SOURCE_JOYSTICK) != InputDevice.SOURCE_JOYSTICK) {
|
||||
return;
|
||||
}
|
||||
Ebitenmobileview.onGamepadRemoved(deviceId);
|
||||
// Do not call inputManager.getInputDevice(), which returns null (#1185).
|
||||
Ebitenmobileview.onInputDeviceRemoved(deviceId);
|
||||
}
|
||||
|
||||
// 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) {
|
||||
id := gamepadIDFromDeviceID(deviceID)
|
||||
delete(gamepads, id)
|
||||
func OnInputDeviceRemoved(deviceID int) {
|
||||
if id, ok := deviceIDToGamepadID[deviceID]; ok {
|
||||
delete(gamepads, id)
|
||||
delete(deviceIDToGamepadID, deviceID)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user