I want to determine if the device currently in use is a touch screen device in my script to perform some business operations. How can I achieve this? My node is just a regular Node2D node. I tried using the InputEventScreenTouch event to implement it, but that requires a click to determine. I hope to know whether it’s a touch screen device as soon as the game starts.
This might be better (cannot find GenericDevice in the docs, I think this is when a device is not recognized).
if OS.get_name() == "Android" or OS.get_name() == "iOS":
print("Touch screen likely supported")
else:
print("Touch screen not likely supported")
PS Still think it is better just to ask or get the user to indicate a preference.
PPS You could do a big button and say “Click or touch here to continue”. Then detect both clicks and touches. Then you would know for sure it is a touch screen if they touch. If they click it could still ‘possibly’ be or not.
Returns true if touch events are available (Android or iOS), the capability is detected on the Web platform or if ProjectSettings.input_devices/pointing/emulate_touch_from_mouse is true.
You misterunderstood my codes, I used OS.get_model_name() that returns only android or ios model name else generic device like pc, etc, you can find this in OS docs. Your codes is long and as well as same.