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
Unified button mask behavior across platforms #20063
Conversation
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.
Logic for HTML5 is good, but please keep the mentioned comment separate and remove the redundant call.
@@ -248,11 +248,17 @@ static EM_BOOL _wheel_callback(int event_type, const EmscriptenWheelEvent *wheel | |||
|
|||
// Different browsers give wildly different delta values, and we can't | |||
// interpret deltaMode, so use default value for wheel events' factor | |||
int mask = _input->get_mouse_button_mask(); | |||
int button_flag = 1 << (ev->get_button_index() - 1); |
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.
This block confusingly looks like it's related to the preceding comment, put a newline inbetween.
|
||
ev->set_pressed(true); | ||
mask |= button_flag; | ||
ev->set_button_mask(mask); |
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.
set_button_mask
is already called once in line 229, remove that original invocation since we're calling it here.
_input->parse_input_event(ev); | ||
|
||
ev->set_pressed(false); | ||
mask &= ~button_flag; | ||
ev->set_button_mask(mask); |
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.
I don't feel the mask
variable helps readability, just this would be clearer:
ev->set_button_mask(ev->get_button_mask() & ~button_flag);
47f83c1
to
d7cf201
Compare
Made requested changes |
d7cf201
to
87d34a0
Compare
resolved conflicts |
87d34a0
to
bd9c592
Compare
Sorry for the delay. More testing from users and contributors would be nice to ensure that no regressions happen, but I guess this will be best done once in the master branch :) |
Thanks! |
Before on linux InputEvent would report button mask like this (pseudo)
InputEventMouseButton button_index=x is_pressed=true button_mask=0
InputEventMouseButton button_index=x is_pressed=false button_mask=button_mask_x
On all other platforms button mask is reported like this
InputEventMouseButton button_index=x is_pressed=true button_mask=button_mask_x
InputEventMouseButton button_index=x is_pressed=false button_mask=0
After this commit linux reports it like other platforms.
Before on linux InputEvent reported button mask for mouse wheel buttons, while other platforms didn't.
After this commit InputEvent reports mouse wheel button mask on all platforms.
Also someone should probably check horizontal mouse wheel buttons, because I don't have a mouse with tilting wheel. For example Logitech m705 has all supported functionality.
NOTE: OSX is NOT tested because I don't have a mac.
NOTE 2: os_windows.cpp diff looks really messy in GitHub because I removed an unnecessary indentation.
It looks fine, when comparing the files using something decent like KDiff3.