From a1993a528dde08156a9e5616f6879783000049ce Mon Sep 17 00:00:00 2001 From: MX <10697207+xMasterX@users.noreply.github.com> Date: Wed, 16 Oct 2024 01:11:34 +0300 Subject: [PATCH] badusb js paritally fix --- .../apps/Scripts/js_examples/badusb_demo.js | 9 +++++---- applications/system/js_app/types/badusb/index.d.ts | 13 ++++++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/applications/system/js_app/examples/apps/Scripts/js_examples/badusb_demo.js b/applications/system/js_app/examples/apps/Scripts/js_examples/badusb_demo.js index 63c0505a5..2bcf736c2 100644 --- a/applications/system/js_app/examples/apps/Scripts/js_examples/badusb_demo.js +++ b/applications/system/js_app/examples/apps/Scripts/js_examples/badusb_demo.js @@ -1,15 +1,16 @@ let badusb = require("badusb"); let notify = require("notification"); let flipper = require("flipper"); -let dialog = require("dialog"); let gui = require("gui"); let dialog = require("gui/dialog"); + +// TODO: Add event loop from ofw badusb.setup({ vid: 0xAAAA, pid: 0xBBBB, - mfr_name: "Flipper", - prod_name: "Zero", + mfrName: "Flipper", + prodName: "Zero", layout_path: "/ext/badusb/assets/layouts/en-US.kl" }); let views = { @@ -38,7 +39,7 @@ if (badusb.isConnected()) { badusb.println("Flipper Model: " + flipper.getModel()); badusb.println("Flipper Name: " + flipper.getName()); - badusb.println("Battery level: " + to_string(flipper.getBatteryCharge()) + "%"); + badusb.println("Battery level: " + toString(flipper.getBatteryCharge()) + "%"); // Alt+Numpad method works only on Windows!!! badusb.altPrintln("This was printed with Alt+Numpad method!"); diff --git a/applications/system/js_app/types/badusb/index.d.ts b/applications/system/js_app/types/badusb/index.d.ts index 647382dc0..4b49dc991 100644 --- a/applications/system/js_app/types/badusb/index.d.ts +++ b/applications/system/js_app/types/badusb/index.d.ts @@ -34,7 +34,7 @@ export type KeyCode = MainKey | ModifierKey | number; * @brief Initializes the module * @param settings USB device settings. Omit to select default parameters */ -export declare function setup(settings?: { vid: number, pid: number, mfrName?: string, prodName?: string }): void; +export declare function setup(settings?: { vid: number, pid: number, mfrName?: string, prodName?: string, layout_path: string }): void; /** * @brief Tells whether the virtual USB HID device has successfully connected @@ -79,3 +79,14 @@ export declare function print(string: string, delay?: number): void; * @param delay How many milliseconds to wait between key presses */ export declare function println(string: string, delay?: number): void; + +/** + * @brief Prints a string by Alt+Numpad method - works only on Windows! + * @param string The string to print + */ +export declare function altPrintln(string: string): void; + +/** + * @brief Releases usb, Optional, but allows to interchange with usbdisk + */ +export declare function quit(): void;