# How to detect presence of mouse/touch?

**URL:** <https://forum.defold.com/t/how-to-detect-presence-of-mouse-touch/3989>\
**Category:** Questions\
**Created:** [January 15, 2017, 9:41am UTC](https://forum.defold.com/t/how-to-detect-presence-of-mouse-touch/3989 "2017-01-15T09:41:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dapetcu21](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/dapetcu21/32/25120_2.png) [@dapetcu21](https://forum.defold.com/u/dapetcu21)\
**Post date:** [January 15, 2017, 9:41am UTC](https://forum.defold.com/t/how-to-detect-presence-of-mouse-touch/3989/1 "2017-01-15T09:41:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Pkeod](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/pkeod/32/606_2.png) [@Pkeod](https://forum.defold.com/u/Pkeod)\
**Post date:** [January 15, 2017, 10:21am UTC](https://forum.defold.com/t/how-to-detect-presence-of-mouse-touch/3989/2 "2017-01-15T10:21:31Z")

</div>

For ref of all of the OS values

> [@Big List of Defold Pro Tips!](https://forum.defold.com/t/big-list-of-defold-pro-tips/1519/12):
>
> Detecting the current OS information for selective code. Sometimes you want to enable or disable code, or have dummy simulated code go off depending on which platform you are testing. Is there a list of all current possibilities somewhere? Can someone check what the Linux one is? local sysinfo = sys.get\_sys\_info() if sysinfo.system\_name == “Android” then … elseif sysinfo.system\_name == “iPhone OS” then … elseif sysinfo.system\_name == “Windows” then … elseif sysinfo.system\_name == “Linu…

---

<div class="post-metadata">

**Author:** ![britzl](https://forum-defold.b-cdn.net/user_avatar/forum.defold.com/britzl/32/23_2.png) [@britzl](https://forum.defold.com/u/britzl)\
**Post date:** [January 15, 2017, 8:18pm UTC](https://forum.defold.com/t/how-to-detect-presence-of-mouse-touch/3989/3 "2017-01-15T20:18:31Z")

</div>

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”
