touch-ctl¶
Reversibly enable and disable the touchscreen. Designed for devices with a cracked screen suffering from ghost touch (phantom touches), but useful in any scenario where you want to guarantee the screen only responds to your command (via SSH) and not to physical noise.
Requires root
Manipulates character device nodes in /dev/input/eventN via mknod + rm.
Basic usage¶
touch-ctl status # touch enabled or disabled?
touch-ctl off # disable (saves everything to restore)
touch-ctl on # re-enable
touch-ctl off --name NAME # if your touch is not called "touchpanel"
touch-ctl --help
How it works (and why it's safe)¶
Older versions of this script simply did mv /dev/input/eventN
~/event_touch. That works, but if the /data partition is wiped or
/dev/input is recreated by boot, the file disappears and the touch is
"lost". The current version does it differently:
flowchart TD
A[touch-ctl off] --> B[Find touchscreen in /sys/class/input]
B --> C[Read major:minor from sysfs]
C --> D[Pre-flight: mknod on temp file]
D --> E{mknod works?}
E -- no --> F[Abort: nothing was changed]
E -- yes --> G[Remove the /dev/input/eventN node]
G --> H[Android notices via inotify\nInputReader drops the device]
H --> I[Touch disabled]
I --> J[touch-ctl on\nRecreate node via mknod\nwith major:minor from sysfs]
Key points:
- The device still exists in the kernel — only the node in
/dev/inputis removed. The kernel still sees it at/sys/class/input/event*/device/. - Pre-flight
mknodtest: before removing the real node, the script proves it can recreate it by creating a temp file. If that fails, aborts before touching the real node. - Self-restoration: if
offfails after removing the node, anEXITtrap tries to recreate it automatically. - State file:
/data/local/tmp/touch-ctl.statestoresEVENT,DEVNUM,MODE,OWNER, and a timestamp — for manual restoration if everything goes very wrong.
Symlink shortcuts¶
touch-ctl recognizes the name it was invoked with. Create shortcuts to use
as separate commands:
ln -s touch-ctl touch-off
ln -s touch-ctl touch-on
ln -s touch-ctl touch-status
# now: touch-off, touch-on, touch-status work directly
Also recognizes old names: desativar-touch, ativar-touch.
--name for different hardware¶
The touchscreen name in sysfs varies by manufacturer. Default is touchpanel
(common on Unisoc/Samsung Go). If not found:
touch-ctl status
# prints: "device 'touchpanel' not found"
# lists all /sys/class/input/event*/device/name entries
Look in the list for your touch name (e.g. fts_ts, goodix_ts,
nt36672a_ts, sec_ts) and use:
Make it persistent with the TOUCH_NAME env var:
Exit codes¶
| Code | Meaning | What to do |
|---|---|---|
0 |
success | — |
1 |
operation failed (mknod, rm, etc.) | see message; try touch-ctl on |
2 |
invalid usage (bad argument) | touch-ctl --help |
3 |
no root | Magisk → Superuser → Termux |
4 |
touch not found in /sys/class/input |
use --name |
Recovery if the screen doesn't respond¶
After touch-ctl off, the device only responds to a physical keyboard or
SSH until you run touch-ctl on (or until reboot — /dev/input is recreated
on boot, so touch comes back).
ALWAYS have one of these ready before using off:
- SSH running in Termux (
sshdortmux+ active session); - ADB connected (
adb shellfrom a PC); - Physical keyboard via OTG/Bluetooth;
- AnyDesk/Scrcpy accessible from another machine.
If none of those is available and touch is off, reboot the device (hold power ~10 s) — boot recreates the node and touch returns.
Migration from the old method¶
If you used the old version (which moved the node to ~/event_touch), the new
touch-ctl on detects the legacy file, uses it as fallback for restoration,
then removes it — transparent migration.
Files¶
| Path | What |
|---|---|
/sys/class/input/event*/device/name |
Input device names (read) |
/sys/class/input/event*/dev |
major:minor (read) |
/dev/input/eventN |
Char device node manipulated |
/data/local/tmp/touch-ctl.state |
Saved state for restoration |
~/event_touch |
Legacy (old method, migrated and removed) |
Environment variables¶
| Variable | Default | What |
|---|---|---|
TOUCH_NAME |
touchpanel |
Touchscreen name in sysfs |
TOUCH_SYS_INPUT |
/sys/class/input |
sysfs input root |
TOUCH_DEV_INPUT |
/dev/input |
Device node root |
TOUCH_STATE |
/data/local/tmp/touch-ctl.state |
State file |
TOUCHCTL_COLOR |
auto | 1 forces colors, 0 disables |
See also¶
- Security — "don't touch if you can't undo" rationale.
- Troubleshooting — touch stuck off and SSH dropped.
- Architecture — where
/dev/inputfits in the Android stack.