Forum Discussion
butterchickenpaneer
1 year agoStart Partner
How to take controller input in a 2d android app ?
Basic events like touch is passed on
onTouchEventbut how to get event on pressing button and moving the joystick on 2d app porting it to meta quest ?
2 Replies
Replies have been turned off for this discussion
- vii.qiuioStart Partner
same
- irpod2Honored Guest
Just like on regular Android, you can override onGenericMotionEvent or setGenericMotionEventListener on your view to get most any sort of inputs passed to your app, and go from there. (Google's docs on it)
If you're using Jetpack Compose, you can also get access to these events with the Modifier.pointerInput modifier. Though I can't find any dedicated docs for controller inputs, you can use awaitPointerEventScope in the PointerInputScope to get an AwaitPointerEventScope in which you can call awaitPointerEvent and play around with that to find the capabilities you're looking for.
Modifier.pointerInput(myKey) { awaitPointerEventScope { val event = awaitPointerEvent() // Do stuff with event } }
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 2 years ago
- 1 year ago
- 1 year ago