Open dtapuska opened 7 years ago
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).
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.
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?
No objections from me (and now wondering if there's any other input-related GetSystemMetrics things we could consider adding)
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.
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).
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.