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

Unified button mask behavior across platforms #20063

Merged
merged 1 commit into from Dec 14, 2018

Conversation

moiman100
Copy link
Contributor

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.

Copy link
Contributor

@leonkrause leonkrause left a 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);
Copy link
Contributor

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);
Copy link
Contributor

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);
Copy link
Contributor

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);

@moiman100
Copy link
Contributor Author

Made requested changes

@moiman100
Copy link
Contributor Author

resolved conflicts

@akien-mga
Copy link
Member

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 :)

@akien-mga akien-mga merged commit 57c3f6a into godotengine:master Dec 14, 2018
@akien-mga
Copy link
Member

Thanks!

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

Successfully merging this pull request may close these issues.

None yet

4 participants