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

Rightclick not working on Android is not BUTTON_RIGHT #51737

Closed
ModProg opened this issue Aug 16, 2021 · 9 comments · Fixed by #51747
Closed

Rightclick not working on Android is not BUTTON_RIGHT #51737

ModProg opened this issue Aug 16, 2021 · 9 comments · Fixed by #51747

Comments

@ModProg
Copy link
Contributor

ModProg commented Aug 16, 2021

Godot version

3.3.2.stable

System information

Android

Issue description

While left and middle click correctly map to BUTTON_LEFT and BUTTON_MIDDLE rightclick does not, it is 0 instead.

Steps to reproduce

Attach this to a control and run on Android (I have a child name Label2 to display the value):

func _input(event: InputEvent) -> void:
	
	if event is InputEventMouseButton:
		$Label2.text = "PRESSED: " if event.pressed else "RELEASED: "
		match event.button_index:
			BUTTON_LEFT:
				$Label2.text += "left";
			BUTTON_RIGHT:
				$Label2.text += "right";
			BUTTON_MIDDLE:
				$Label2.text += "middle";

Minimal reproduction project

No response

@Calinou
Copy link
Member

Calinou commented Aug 16, 2021

cc @thebestnom

Note for potential testers: this requires a hardware mouse, which you can connect to an Android device using an USB OTG adapter or Bluetooth. Using an Android emulator on a PC might work, but I'm not sure.

@akien-mga
Copy link
Member

Note that the Android input handling changed significantly in 3.x, so it might be worth testing if this is reproducible in 3.4-beta3 or later: https://downloads.tuxfamily.org/godotengine/3.4/beta3/

I haven't tested and I'm not familiar with that code, but from a quick glance at the code I noticed something fishy:

if (android_button_mask & AMOTION_EVENT_BUTTON_SECONDARY) {
godot_button_mask |= BUTTON_MASK_XBUTTON2;
}

AMOTION_EVENT_BUTTON_SECONDARY is handled twice.

@ModProg
Copy link
Contributor Author

ModProg commented Aug 16, 2021

@akien-mga I tried your recomendation and it fixed the issue: #51744

@thebestnom
Copy link
Contributor

thebestnom commented Aug 16, 2021

What rom are you? the fix is mostly wrong 😅
Most stock android roms doesn't support right click correctly,I tested on lineageos as a baseline because it doesn't meddle with the mouse click

@akien-mga
Copy link
Member

I don't know if the fix is sufficient for all ROMs but it does seem to fix a typo, no? What's the use case for matching AMOTION_EVENT_BUTTON_SECONDARY to BUTTON_MASK_XBUTTON2?

@ModProg
Copy link
Contributor Author

ModProg commented Aug 16, 2021

What rom are you? the fix is mostly wrong sweat_smile

Samsung Android 11, but this should be the default behaviour, did you check with a native android application?

BUTTON_SECONDARY was added in android 4.0

@thebestnom
Copy link
Contributor

Actually not, samsung did this completely wrong when I tested on my dad galaxy s10, I have a huge complain on it in the PR 😅

@thebestnom
Copy link
Contributor

#37158 (comment)

@thebestnom
Copy link
Contributor

Oh... My bad, I didn't read the bug correctly, I think you are correct, but my comment in the PR will make this really hard to test on most devices 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants