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

Add ability to detect mouse buttons are swapped #28

Open
dtapuska opened this issue Oct 4, 2017 · 6 comments
Open

Add ability to detect mouse buttons are swapped #28

dtapuska opened this issue Oct 4, 2017 · 6 comments

Comments

@dtapuska
Copy link

dtapuska commented Oct 4, 2017

Would it make sense to indicate in the InputDeviceCapabilities for mouse that the primary and secondary buttons are swapped?

You can do this via querying GetSystemMetrics(SM_SWAPBUTTON) on Windows.

The only problem I see with using the InputDeviceCapabilities API for this is that you can't query the API dynamically for installed devices; you have to wait for a device to appear.

@RByers
Copy link
Member

RByers commented Oct 5, 2017

Makes sense to me (pretty similar to the "touchpad direction reversed" capability we've discussed previously). But can you describe the use case?

The only problem I see with using the InputDeviceCapabilities API for this is that you can't query the API dynamically for installed devices; you have to wait for a device to appear.

This seems like an argument for InputDeviceCapabilities to me. The main alternative is to expose something on MouseEvent. With InputDeviceCapabilities we at least have a sketch of a design for enumerating the devices (but hopefully that's still lower priority as it certainly adds complexity).

@dtapuska
Copy link
Author

dtapuska commented Oct 5, 2017

Use case is UI polish. You can display text like "Click the left button" (instead of text like "Click the primary button"), or for some web based game you could show the user a picture of a mouse annotated with the actions each one does. If the user has them swapped then the annotation could be correct.

@RByers
Copy link
Member

RByers commented Oct 5, 2017

Thanks, those use cases seem really compelling to me! So are you thinking something like this?

partial interface InputDeviceCapabilities {
    // When true, the device represents a mouse where the physical location of
    // the "right" and "left" buttons are swapped.
    boolean mouseButtonsSwapped = false;
};

What about Back/Forward buttons, should they be considered swapped by this as well? Logically I'd expect so, but the SM_SWAPBUTTON documentation doesn't say anything about it.

@smaug---- @patrickhlauke @patrickkettner any feedback?

@patrickhlauke
Copy link
Contributor

No objections from me (and now wondering if there's any other input-related GetSystemMetrics things we could consider adding)

@smaug----
Copy link

smaug---- commented Oct 10, 2017

In principal sounds reasonable.

But is InputDeviceCapabilities the right place? If the information is used in UI, one should be able to query it without any user input... but then, that would be a privacy issue...
Not quite sure what the API should look like.

@RByers
Copy link
Member

RByers commented Oct 10, 2017

If the information is used in UI, one should be able to query it without any user input... but then, that would be a privacy issue...

IMHO if we ever add a "enumerate devices" API, that API should probably be restricted from being used in cross-origin iframes (unless permitted by a feature policy). For top documents I don't see much difference between enumeration or on input event only - the vast majority of pages will get at least one mouse input event (assuming we expose it consistently even on mousemove, but even only on mousedown will probably still be most pages).

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

No branches or pull requests

4 participants