Virtual/on-screen joystick support#2803
Merged
Merged
Conversation
1c6fb91 to
b81c49d
Compare
b81c49d to
ab54490
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR makes joystick support available everywhere by adding an on-screen virtual joystick integrated directly into the input backend.
The advantage of this approach is that a jME application sees the virtual joystick just like any other Xbox-style joystick supported by jME. No special handling is needed: applications can use the usual joystick bindings.
The controls are rendered as spatials attached to the node passed to the joystick update method. When using
SimpleApplication, this is already handled correctly and the controls end up in theguiNode, so normal jME apps do not need any additional setup.xbox layout
dynamic layout
Since it now conflicts with this, the
AndroidSensorJoyInput(that is used to simulate android joysticks using accelerometer), is now disabled by default and gated behind theUseAndroidSensorJoystickapp setting.Other changes to AppSettings:
DisableJoysticksis now off by default, meaning gamepads are always supported when availableVirtualJoystickcan be used to set the virtual joystick mode , defaults toVIRTUAL_JOYSTICK_AUTOVirtualJoystickDefaultLayoutcan be used to set the virtual joystick layout, defaults toVIRTUAL_JOYSTICK_LAYOUT_DYNAMICDefault settings should just work as expected in most apps, but these appsettings allow some customization:
modes
VIRTUAL_JOYSTICK_DISABLEDwill never show the virtual joystickVIRTUAL_JOYSTICK_ENABLEDwill always show the virtual joystickVIRTUAL_JOYSTICK_AUTOwill automatically display the virtual joystick on mobile, if there is at least one joystick bind registered by the app, and if there is not an hardware joystick connecteddefault layouts
VIRTUAL_JOYSTICK_LAYOUT_XBOXwill show a full xbox-like layoutVIRTUAL_JOYSTICK_LAYOUT_DYNAMICwill only show the buttons used by the appadvanced usage
it is possible to set custom layouts and tweak the virtual joystick even more, by accessing the
VirtualJoystickobject, that is retrievable via InputManager.getJoysticks()