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

fix: mouse buttons #489

Merged
merged 4 commits into from
Mar 31, 2023
Merged

fix: mouse buttons #489

merged 4 commits into from
Mar 31, 2023

Conversation

Riverlance
Copy link
Contributor

Description

Mouse buttons uses bitwise logic, so these values should be like 0, 1, 2, 4, 8, and so on, not like 0, 1, 2, 3, 4, 5, 6, 7, 8, and so on.

Behaviour

Actual

As an example, MouseMidButton was the same as pressing MouseLeftButton + MouseRightButton at the same time. Because MouseLeftButton (1) + MouseRightButton (2) = MouseMidButton (3). It means, if I check in my code if I'm pressing mid button g_window.isPressed(MouseMidButton), it will work with mid button, but ALSO if I click left+right buttons.

Expected

If I check like g_window.isPressed(MouseMidButton), it should not consider this as true if I click left+right buttons.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested

  1. Use the code below somewhere:
print(g_window.isPressed(MouseMidButton))
  1. Then press left+right buttons. It will print true, but it should be false instead, since you are not pressing the mid button.

Test Configuration:

  • Server Version: TFS 1.5
  • Client: 12.87
  • Operating System: Windows

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I checked the PR checks reports
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

As an example, MouseMidButton was the same as pressing MouseLeftButton+MouseRightButton at the same time.
Because MouseLeftButton (1) + MouseRightButton (2) = MouseMidButton (3). It means, if I check in my code if I'm pressing mid button `g_window.isPressed(MouseMidButton)`, it will work with mid button, but ALSO if I click left+right buttons.

It should not work like that.
Mouse buttons uses bitwise logic, so these values should be like 0, 1, 2, 4, 8, and so on, not like 0, 1, 2, 3, 4, 5, 6, 7, 8, and so on.
@mehah
Copy link
Owner

mehah commented Mar 24, 2023

unfortunately it cannot be like that, the 'left shift(<<)' has to be applied only to m_mouseButtonStates, because when I click, for example, on the number 4 of the mouse, it returns 8.

image

middle returned 4

@mehah mehah changed the title Fix mouse buttons fix: mouse buttons Mar 31, 2023
@mehah mehah merged commit 1c631df into mehah:main Mar 31, 2023
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.

2 participants