'Disable and enable android touchscreen via adb

I need to disable and enable touchscreen on my android device. I tried this

adb shell su rm -rf /dev/input/event2 

and

adb shell su rm -rf /dev/input/event0

but have

tmp-mksh: tmp-mksh: - : unknown option

What command do I need to send to turn touch screen off and then on?



Solution 1:[1]

I know, much too late for you, but maybe it might help others (as me, who found your thread). This is how it finally worked out for me with separate commands.

  • Requires adb root access to be enabled in android dev-settings.
  • In the third command, event1 can even be any other of the events in that folder. From my experience these events restore fully on reboot, so don't hesitate to try deleting them one by one.
  • This completely disables touch & access via mouse. However scrcpy still works, even with input.
    adb root
    adb shell
    rm -rf /dev/input/event1

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jonas