-
Notifications
You must be signed in to change notification settings - Fork 51
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
Add extra mouse buttons #178
Conversation
@@ -175,7 +175,7 @@ class Mouse extends VirtualInput { | |||
} | |||
|
|||
function buttonIndex(button: String): Int { | |||
return button == "left" ? 0 : (button == "right" ? 1 : 2); | |||
return button == "left" ? 0 : button == "right" ? 1 : button == "middle" ? 2 : button == "side1" ? 3 : (button == "side2" ? 4 : 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A switch statement is probably more readable here. It's not a big deal though, at least not for me :)
Also, should 2 still be the default value if the button
name is not in the list of known names? I think we should either return 5 or -1 here (irrespective of introducing a breaking change, which would be pretty minor).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Funny story, I actually used switch/case originally to test my buttons as I enjoy them more as well, then back-ported it to the question-mark & colon combination. To answer your questions:
- Lubos implemented the code so I didn't want to change anything that is preferable, nor did I know if using queston-mark/colon versus switch/case had any particular performance boost. It does however have better white space i.e. 1 line vs 14 lines.
5
would return an extra mouse button, which might raise an error if a user doesn't have that extra mouse button. Better to keep it at2
(middle mouse) - or0
(left mouse) if you'd prefer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, good point 👍
Hi @ Lubos. Regarding the comments above, do you prefer the current |
Happy with either one, thanks! Looks like for gamepad it's done in a loop https://github.com/armory3d/iron/blob/main/Sources/iron/system/Input.hx#L717. |
No description provided.