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

BUG: jadx-gui: invalid mapping for horizontal scroll wheel and forward mouse button #1718

Closed
S-trace opened this issue Nov 3, 2022 · 4 comments · Fixed by #2229
Closed
Assignees
Labels
GUI Issues in jadx-gui module
Milestone

Comments

@S-trace
Copy link
Contributor

S-trace commented Nov 3, 2022

Hello.

I'm using jadx-gui v1.4.5.
I have a Logitech MX Master 3 mouse with a horizontal scroll wheel and forward/back thumb buttons.

If I use the horizontal scroll wheel to scroll right or left with the mouse cursor over the code window - jadx-gui does not scroll the code window but reacts as if I pressed the "forward"/"back" mouse buttons (back for left-to-right scroll, forward for right-to-left scroll).

If I press the "back" mouse button - jadx-gui works as it should, and shows the previous open tab

If I press the "forward" mouse button - jadx-gui does not react to it.

This is confusing.

Thank you.

@skylot
Copy link
Owner

skylot commented Nov 3, 2022

Unfortunately, I don't find any method in java Swing/AWT to get actions bound to mouse buttons. So jadx-gui using raw mouse button numbers (here), and this approach is very limited. Only way to fix that is to allow user to change keybindings (already requested in #1479). Anyway, I will try to search any other solution, maybe I missed something 👍

@skylot skylot self-assigned this Nov 3, 2022
@skylot skylot added the GUI Issues in jadx-gui module label Nov 3, 2022
@skylot skylot added this to the TBD milestone Nov 3, 2022
@oxodao
Copy link

oxodao commented Feb 21, 2023

Just discovered jadx recently and having a lot of fun with it. Unfortunately this issue is really bugging me as the sensitivity on the MX Master (1) seems to be quite high. Thank you for this piece of software anyway it's really great to have a good free alternative to JEB

@Mino260806
Copy link
Contributor

About this

If I use the horizontal scroll wheel to scroll right or left with the mouse cursor over the code window - jadx-gui does not scroll the code window but reacts as if I pressed the "forward"/"back" mouse buttons (back for left-to-right scroll, forward for right-to-left scroll).

The issue is here

private void registerMouseNavigationButtons() {
	Toolkit toolkit = Toolkit.getDefaultToolkit();
	toolkit.addAWTEventListener(event -> {
		if (event instanceof MouseEvent) {
			MouseEvent mouseEvent = (MouseEvent) event;
			if (mouseEvent.getID() == MouseEvent.MOUSE_PRESSED) {
				int rawButton = mouseEvent.getButton();
				if (rawButton <= 3) {
					return;
				}
				int button = remapMouseButton(rawButton);
				switch (button) {
					case 4:
						tabbedPane.navBack();
						break;
					case 5:
						tabbedPane.navForward();
						break;
				}
			}
		}
	}, AWTEvent.MOUSE_EVENT_MASK);
}

On Linux Mint, I logged the value of rawButton when I scroll horizontally and the results are:

  • Scroll to the right rawButton == 4
  • Scroll to the left rawButton == 5

From AWT documentation

Button numbers greater than BUTTON3 have no constant identifier. So if a mouse with five buttons is installed, this method may return the following values:
0 ( NOBUTTON)
1 ( BUTTON1)
2 ( BUTTON2)
3 ( BUTTON3)
4
5

So it's wrong to assume the type of the button from mouseEvent.getButton() when the value is greater than 3, there's nothing that verifies our assumptions and there will always be different values and mappings from one driver to another

It's better to let the user simulate the input himself if he wants to use an advanced mouse button, which is what I'm trying to implement atm

@skylot
Copy link
Owner

skylot commented Aug 3, 2023

Now is possible to set these shortcuts manually, by default there are only assigned keyboard keys, but no mouse buttons.
Shortcut customization feature was implemented by @Mino260806 in PR #1980.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI Issues in jadx-gui module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants