the web export version should auto detect keyboard mouse or screen and remove the touch screen controls if not needed #171

Closed
opened 2026-08-30 11:26:18 +00:00 by metaheavens · 1 comment
Owner
No description provided.
Author
Owner

Done in 0fad1dd.

The old rule asked DisplayServer.is_touchscreen_available(), which answers "could a touch arrive" rather than "is anyone touching". In a browser that is yes on any laptop whose panel or pointer reports touch support, so the web build put thumb sticks over a screen being played with a mouse - and it also gated MOUSE AIMING, which was therefore switched off on exactly the machine it exists for. The decision was also made once and never revisited, so a wrong answer the other way stranded a device with no controls until it was restarted.

The reading is now the last input actually USED, which is a fact rather than a capability. It lives in GameState (pointer_is_touch) because two things need the same answer - GameController shows or hides the four on-screen controls, MouseCombatController decides whether a click fires - and one answer means they can never disagree.

It is two-way: a keyboard or mouse takes the controls away, a touch brings them straight back. That is what makes it safe to apply everywhere rather than only where the display claims there is no touchscreen - nothing can be stranded, because the gesture that needs the controls is the gesture that restores them, and it takes one tap.

The one subtlety: Godot manufactures the other kind of event from each one, so a tap produces a click a moment later. A touch therefore suppresses mouse evidence for a second, and that manufactured click is not mistaken for a mouse.

test_desktop_hides_touch_controls.gd was rewritten around the new rule and now covers both directions, the manufactured click, and the fact that the guns read the same answer the sticks do.

Done in 0fad1dd. The old rule asked `DisplayServer.is_touchscreen_available()`, which answers "could a touch arrive" rather than "is anyone touching". In a browser that is yes on any laptop whose panel or pointer reports touch support, so the web build put thumb sticks over a screen being played with a mouse - and it also gated MOUSE AIMING, which was therefore switched off on exactly the machine it exists for. The decision was also made once and never revisited, so a wrong answer the other way stranded a device with no controls until it was restarted. The reading is now the last input actually USED, which is a fact rather than a capability. It lives in GameState (`pointer_is_touch`) because two things need the same answer - GameController shows or hides the four on-screen controls, MouseCombatController decides whether a click fires - and one answer means they can never disagree. It is two-way: a keyboard or mouse takes the controls away, a touch brings them straight back. That is what makes it safe to apply everywhere rather than only where the display claims there is no touchscreen - nothing can be stranded, because the gesture that needs the controls is the gesture that restores them, and it takes one tap. The one subtlety: Godot manufactures the other kind of event from each one, so a tap produces a click a moment later. A touch therefore suppresses mouse evidence for a second, and that manufactured click is not mistaken for a mouse. test_desktop_hides_touch_controls.gd was rewritten around the new rule and now covers both directions, the manufactured click, and the fact that the guns read the same answer the sticks do.
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
metaheavens/spaceship#171
No description provided.