mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 21:35:59 +00:00
feat(ctl): input pen draws with a virtual pen through Android's input reader (#2639)
droiddeckctl input pen hover, tap, stroke and button register a virtual direct pen with `adb shell uinput -` and play the gesture through it, so Android's input reader makes the same stylus events a built-in pen does, with pressure, tilt, distance, the eraser and both side buttons. The app is not involved, which lets pen handling be tested without a pen. Positions are fractions of the screen as shown, placed inside the physical frame of the internal display viewport in dumpsys input: the frame is smaller than the panel when `wm size` sets another aspect ratio, and Android drops pen events outside it. The rotation and size come from the same viewport. The values are checked before anything runs on the device. The script waits 1 s after registering, since uinput reads it in one go and cannot wait for the device, and does not reset uinput's time base after that, which would drop the first samples. Contact sends a pressure of at least 1, because Android takes a pen at pressure 0 for a hovering one, and a lift first moves to where it lifts, because Android's UP repeats the last contact. A pen held still moves by one unit without leaving the physical frame so that it keeps reporting, since the kernel drops frames that change nothing. Co-authored-by: alien2003 <11610652+alien2003@users.noreply.github.com>
This commit is contained in:
1 parent
33cd43237e
commit
de70e37f30
4 files changed
+515
-3
No files matched your search
@@ -122,6 +122,10 @@ tools/droiddeckctl input swipe 100 600 100 100 --duration 400
|
||||
tools/droiddeckctl input pad a
|
||||
tools/droiddeckctl input stick left 0 -1 --hold 500
|
||||
tools/droiddeckctl input trigger right 1.0
|
||||
tools/droiddeckctl input pen tap 0.5 0.5 --pressure 0.7
|
||||
tools/droiddeckctl input pen stroke 0.2 0.5 0.8 0.5 --pressure 0.1:0.9 --tilt-x=-30:30
|
||||
tools/droiddeckctl input pen hover 0.3 0.5 --to 0.7 0.5 --duration 600
|
||||
tools/droiddeckctl input pen button primary 0.5 0.5
|
||||
|
||||
tools/droiddeckctl ui dump
|
||||
tools/droiddeckctl ui click rail-steam
|
||||
@@ -196,6 +200,20 @@ virtual pad, the same one the on-screen controls drive, so games that ignore tou
|
||||
`launch`, `quit` and `cdp` need a Steam session; `focus` and `wait focused` need gamescope (every
|
||||
mode except the desktop).
|
||||
|
||||
`input pen` does not go through the app. It registers a virtual pen with `adb shell uinput -`, so
|
||||
Android's own input reader makes the stylus events, as for a built-in pen, and it works on whatever
|
||||
is on screen, without a session or Setup > Developer > Debugging tools. Positions are fractions of
|
||||
the screen as shown; `dumpsys input` gives the frame, rotation and size of the display Android maps
|
||||
internal touchscreens to. `hover` comes near and glides to `--to`; `tap`, `stroke` and `button`
|
||||
hover for `--hover-ms` (80) before and after the touch or the button press. Each takes
|
||||
`--tool pen|eraser`, `--tilt-x` and `--tilt-y` in degrees, `--distance` in device units (0 to 255)
|
||||
and `--rate` (120 samples a second); `--pressure` and tilt take `FROM:TO` ranges, written
|
||||
`--tilt-x=-30:30` when they start negative. A gesture lasts at most 30 s. `UINPUT_UNAVAILABLE`
|
||||
means the shell has no `uinput` or cannot write `/dev/uinput`, `NO_VIEWPORT` that there is no
|
||||
internal display or it is off, and `UINPUT_FAILED` that `uinput` stopped early; all three exit 3.
|
||||
It needs Android 14 QPR2 or later: the `uinput` of Android 12 to 14 QPR1 takes only numeric codes
|
||||
and the USB or Bluetooth bus, so there the pen ends with `UINPUT_FAILED`.
|
||||
|
||||
## State (schema 2)
|
||||
|
||||
`state` returns `schema`, `build`, `appVersion`, `runtime {installed, version}`,
|
||||
|
||||
Reference in new issue
Block a user