How to detect presence of mouse/touch?

I have some button code that has an “hover” state. On Desktop that’s all cool and fine, but on mobile (iOS), action_id == nil events are still simulated (to match the last known touch position). I want to disable the hover feature on my buttons when the device I’m running on doesn’t have a mouse.

Is there a way of detecting that? Or, at least, is it a way of detecting if my game runs on mobile? (to be fair, very few people use Android with a mouse)

I tried sys.get_sys_info().system_name and I get Darwin on macOS and iPhone OS on my iPhone, but I don’t know the value for Android, as I don’t own an Android phone (at least one that still works).

Also, is the value the same on iPad? I assume you’re using [UIDevice systemName], so I’d assume yes.

EDIT: It’s "Android" on Android. I found out eventually.

For ref of all of the OS values

1 Like

The easiest way to detect the platform your game is running is as you’ve already guessed, sys.get_sys_info().system_name. The values are:

  • “Android”
  • “iPhone OS” - iPhone, iPad, iPod etc
  • “Windows”
  • “Linux”
  • “Darwin” - OSX
  • “HTML5” - Old versions of dmengine used “Emscripten”
1 Like