2021-11-26 16:53:51 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <furi.h>
|
2023-03-09 20:42:34 +03:00
|
|
|
#include <furi_hal.h>
|
2021-11-26 16:53:51 +03:00
|
|
|
|
2023-03-09 20:42:34 +03:00
|
|
|
#define FILE_BUFFER_LEN 16
|
2021-11-26 16:53:51 +03:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
BadUsbStateInit,
|
|
|
|
BadUsbStateNotConnected,
|
|
|
|
BadUsbStateIdle,
|
2022-11-03 08:21:44 +03:00
|
|
|
BadUsbStateWillRun,
|
2021-11-26 16:53:51 +03:00
|
|
|
BadUsbStateRunning,
|
|
|
|
BadUsbStateDelay,
|
|
|
|
BadUsbStateDone,
|
|
|
|
BadUsbStateScriptError,
|
|
|
|
BadUsbStateFileError,
|
|
|
|
} BadUsbWorkerState;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
BadUsbWorkerState state;
|
|
|
|
uint16_t line_cur;
|
|
|
|
uint16_t line_nb;
|
|
|
|
uint32_t delay_remain;
|
|
|
|
uint16_t error_line;
|
2022-10-12 19:21:54 +03:00
|
|
|
char error[64];
|
2021-11-26 16:53:51 +03:00
|
|
|
} BadUsbState;
|
|
|
|
|
2023-03-09 20:42:34 +03:00
|
|
|
typedef struct BadUsbScript {
|
|
|
|
FuriHalUsbHidConfig hid_cfg;
|
|
|
|
BadUsbState st;
|
|
|
|
FuriString* file_path;
|
|
|
|
uint32_t defdelay;
|
|
|
|
uint16_t layout[128];
|
|
|
|
uint32_t stringdelay;
|
|
|
|
FuriThread* thread;
|
|
|
|
uint8_t file_buf[FILE_BUFFER_LEN + 1];
|
|
|
|
uint8_t buf_start;
|
|
|
|
uint8_t buf_len;
|
|
|
|
bool file_end;
|
|
|
|
FuriString* line;
|
|
|
|
|
|
|
|
FuriString* line_prev;
|
|
|
|
uint32_t repeat_cnt;
|
|
|
|
} BadUsbScript;
|
|
|
|
|
2022-10-05 18:15:23 +03:00
|
|
|
BadUsbScript* bad_usb_script_open(FuriString* file_path);
|
2021-11-26 16:53:51 +03:00
|
|
|
|
|
|
|
void bad_usb_script_close(BadUsbScript* bad_usb);
|
|
|
|
|
2023-02-08 18:01:00 +03:00
|
|
|
void bad_usb_script_set_keyboard_layout(BadUsbScript* bad_usb, FuriString* layout_path);
|
|
|
|
|
2021-11-26 16:53:51 +03:00
|
|
|
void bad_usb_script_start(BadUsbScript* bad_usb);
|
|
|
|
|
|
|
|
void bad_usb_script_stop(BadUsbScript* bad_usb);
|
|
|
|
|
|
|
|
void bad_usb_script_toggle(BadUsbScript* bad_usb);
|
|
|
|
|
|
|
|
BadUsbState* bad_usb_script_get_state(BadUsbScript* bad_usb);
|
|
|
|
|
2023-03-09 20:42:34 +03:00
|
|
|
uint16_t ducky_get_keycode(BadUsbScript* bad_usb, const char* param, bool accept_chars);
|
|
|
|
|
|
|
|
uint32_t ducky_get_command_len(const char* line);
|
|
|
|
|
|
|
|
bool ducky_is_line_end(const char chr);
|
|
|
|
|
2021-11-26 16:53:51 +03:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|