Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #467
All variants other than
Text
have been implemented. WhileText
can be implemented usingToUnicode
, that doesn't play nice with dead keys, IME, etc.Most of the mouse
DeviceEvent
s were already implemented, but due to the flags that were used when registering for raw input events, they only worked when the window was in the foreground.This is also a step forward for #338, as
DeviceId
s are no longer useless on Windows. OnDeviceEvent
s, theDeviceId
contains that device's handle. While that handle could ostensibly be used by developers to query device information, my actual reason for choosing it is because it's simply a very easy way to handle this. As a fun bonus, this enabled me to create this method:Using this gives you a unique identifier for the device that persists across replugs/reboots/etc., so it's ideal for something like device-specific configuration.
There's a notable caveat to the new
DeviceId
s, which is that the value will always be 0 for aWindowEvent
. There doesn't seem to be any straightforward way around this limitation.I was concerned that multi-window applications would receive n copies of every
DeviceEvent
, but Windows only sends them to one window per application.Lastly, there's a chance that these additions will cause antivirus/etc. software to detect winit applications as keyloggers. I don't know how likely that is to actually happen to people, but if it does become an issue, the raw input code is neatly sequestered and would be easy to make optional during compilation.