mirror of
https://github.com/Creased/RCM-Emulator.git
synced 2026-12-06 02:48:11 +01:00
Tap the touchscreen from --input-script
The input script pressed POWER and the volume buttons only, so touch- driven payloads - Nyx above all - could not be driven headless. `<ms> TAP <x> <y> [hold_ms]` touches the screen at (x, y) in the 1280x720 picture bdk's touch driver reports, inverted through its 15..1264 / 15..704 scaling to the FTS4 panel's raw coordinates, and lifts after hold_ms. The press and release go through the same event queue as a mouse click in the window. This is how Nyx's Tools > USB Tools > SD Card is reached headless: "12000 TAP 516 531, 15000 TAP 640 32, 17000 TAP 640 423, 19000 TAP 850 420, 22000 TAP 170 202" on hekate 6.5.3. The README now documents --input-script, which it did not mention before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YYewwDPujjo5B2xRyC5Grb
This commit is contained in:
3 files changed
+59
-4
No files matched your search
@@ -631,7 +631,11 @@ while (te_idx < n && state.emu_usec >= te_events[te_idx].at_us) {
|
|||||||
|
|
||||||
Because `emu_usec` is deterministic, the same timestamps land at the same UI
|
Because `emu_usec` is deterministic, the same timestamps land at the same UI
|
||||||
states across runs. Adding a new automated flow is "press the buttons once
|
states across runs. Adding a new automated flow is "press the buttons once
|
||||||
with `[input]` logging on, copy the timestamps".
|
with `[input]` logging on, copy the timestamps". `--input-script` does the
|
||||||
|
same for any payload without a rebuild (`input_script.cpp`): button presses
|
||||||
|
and touchscreen taps (`<ms> TAP <x> <y>`, in the 1280x720 picture, inverted
|
||||||
|
through bdk's touch scaling) keyed to `emu_usec`. That is how Nyx's USB tools
|
||||||
|
are reached headless.
|
||||||
|
|
||||||
## CCPLEX CPU0
|
## CCPLEX CPU0
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ slow or destructive.
|
|||||||
[CCPLEX CPU0](#ccplex-cpu0).
|
[CCPLEX CPU0](#ccplex-cpu0).
|
||||||
- Replay deterministic button sequences via `--auto-pin-recovery` or
|
- Replay deterministic button sequences via `--auto-pin-recovery` or
|
||||||
`--auto-te-script`, so a payload flow can be exercised from a CI run or a
|
`--auto-te-script`, so a payload flow can be exercised from a CI run or a
|
||||||
one-shot script.
|
one-shot script. `--input-script` scripts buttons and touchscreen taps for
|
||||||
|
any payload.
|
||||||
- Tweak emulated hardware live (battery, charger, thermal, USB-PD, PMIC,
|
- Tweak emulated hardware live (battery, charger, thermal, USB-PD, PMIC,
|
||||||
fuses, SD insertion) from a side window. See [Live hardware tweaks](#live-hardware-tweaks).
|
fuses, SD insertion) from a side window. See [Live hardware tweaks](#live-hardware-tweaks).
|
||||||
- Inspect each Tegra UART port (TX history) and inject keystrokes into the
|
- Inspect each Tegra UART port (TX history) and inject keystrokes into the
|
||||||
@@ -278,6 +279,7 @@ needed.
|
|||||||
| `--oem` | `erista` \| `mariko` | Switch SoC generation. Drives `APB_MISC_GP_HIDREV` so Hekate's `h_cfg.t210b01` matches and pkg1 identification skips the right OEM header. Default `erista`. |
|
| `--oem` | `erista` \| `mariko` | Switch SoC generation. Drives `APB_MISC_GP_HIDREV` so Hekate's `h_cfg.t210b01` matches and pkg1 identification skips the right OEM header. Default `erista`. |
|
||||||
| `--bt-radio` | `healthy` \| `faulty` \| `absent` | Broadcom CYW4356 behaviour on UART-D. `healthy` powers up on the `BT_REG_ON` edge, holds `BT_HOST_WAKE` high, asserts `RTS_N` and answers HCI; `faulty` reproduces the 2110-1118 console (module fitted, never leaves POR); `absent` additionally leaves `BT_UART_RXD` in a break condition. Overrides `[bluetooth] radio` in the ini. Default `healthy`. |
|
| `--bt-radio` | `healthy` \| `faulty` \| `absent` | Broadcom CYW4356 behaviour on UART-D. `healthy` powers up on the `BT_REG_ON` edge, holds `BT_HOST_WAKE` high, asserts `RTS_N` and answers HCI; `faulty` reproduces the 2110-1118 console (module fitted, never leaves POR); `absent` additionally leaves `BT_UART_RXD` in a break condition. Overrides `[bluetooth] radio` in the ini. Default `healthy`. |
|
||||||
| `--wifi-radio` | `healthy` \| `faulty` \| `absent` | The WLAN half of the same CYW4356: a PCI Express endpoint on root port 1, reachable only from CPU0 (the BPMP reads all ones, as on silicon). `healthy` trains the link, enumerates as `14E4:43EC` and answers a ChipCommon ChipID read with `0x4356`; `faulty` still trains and enumerates but reads all ones on the backplane (live PCIe front-end, dead radio die); `absent` never leaves detect. The model also enforces the datasheet's power-up ordering, so a payload that releases PERST# too early gets a link that stays down and a `[pcie]` line naming the reason. Overrides `[wifi] radio` in the ini. Default `healthy`. |
|
| `--wifi-radio` | `healthy` \| `faulty` \| `absent` | The WLAN half of the same CYW4356: a PCI Express endpoint on root port 1, reachable only from CPU0 (the BPMP reads all ones, as on silicon). `healthy` trains the link, enumerates as `14E4:43EC` and answers a ChipCommon ChipID read with `0x4356`; `faulty` still trains and enumerates but reads all ones on the backplane (live PCIe front-end, dead radio die); `absent` never leaves detect. The model also enforces the datasheet's power-up ordering, so a payload that releases PERST# too early gets a link that stays down and a `[pcie]` line naming the reason. Overrides `[wifi] radio` in the ini. Default `healthy`. |
|
||||||
|
| `--input-script` | file or spec | Scripted input keyed to emulated time: `<ms> P\|U\|D [hold_ms]` presses POWER / VOL+ / VOL-, `<ms> TAP <x> <y> [hold_ms]` taps the touchscreen at (x, y) in the 1280x720 picture, `+N` times an event N ms after the previous one. Events are separated by `,`, `;` or newlines. |
|
||||||
| `--auto-pin-recovery` | (none) | Drive the Lockpick PIN-recovery menu without user input. |
|
| `--auto-pin-recovery` | (none) | Drive the Lockpick PIN-recovery menu without user input. |
|
||||||
| `--auto-te-script` | (none) | Drive `recover_pin.te` in TegraExplorer without input. |
|
| `--auto-te-script` | (none) | Drive `recover_pin.te` in TegraExplorer without input. |
|
||||||
|
|
||||||
|
|||||||
+51
-2
@@ -12,6 +12,11 @@
|
|||||||
// VOL_UP | VOLUP | UP | U
|
// VOL_UP | VOLUP | UP | U
|
||||||
// hold_ms how long to hold the button, default 200 ms.
|
// hold_ms how long to hold the button, default 200 ms.
|
||||||
//
|
//
|
||||||
|
// <when> TAP <x> <y> [hold_ms]
|
||||||
|
//
|
||||||
|
// touches the screen at (x, y) in the 1280x720 landscape picture bdk's
|
||||||
|
// touch driver reports (Nyx's coordinates), and lifts after hold_ms.
|
||||||
|
//
|
||||||
// '#' starts a comment. Example - walk 6 entries down a menu and select:
|
// '#' starts a comment. Example - walk 6 entries down a menu and select:
|
||||||
//
|
//
|
||||||
// rcm_emu payload.bin --input-script "3000 D, + D, + D, + D, + D, + D, + P"
|
// rcm_emu payload.bin --input-script "3000 D, + D, + D, + D, + D, + D, + P"
|
||||||
@@ -27,6 +32,7 @@
|
|||||||
#include "input_script.h"
|
#include "input_script.h"
|
||||||
#include "emu_state.h"
|
#include "emu_state.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cctype>
|
#include <cctype>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@@ -36,7 +42,7 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
enum class Key { Power, VolUp, VolDown, Uart, UartFile };
|
enum class Key { Power, VolUp, VolDown, Uart, UartFile, Tap };
|
||||||
|
|
||||||
struct Event {
|
struct Event {
|
||||||
uint64_t at_us = 0; // press time
|
uint64_t at_us = 0; // press time
|
||||||
@@ -45,6 +51,7 @@ struct Event {
|
|||||||
bool pressed = false;
|
bool pressed = false;
|
||||||
bool released = false;
|
bool released = false;
|
||||||
std::string data; // UART / UARTFILE payload
|
std::string data; // UART / UARTFILE payload
|
||||||
|
uint16_t x = 0, y = 0; // TAP: panel-raw coordinates
|
||||||
};
|
};
|
||||||
|
|
||||||
std::vector<Event> g_events;
|
std::vector<Event> g_events;
|
||||||
@@ -60,6 +67,7 @@ const char *key_name(Key k) {
|
|||||||
case Key::VolUp: return "VOL+";
|
case Key::VolUp: return "VOL+";
|
||||||
case Key::Uart: return "UART";
|
case Key::Uart: return "UART";
|
||||||
case Key::UartFile: return "UARTFILE";
|
case Key::UartFile: return "UARTFILE";
|
||||||
|
case Key::Tap: return "TAP";
|
||||||
default: return "VOL-";
|
default: return "VOL-";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -80,6 +88,7 @@ bool parse_key(const std::string &tok, Key *out) {
|
|||||||
// UARTFILE pushes a file's raw contents, for binary protocol work.
|
// UARTFILE pushes a file's raw contents, for binary protocol work.
|
||||||
if (s == "UART") { *out = Key::Uart; return true; }
|
if (s == "UART") { *out = Key::Uart; return true; }
|
||||||
if (s == "UARTFILE") { *out = Key::UartFile; return true; }
|
if (s == "UARTFILE") { *out = Key::UartFile; return true; }
|
||||||
|
if (s == "TAP" || s == "T") { *out = Key::Tap; return true; }
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +193,23 @@ bool parse_text(const std::string &text) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t hold_ms = (tok.size() >= 3) ? strtoull(tok[2].c_str(), nullptr, 10)
|
size_t hold_tok = 2;
|
||||||
|
if (ev.key == Key::Tap) {
|
||||||
|
if (tok.size() < 4) {
|
||||||
|
fprintf(stderr, "[input-script] entry %d: expected '<when> TAP <x> <y> [hold_ms]'\n",
|
||||||
|
lineno);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// bdk's touch.c clamps raw samples to 15..1264 and 15..704 and
|
||||||
|
// stretches that span over 1280x720; invert it.
|
||||||
|
uint32_t x = std::min<uint32_t>(strtoul(tok[2].c_str(), nullptr, 10), 1279);
|
||||||
|
uint32_t y = std::min<uint32_t>(strtoul(tok[3].c_str(), nullptr, 10), 719);
|
||||||
|
ev.x = (uint16_t)(15 + (x * (1264 - 15) + 1279) / 1280);
|
||||||
|
ev.y = (uint16_t)(15 + (y * (704 - 15) + 719) / 720);
|
||||||
|
hold_tok = 4;
|
||||||
|
}
|
||||||
|
uint64_t hold_ms = (tok.size() > hold_tok)
|
||||||
|
? strtoull(tok[hold_tok].c_str(), nullptr, 10)
|
||||||
: kDefaultHoldMs;
|
: kDefaultHoldMs;
|
||||||
if (hold_ms == 0) hold_ms = kDefaultHoldMs;
|
if (hold_ms == 0) hold_ms = kDefaultHoldMs;
|
||||||
ev.until_us = ev.at_us + hold_ms * 1000ULL;
|
ev.until_us = ev.at_us + hold_ms * 1000ULL;
|
||||||
@@ -271,6 +296,30 @@ void input_script_tick(EmuState &state) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ev.key == Key::Tap) {
|
||||||
|
if (!ev.pressed && now >= ev.at_us) {
|
||||||
|
state.tc_pressed.store(true);
|
||||||
|
state.touch_post(0x03, ev.x, ev.y); // FTS4 ENTER
|
||||||
|
ev.pressed = true;
|
||||||
|
printf("[input-script] TAP down panel=(%u,%u) @%llu us (%zu/%zu)\n",
|
||||||
|
ev.x, ev.y, (unsigned long long)now, i + 1, g_events.size());
|
||||||
|
fflush(stdout);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (ev.pressed && !ev.released && now >= ev.until_us) {
|
||||||
|
state.tc_pressed.store(false);
|
||||||
|
state.touch_post(0x04, ev.x, ev.y); // FTS4 LEAVE
|
||||||
|
ev.released = true;
|
||||||
|
if (i == g_done) {
|
||||||
|
g_done++;
|
||||||
|
if (g_done == g_events.size())
|
||||||
|
printf("[input-script] sequence complete\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ev.released) break;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
std::atomic<bool> *btn = (ev.key == Key::Power) ? &state.btn_power
|
std::atomic<bool> *btn = (ev.key == Key::Power) ? &state.btn_power
|
||||||
: (ev.key == Key::VolUp) ? &state.btn_vol_up
|
: (ev.key == Key::VolUp) ? &state.btn_vol_up
|
||||||
: &state.btn_vol_down;
|
: &state.btn_vol_down;
|
||||||
|
|||||||
Reference in new issue
Block a user