Skip to content

Commit

Permalink
Merge pull request #214 from Zondax/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosala authored Mar 31, 2023
2 parents 90ca2b2 + 47f1bff commit 0119e62
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
22 changes: 15 additions & 7 deletions src/Zemu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<number> {
async enableSpecialMode(
nanoModeText: string,
staxToggleSettingButton?: ButtonKind,
path = ".",
testcaseName = "",
waitForScreenUpdate = true,
takeSnapshots = false,
startImgIndex = 0
): Promise<number> {
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
);
Expand All @@ -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);
}
}

Expand Down
9 changes: 4 additions & 5 deletions src/zondax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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);
}

Expand All @@ -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,
]);
Expand Down

0 comments on commit 0119e62

Please sign in to comment.