Skip to content
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

Hide instructions on touch devices #20

Merged
merged 1 commit into from
Dec 16, 2024
Merged

Conversation

wjt
Copy link
Member

@wjt wjt commented Dec 16, 2024

When running on a touchscreen, the (self-explanatory) controls are visible on-screen, and the assumption is that neither a keyboard nor a touchpad is available. So, hide the instructions in that case. If the player does have one or more joypads connected to their touchscreen device, they'll figure it out.

There is no change notification for DisplayServer.is_touchscreen_available(). One might expect that its value could change: for example, only one of the screens currently connected to my computer. In fact, there are only 4 implementations:

  • The iOS and Android implementations always return true;
  • The web implementation checks whether window.ontouchstart is defined, which AFAICT cannot change;
  • The fallback implementation checks whether emulate_touch_from_mouse is set.

So, it is safe to just check it once when the scene loads.

When running on a touchscreen, the (self-explanatory) controls are visible
on-screen, and the assumption is that neither a keyboard nor a touchpad is
available. So, hide the instructions in that case. If the player does have
one or more joypads connected to their touchscreen device, they'll figure
it out.

There is no change notification for DisplayServer.is_touchscreen_available().
One might expect that its value could change: for example, only one of the
screens currently connected to my computer. In fact, there are only 4
implementations:

- The iOS and Android implementations always return true;
- The web implementation checks whether window.ontouchstart is defined, which
  AFAICT cannot change;
- The fallback implementation checks whether emulate_touch_from_mouse is set.

So, it is safe to just check it once when the scene loads.
@@ -25,7 +25,8 @@ func _ready():
Global.timer_added.connect(_on_timer_added)

Input.joy_connection_changed.connect(_on_joy_connection_changed)
# TODO: hide entirely if touch controls are visible?
if DisplayServer.is_touchscreen_available():
%Start.hide()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@manuq manuq merged commit ca69811 into main Dec 16, 2024
1 check passed
@manuq manuq deleted the hide-instructions-on-touch-devices branch December 16, 2024 11:48
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.

2 participants