Skip to content

refactor: Do not use id for mouse and rename TouchState to PointerState#51

Open
leomeinel wants to merge 3 commits intoSergioRibera:mainfrom
leomeinel:no-mouse-id
Open

refactor: Do not use id for mouse and rename TouchState to PointerState#51
leomeinel wants to merge 3 commits intoSergioRibera:mainfrom
leomeinel:no-mouse-id

Conversation

@leomeinel
Copy link
Copy Markdown
Contributor

@leomeinel leomeinel commented Apr 28, 2026

Purpose

Bevy does not assign ids to mouse input, therefore storing one is unnecessary.

By inserting None for id if we are using a mouse, we can also just use that to check if input is from a mouse which seems a lot cleaner.

Additionally this avoids previously duplicated checks in one of the branches by just first processing touch and mouse in the else branch.

Edit

I have now also renamed TouchState to PointerState since TouchState suggests that it is only four touches, but it actually is for any pointer.

Additionally and slightly out of the scope of this pr, I have also made sure that we are not calling node_rect unnecessarily which required a small refactor of the else branch in update_input.

Testing

This has been tested on mobile with the simple_mobile example and on linux with the simple example.

Bevy does not assign ids to mouse input, therefore storing one is unnecessary.

By inserting None for id if we are using a mouse, we can also just use that to check if input is from a mouse which seems a lot cleaner.

Additionally this avoids previously duplicated checks in one of the branches by just first processing touch and mouse in the else branch.
TouchState suggests that this is only four touches, but it actually is for any pointer.
@leomeinel leomeinel changed the title refactor: Avoid use of id for mouse input refactor: Do not use id for mouse and rename to PointerState Apr 28, 2026
@leomeinel leomeinel marked this pull request as ready for review April 28, 2026 18:04
@leomeinel leomeinel changed the title refactor: Do not use id for mouse and rename to PointerState refactor: Do not use id for mouse and rename TouchState to PointerState Apr 28, 2026
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

Successfully merging this pull request may close these issues.

1 participant