5

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.

  • 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 '15 at 20:26
  • You can use an OTG cable and a mouse, provided that OTG is supported in your device. – Firelord Jul 14 '15 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 ??? – Antoniossss Jan 6 '16 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. – shengwu zhang Dec 4 '18 at 2:04
8

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).

  • Thanks Josh, I will look into whether I can make use of this to solve my problem. – Mark Booth Jul 15 '15 at 11:05
  • 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 '17 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.

  • 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 '17 at 3:47
  • I did a research, apparently it is because of the Android version that is on the device. – Zack Jan 19 '17 at 18:25
0

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".

protected by Community Dec 5 '18 at 14:38

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.