11

Is there any way to simulate a touch (anywhere) on the screen without root?

If not, is there any other way I can perform a cardboard 'select' action without magnet support, or opening up my cardboard every time?

Background

I am trying to get cardboard apps to work to work with a 5.1 phone which doesn't support the magnet 'button'.

Most apps seem to use the button to select or advance, so without it working, it is difficult to use. I have found that a touch anywhere on the screen also works as a select, so what I'm doing at the moment is opening the back, touching the screen and then closing it up again, but obviously that quickly gets tedious.

What I have tried:

  • Using my ipega 9017 gamepad (in Gamepad, Keyboard and iCade modes) no mode maps any key to anything which performs a select action in cardboard (though some modes map the B button to back, which works to exit a cardboard app at least).

  • I have tried Tincore Keymapper, but that requires root in order to simulate touch, and I cannot root my device.

  • Looking on here, custom keymapping for games?, Can I use USB gamepad without any setup? and Mouse to touch? looked most promising, but none of them answer this question.

4
  • Sending touch events requires root/system permissions, so like any other cardboard you need to have an actual magnet for the screen to detect as an input. Using a mouse (Bluetooth or USB) may be worth looking into.
    – GiantTree
    Jul 14, 2015 at 20:26
  • You can use an OTG cable and a mouse, provided that OTG is supported in your device.
    – Firelord
    Jul 14, 2015 at 20:33
  • Then tell me guys, how teamviewer does that? There is available version of teamviewer that allows to controll android device remotely just like it is done with the PC. So how TV simulates events ??? Jan 6, 2016 at 21:00
  • you can achieve this by using tasker and touchtask plugin without root. Tasker is a very powerful must have android app if you really like to automate your phone. It's a paid app but the money spent will be well worth it. Dec 4, 2018 at 2:04

3 Answers 3

10

You can potentially simulate a touch with the command input tap x y (e.g. from a terminal emulator, or possibly with Tasker (can't remember if it can do shell commands, but I presume so)), or over ADB with adb shell input tap x y. See https://stackoverflow.com/a/20830258/2141741 (and if you want to connect the device to itself via ADB, https://code.google.com/p/android/issues/detail?id=48126 and associated comments are informative).

This solution doesn't require root (at least not doing it from a computer connected over ADB).

1
  • This has been the simplest way I've found. Putting the command in a loop waiting for a key press does the trick nicely: $ while true; do read; adb shell input tap 0 0; echo pressed; done. It has a lot of lag though.
    – Álex
    Jan 2, 2017 at 15:24
2

I tried the what @user43185 proposed, but it won't work. But, as an alternative, I see that is possible to use the following.

input [text|keyevent]
input text <string>
input keyevent <event_code>
input motionevent <x> <y> <down|move|up>
input motionevent-batch <pointer-log>

For example, if I want a tap event, then I do:

adb shell input motionevent x y down
adb shell input motionevent x y up

Where x and y are the coordinates on the device.


UPDATE.

The reason why the other answer won't work, according to this answer, is because of the Android version at the device.

2
  • 1
    I guess it depends on the ADB version. In addition of those, I see tap, swipe, press and roll on ADB version 1.0.36.
    – Andrew T.
    Jan 18, 2017 at 3:47
  • I did a research, apparently it is because of the Android version that is on the device.
    – Zack
    Jan 19, 2017 at 18:25
1

I made it on Android 6.0 with the app Automate. You can download the Automate Flow here. Every time you click the headset button it runs the shell command "input tap 200 200".

1
  • this only worked in the automate app for me (android 9) but automate has an "interact touch click" action now, which works globally. and then i had to change the trigger to "key pressed headset hook" because the other one only worked when the app had no audio running...
    – ths
    Dec 3, 2020 at 1:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .