From 47f1bff140bde79d853cdafb4207309810663394 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Fri, 31 Mar 2023 17:01:36 +0200 Subject: [PATCH] feat!: add enableSpecialMode --- src/Zemu.ts | 22 +++++++++++++++------- src/zondax.ts | 9 ++++----- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/Zemu.ts b/src/Zemu.ts index 7bac254..8fb7fb2 100644 --- a/src/Zemu.ts +++ b/src/Zemu.ts @@ -60,7 +60,7 @@ import { type IStartOptions, type TModel, } from "./types"; -import { zondaxToggleExpertMode, zondaxStaxActivateShortcutMode } from "./zondax"; +import { zondaxToggleExpertMode, zondaxStaxEnableSpecialMode } from "./zondax"; export default class Zemu { private startOptions!: IStartOptions; @@ -398,14 +398,22 @@ export default class Zemu { return await this.navigate(".", testcaseName, nav.schedule, true, takeSnapshots, startImgIndex); } - async activateShortcutMode(testcaseName = "", takeSnapshots = false, startImgIndex = 0): Promise { + async enableSpecialMode( + nanoModeText: string, + staxToggleSettingButton?: ButtonKind, + path = ".", + testcaseName = "", + waitForScreenUpdate = true, + takeSnapshots = false, + startImgIndex = 0 + ): Promise { if (this.startOptions.model !== "stax") { const expertImgIndex = await this.toggleExpertMode(testcaseName, takeSnapshots, startImgIndex); const tmpImgIndex = await this.navigateUntilText( - ".", + path, testcaseName, - "Shortcut", - true, + nanoModeText, + waitForScreenUpdate, takeSnapshots, expertImgIndex ); @@ -418,8 +426,8 @@ export default class Zemu { tmpImgIndex ); } else { - const nav = zondaxStaxActivateShortcutMode(); - return await this.navigate(".", testcaseName, nav.schedule, true, takeSnapshots, startImgIndex); + const nav = zondaxStaxEnableSpecialMode(staxToggleSettingButton); + return await this.navigate(path, testcaseName, nav.schedule, waitForScreenUpdate, takeSnapshots, startImgIndex); } } diff --git a/src/zondax.ts b/src/zondax.ts index ca9d23f..35eea35 100644 --- a/src/zondax.ts +++ b/src/zondax.ts @@ -16,9 +16,6 @@ import { ClickNavigation, TouchNavigation } from "./actions"; import { ButtonKind, type TModel } from "./types"; -const DEFAULT_MAINMENU_CLICKS = [1, 0, 0, 4, -5]; -const DEFAULT_EXPERT_MODE_CLICKS = [1, 0, -1]; - export function zondaxMainmenuNavigation(model: TModel, clickArray?: number[]): ClickNavigation | TouchNavigation { if (model === "stax") { return new TouchNavigation([ @@ -29,6 +26,7 @@ export function zondaxMainmenuNavigation(model: TModel, clickArray?: number[]): ButtonKind.PrevPageButton, ]); } + const DEFAULT_MAINMENU_CLICKS = [1, 0, 0, 4, -5]; return new ClickNavigation(clickArray ?? DEFAULT_MAINMENU_CLICKS); } @@ -41,17 +39,18 @@ export function zondaxToggleExpertMode(model: TModel, clickArray?: number[]): Cl ButtonKind.PrevPageButton, ]); } + const DEFAULT_EXPERT_MODE_CLICKS = [1, 0, -1]; return new ClickNavigation(clickArray ?? DEFAULT_EXPERT_MODE_CLICKS); } -export function zondaxStaxActivateShortcutMode(): TouchNavigation { +export function zondaxStaxEnableSpecialMode(toggleSettingButton?: ButtonKind): TouchNavigation { return new TouchNavigation([ ButtonKind.InfoButton, ButtonKind.NavRightButton, ButtonKind.ToggleSettingButton1, ButtonKind.NavLeftButton, ButtonKind.NavRightButton, - ButtonKind.ToggleSettingButton2, + toggleSettingButton ?? ButtonKind.ToggleSettingButton2, ButtonKind.TapContinueButton, ButtonKind.ConfirmYesButton, ]);