Flipper/Applications/Custom (UL, RM, XFW)/RogueMaster/Scripts/badusb_demo.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2024-02-28 05:53:59 +00:00
let badusb = require("badusb");
let notify = require("notification");
let flipper = require("flipper");
let dialog = require("dialog");
2024-04-17 10:33:29 +00:00
badusb.setup({
vid: 0xAAAA,
pid: 0xBBBB,
mfr_name: "Flipper",
prod_name: "Zero",
layout_path: "/ext/badusb/assets/layouts/en-US.kl"
});
2024-02-28 05:53:59 +00:00
dialog.message("BadUSB demo", "Press OK to start");
if (badusb.isConnected()) {
notify.blink("green", "short");
print("USB is connected");
badusb.println("Hello, world!");
badusb.press("CTRL", "a");
badusb.press("CTRL", "c");
badusb.press("DOWN");
delay(1000);
badusb.press("CTRL", "v");
delay(1000);
badusb.press("CTRL", "v");
badusb.println("1234", 200);
badusb.println("Flipper Model: " + flipper.getModel());
badusb.println("Flipper Name: " + flipper.getName());
badusb.println("Battery level: " + to_string(flipper.getBatteryCharge()) + "%");
2024-03-25 01:35:38 +00:00
// Alt+Numpad method works only on Windows!!!
badusb.altPrintln("This was printed with Alt+Numpad method!");
// There's also badusb.print() and badusb.altPrint()
// which don't add the return at the end
2024-02-28 05:53:59 +00:00
notify.success();
} else {
print("USB not connected");
notify.error();
}
// Optional, but allows to interchange with usbdisk
badusb.quit();