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

TouchScreenGUI: Read coordinates directly for virtual joystick #13567

Merged
merged 2 commits into from Jun 16, 2023

Conversation

srifqi
Copy link
Member

@srifqi srifqi commented Jun 6, 2023

Goal of the PR
This PR makes the input handler to use virtual joystick's coordinate directly instead of using keyboard event so that the movement can be smooth and not limited to 8 direction and full speed.

YouTube video

How does the PR work?
The movement's direction and speed are calculated directly from the virtual joystick button's screen coordinate.

The only virtual joystick status left is for Aux1 button (used if virtual_joystick_triggers_aux1 is enabled).

Does it resolve any reported issue?
This PR tries to fix #12436.

Does this relate to a goal in the roadmap?
Probably, this PR tries to fix a reported UX issue.

To do

This PR is a Ready for Review.

How to test

  1. Run Minetest on a touch-screen device.
  2. Play in a world or on a server.
  3. Use the virtual joystick with incrementing distance from its centre.
  4. The movement's speed should be linearly proportional to the button's distance from its container's centre.
  5. Back to Menu.
  6. Enable virtual_joystick_triggers_aux1.
  7. Play in a world or on a server with a sprinting mod.
  8. Use the virtual joystick to move forward until the button is outside its container.
  9. The Aux1 button should be pressed automatically while moving forward (e.g. sprinting is happening).

Android: APK builds

…or virtual joystick

The movement's direction and speed are calculated directly from the button's screen coordinate.
The only virtual joystick status left is Aux1 button.
@srifqi srifqi added Android Feature ✨ PRs that add or enhance a feature @ Client / Controls / Input labels Jun 6, 2023
@Zughy Zughy added the Concept approved Approved by a core dev: PRs welcomed! label Jun 7, 2023
@grorp
Copy link
Member

grorp commented Jun 7, 2023

This is definitely an improvement to the user experience. I tested this PR both with and without fixed_virtual_joystick and virtual_joystick_triggers_aux1 and everything worked as expected.

The code also looks good. The only problem I see is that it removes physical joystick support on Android, but I doubt anyone is using a physical joystick on Android, and joystick support seems to be quite broken anyway.

EDIT: Another small thing: srifqi#1

@AbduSharif
Copy link

AbduSharif commented Jun 7, 2023

I got the build from "Actions" here, but it lead to the irrlicht crash, does anyone have a build to test this or is a rebase enough?

Edit: a rebase won't do (?).

@grorp
Copy link
Member

grorp commented Jun 7, 2023

I got the build from "Actions" here, but it lead to the irrlicht crash, does anyone have a build to test this or is a rebase enough?

Edit: a rebase won't do (?).

A rebase won't help, all Android builds will be broken until the IrrlichtMt revision is bumped. That's because the Android build downloads a pre-compiled IrrlichtMt. The only way to get a working build is to compile IrrlichtMt yourself.

EDIT: Here's an APK: ... .

@srifqi
Copy link
Member Author

srifqi commented Jun 8, 2023

[...] The only problem I see is that it removes physical joystick support on Android, but I doubt anyone is using a physical joystick on Android, and joystick support seems to be quite broken anyway.

Should I use the enable_joysticks setting in addition with the preprocessor directive? I do not have any physical joystick, so I can not test it.

#ifdef HAVE_TOUCHSCREENGUI
		if (!g_settings->getBool("enable_joysticks"))
			return m_receiver->m_touchscreengui->getMovementSpeed();
#endif
		return joystick.getMovementSpeed();

[...] does anyone have a build to test this [...]

I attached the APK builds in the first post with the recent IrrlichtMT build (09af5ac).

@sfan5
Copy link
Member

sfan5 commented Jun 8, 2023

Should I use the enable_joysticks setting in addition with the preprocessor directive?

IMO no

@grorp
Copy link
Member

grorp commented Jun 8, 2023

Just to make the available information more complete: Physical joysticks don't seem to be supported at all on Android at the moment, as Irrlicht doesn't support them on Android.

Copy link
Member

@sfan5 sfan5 left a comment

Choose a reason for hiding this comment

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

LGTM

@srifqi srifqi merged commit a4e69d6 into minetest:master Jun 16, 2023
13 checks passed
@srifqi srifqi deleted the virtual_joystick_smooth branch June 16, 2023 15:40
Wuzzy2 pushed a commit to Wuzzy2/minetest that referenced this pull request Jul 31, 2023
…est#13567)

The movement's direction and speed are calculated directly from the button's relative screen coordinate. The previous method was to trigger the movement using a keyboard event.
The only virtual joystick status left is Aux1 button.

---------

Co-authored-by: Gregor Parzefall <gregor.parzefall@posteo.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Android @ Client / Controls / Input Concept approved Approved by a core dev: PRs welcomed! Feature ✨ PRs that add or enhance a feature One approval ✅ ◻️
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Android virtual joystick movement
5 participants