Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iOS catch exception for unknown keys from hardware keyboard #6337

Merged
merged 1 commit into from Dec 30, 2020

Conversation

MrStahlfelge
Copy link
Member

I have this crash in my logs:

java.lang.IllegalArgumentException: No constant with value 669 (0x29d) found in org.robovm.apple.uikit.UIKeyboardHIDUsage
	at org.robovm.rt.bro.ValuedEnum$AsLongMarshaler.toObject(ValuedEnum.java:142)
	at org.robovm.rt.bro.ValuedEnum$AsMachineSizedSIntMarshaler.toObject(ValuedEnum.java:158)
	at org.robovm.apple.uikit.UIKey.$m$keyCode(Native Method)
	at org.robovm.apple.uikit.UIKey.getKeyCode(UIKey.java)
	at com.badlogic.gdx.backends.iosrobovm.DefaultIOSInput.onKey(DefaultIOSInput.java:660)

A UIKeyboardHIDUsage with value 669 is currently not present in RoboVM bindings. Even if it is added, the IllegalArgumentException might be thrown when Apple adds another newly supported key and the game is compiled with a RoboVM version still not knowing it. To avoid crashes, this PR catches the thrown exception and maps to Keys.UNKNOWN instead.

@MrStahlfelge MrStahlfelge added ios input Concerning Gdx.input labels Dec 29, 2020
Copy link
Member

@MobiDevelop MobiDevelop left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable.

@obigu
Copy link
Contributor

obigu commented Dec 29, 2020

LGTM.

As discussed, the constant is missing on the Apple class itself (https://developer.apple.com/documentation/uikit/uikeyboardhidusage) so I would make sure with MobiVM guys in Gitter the bindings are correct or if it would make sense to change them so that UIKey.getKeyCode returns a number instead.

@MrStahlfelge MrStahlfelge merged commit 09c3c16 into libgdx:master Dec 30, 2020
@MrStahlfelge MrStahlfelge deleted the catchKeyError branch December 30, 2020 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
input Concerning Gdx.input ios
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants