diff --git a/applications/plugins/usb_hid_autofire/.github/workflows/build-test.yml b/applications/plugins/usb_hid_autofire/.github/workflows/build-test.yml new file mode 100644 index 000000000..21a93b76d --- /dev/null +++ b/applications/plugins/usb_hid_autofire/.github/workflows/build-test.yml @@ -0,0 +1,32 @@ +name: Build + +on: + pull_request: + push: + branches: + - main + workflow_dispatch: + +jobs: + build: + runs-on: ubuntu-latest + name: Build application + steps: + - name: Cache toolchain + uses: actions/cache@v3 + id: toolchain-cache + with: + path: ./firmware + key: firmware + - name: Checkout firmware + if: steps.toolchain-cache.outputs.cache-hit != 'true' + run: git clone https://github.com/flipperdevices/flipperzero-firmware.git --recursive --depth 1 firmware + - name: Install toolchain + if: steps.toolchain-cache.outputs.cache-hit != 'true' + run: cd firmware && ./fbt + - name: Checkout application + uses: actions/checkout@v3 + with: + path: firmware/applications_user/usb_hid_autofire + - name: Build application + run: cd firmware && ./fbt fap_usb_hid_autofire diff --git a/applications/plugins/usb_hid_autofire/screenshot.png b/applications/plugins/usb_hid_autofire/screenshot.png index d2053c13d..b5547e1ba 100644 Binary files a/applications/plugins/usb_hid_autofire/screenshot.png and b/applications/plugins/usb_hid_autofire/screenshot.png differ diff --git a/applications/plugins/usb_hid_autofire/usb_hid_autofire.c b/applications/plugins/usb_hid_autofire/usb_hid_autofire.c index 2e7a096d9..47cabdcdb 100644 --- a/applications/plugins/usb_hid_autofire/usb_hid_autofire.c +++ b/applications/plugins/usb_hid_autofire/usb_hid_autofire.c @@ -20,9 +20,13 @@ typedef struct { } UsbMouseEvent; bool btn_left_autofire = false; +uint32_t autofire_delay = 10; static void usb_hid_autofire_render_callback(Canvas* canvas, void* ctx) { UNUSED(ctx); + char autofire_delay_str[12]; + itoa(autofire_delay, autofire_delay_str, 10); + canvas_clear(canvas); canvas_set_font(canvas, FontPrimary); @@ -33,6 +37,8 @@ static void usb_hid_autofire_render_callback(Canvas* canvas, void* ctx) { canvas_draw_str(canvas, 96, 10, VERSION); canvas_draw_str(canvas, 0, 22, "Press [ok] for auto left clicking"); canvas_draw_str(canvas, 0, 34, btn_left_autofire ? "" : ""); + canvas_draw_str(canvas, 0, 46, "delay [ms]:"); + canvas_draw_str(canvas, 50, 46, autofire_delay_str); canvas_draw_str(canvas, 0, 63, "Press [back] to exit"); } @@ -45,10 +51,6 @@ static void usb_hid_autofire_input_callback(InputEvent* input_event, void* ctx) furi_message_queue_put(event_queue, &event, FuriWaitForever); } -//void wait(int ticks) { -// for (int i = 0; i < ticks; i++) {} -//} - int32_t usb_hid_autofire_app(void* p) { UNUSED(p); FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(UsbMouseEvent)); @@ -78,17 +80,34 @@ int32_t usb_hid_autofire_app(void* p) { break; } - if(event.input.key == InputKeyOk && event.input.type == InputTypeRelease) { - btn_left_autofire = !btn_left_autofire; + if(event.input.type != InputTypeRelease) { + continue; + } + + switch(event.input.key) { + case InputKeyOk: + btn_left_autofire = !btn_left_autofire; + break; + case InputKeyLeft: + if(autofire_delay > 0) { + autofire_delay -= 10; + } + break; + case InputKeyRight: + autofire_delay += 10; + break; + default: + break; } } } if(btn_left_autofire) { furi_hal_hid_mouse_press(HID_MOUSE_BTN_LEFT); - // wait(100); + // TODO: Don't wait, but use the timer directly to just don't send the release event (see furi_hal_cortex_delay_us) + furi_delay_us(autofire_delay * 500); furi_hal_hid_mouse_release(HID_MOUSE_BTN_LEFT); - // wait(100); + furi_delay_us(autofire_delay * 500); } view_port_update(view_port); diff --git a/applications/plugins/usb_hid_autofire/version.h b/applications/plugins/usb_hid_autofire/version.h index 0502a24e9..41c8b38b7 100644 --- a/applications/plugins/usb_hid_autofire/version.h +++ b/applications/plugins/usb_hid_autofire/version.h @@ -1 +1 @@ -#define VERSION "0.2" +#define VERSION "0.3"