diff --git a/CHANGELOG.md b/CHANGELOG.md index d2da091..19fe7da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.3 +- add a delay between key-presses (with left/right buttons) + ## 0.2 - update icon diff --git a/screenshot.png b/screenshot.png index d2053c1..b5547e1 100644 Binary files a/screenshot.png and b/screenshot.png differ diff --git a/usb_hid_autofire.c b/usb_hid_autofire.c index 34c1fa4..47cabdc 100644 --- a/usb_hid_autofire.c +++ b/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/version.h b/version.h index 0502a24..41c8b38 100644 --- a/version.h +++ b/version.h @@ -1 +1 @@ -#define VERSION "0.2" +#define VERSION "0.3"