Skip to content

Distinction between MouseMotion and CursorMoved events is unclear in docs #5083

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

Closed
alice-i-cecile opened this issue Jun 23, 2022 · 3 comments
Assignees
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Docs An addition or correction to our documentation

Comments

@alice-i-cecile
Copy link
Member

What problem does this solve or what need does it fill?

As shown in the mouse_input_events example, Bevy exposes both a MouseMotion and CursorMoved event type.

These are poorly documented, but it appears that MouseMotion is relative, while CursorPosition is absolute (and tied to a specific window).

What solution would you like?

Clearly differentiate these types in the docs and explain why they both exist (and when you should use one vs the other).

What alternative(s) have you considered?

Remove MouseMotion, and only expose CursorMoved. However, it's not clear if MouseMotion can always be reconstructed; I'm particularly nervous about what happens when the cursor is locked to the screen.

Additional context

Related to #5034, which also tries to simplify the UX here.

@alice-i-cecile alice-i-cecile added C-Docs An addition or correction to our documentation A-Input Player input via keyboard, mouse, gamepad, and more C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Jun 23, 2022
@alice-i-cecile
Copy link
Member Author

It's also not clear why one refers to "mouse" and the other refers to "cursor". Perhaps there's a significance to this upstream in winit?

@alice-i-cecile
Copy link
Member Author

And of course, MouseMotion is stored in bevy_input, while CursorMoved comes from bevy_window.

@DJMcNab
Copy link
Member

DJMcNab commented Jun 23, 2022

My understanding is that mouse motion is about the physical motion of the actual mouse - this ignores pointer acceleration for example.

Cursor movement is about the movement of the cursor, i.e. the thing that you use to click with.

@alice-i-cecile alice-i-cecile removed the C-Usability A targeted quality-of-life change that makes Bevy easier to use label Jun 23, 2022
@alice-i-cecile alice-i-cecile changed the title MouseMotion vs CursorMoved events are confusing Distinction between MouseMotion and CursorMoved events is unclear in docs Jun 24, 2022
@Nilirad Nilirad self-assigned this Jun 24, 2022
@bors bors bot closed this as completed in 056f122 Jun 26, 2022
inodentry pushed a commit to IyesGames/bevy that referenced this issue Aug 8, 2022
# Objective

- Fixes bevyengine#5083 

## Solution

I looked at the implementation of those events. I noticed that they both are adaptations of `winit`'s `DeviceEvent`/`WindowEvent` enum variants. Therefore I based the description of the items on the documentation provided by the upstream crate. I also added a link to `CursorMoved`, just like `MouseMotion` already has.

## Observations

- Looking at the implementation of `MouseMotion`, I noticed the `DeviceId` field of the `winit` event is discarded by `bevy_input`. This means that in the case a machine has multiple pointing devices, it is impossible to distinguish to which one the event is referring to. **EDIT:** just tested, `MouseMotion` events are emitted for movement of both mice.
james7132 pushed a commit to james7132/bevy that referenced this issue Oct 28, 2022
# Objective

- Fixes bevyengine#5083 

## Solution

I looked at the implementation of those events. I noticed that they both are adaptations of `winit`'s `DeviceEvent`/`WindowEvent` enum variants. Therefore I based the description of the items on the documentation provided by the upstream crate. I also added a link to `CursorMoved`, just like `MouseMotion` already has.

## Observations

- Looking at the implementation of `MouseMotion`, I noticed the `DeviceId` field of the `winit` event is discarded by `bevy_input`. This means that in the case a machine has multiple pointing devices, it is impossible to distinguish to which one the event is referring to. **EDIT:** just tested, `MouseMotion` events are emitted for movement of both mice.
ItsDoot pushed a commit to ItsDoot/bevy that referenced this issue Feb 1, 2023
# Objective

- Fixes bevyengine#5083 

## Solution

I looked at the implementation of those events. I noticed that they both are adaptations of `winit`'s `DeviceEvent`/`WindowEvent` enum variants. Therefore I based the description of the items on the documentation provided by the upstream crate. I also added a link to `CursorMoved`, just like `MouseMotion` already has.

## Observations

- Looking at the implementation of `MouseMotion`, I noticed the `DeviceId` field of the `winit` event is discarded by `bevy_input`. This means that in the case a machine has multiple pointing devices, it is impossible to distinguish to which one the event is referring to. **EDIT:** just tested, `MouseMotion` events are emitted for movement of both mice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Input Player input via keyboard, mouse, gamepad, and more C-Docs An addition or correction to our documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants