cmd/ebitenmobile: Bug fix: an input device might be null

Fixes #1342
This commit is contained in:
Hajime Hoshi 2020-09-10 14:10:35 +09:00
parent 99dcb14582
commit 404a662383
2 changed files with 5 additions and 1 deletions

View File

@ -509,6 +509,10 @@ public class EbitenView extends ViewGroup implements InputManager.InputDeviceLis
@Override
public void onInputDeviceAdded(int deviceId) {
InputDevice inputDevice = this.inputManager.getInputDevice(deviceId);
// The InputDevice can be null on some deivces (#1342).
if (inputDevice == null) {
return;
}
int sources = inputDevice.getSources();
if ((sources & InputDevice.SOURCE_GAMEPAD) != InputDevice.SOURCE_GAMEPAD &&
(sources & InputDevice.SOURCE_JOYSTICK) != InputDevice.SOURCE_JOYSTICK) {

File diff suppressed because one or more lines are too long