From 78ae20793d31e1ac93d78bfa235901ebf647407c Mon Sep 17 00:00:00 2001 From: Patrizio Bekerle Date: Fri, 25 Nov 2022 08:17:54 +0100 Subject: [PATCH] Add delay --- CHANGELOG.md | 3 +++ screenshot.png | Bin 1973 -> 2176 bytes usb_hid_autofire.c | 35 +++++++++++++++++++++++++++-------- version.h | 2 +- 4 files changed, 31 insertions(+), 9 deletions(-) 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 d2053c13db913a378cd77a0681eabb0882581948..b5547e1ba807aefb3245fc480d1a2efc8ae1de4c 100644 GIT binary patch literal 2176 zcmb7Ge^8TU9DfEXLJdmelEmn)h_pNu50cFRl?E6BItIBZa{geBso?CEG z{cz}5u@pBQWMin|HVlmv*jW1kf-uBjYiz#6%Qn~;HOtON>%8la_n!B8?|r||=ll75 zzMp#!XJ@8jLtY300ASP8R&M|xz<-MYbMG%}$2TtXFTo{g8yNtEUb}x`zIZ)!ApmpZ z(pSHgv+tCnpHknK@Z9V!+*nDR>gn3Mqx(MM{+jwch7$Mdu{1=Xs-zIoZfWL(McbSx zg77e(TKe=@Fc=X4Ui#c$CK`aZgF$)rgRQg3$2XxEGk03P-Al3v6ASqypK?#KeBFCa zG?L)Bj0!%}X@@ll6Jyg@{IY*NjLOo#6Bmo~4PGS4=- z;>g4Pa;6wS9Dj>w3XtwA#%v;Wd@S7hL1^K~WFCz%=Uo84ne{h5=`;t(s>y3M^Gn5} z0~5QB=jL&4{?ARI4T+S)_ z$O)Fqw>oRH$cDNic^6e)$HWTg$SpO2R!Np)lXmM;5%Y{b+1=lJg~G0fxHWvQC@(aL zXbwCsW<94qBHYq1%WbyFt+!Z>SlKqsZOZ_z+q#^xn{wLI-0ks7we>?PFP_I2n?*WT zhOf`7W(SNNd!T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AT0el zvMCHXBaMr`hHy<)b}S**U`tFi9T8xy&_c{Nt>iZ9$r2?-9`4O)h?LFAAd_e752NP1HZub%dQ&J5@+rBsCCgohyg=XR{Q z|LKF+OagRE63OOyCANJJ?QH0s83M|Etf4nbFH+pm^eK_G;@w6bLq`yHpDIi()EWpn zLxpccu4b%y4#Qz(2eqP1X$GvqUj4GZ^loVud6(l28!BUTiFJ|#LHXR>tU|6e z-A%3ZGT$&&mP?H?O-I}ycK(ibyB8Ap%H85HI^CvQ?o-(tNsc?4qu_8Z;H#Yosh5y~ zml0VzQ47C5(y)>?QTdlDiXm;jUbSLJVyCf2u*c=h3GOTTh^nA}>JQ6Zl@PJ)hWn|X z6cgh|@uW&PW}yb<3*9D1QJHtd^C)cX znBSKW=uVzpN*>KEpJ|AoQPwxFg?uvIa~pqFGhUsYHnORdFAdf8DFM4l_1h0c)92w@TV5cfYRrZf4zB#5g0Tvt;U7)-x8PE- zIk+N6pAt`D61s%Y%%5Dcy_N283QoOUel6JS9@xHyc@DaZoxuV%MZ3!*6y;g_QN3=37UO$oabPjygJ` z3_qkK4klEI(iA(1{I`bb+2O`wsAL+S+f>FVn4Pos!hyRevnb+-9H02MLGtDhIxbpO z)N4;4{=m|c&oB=*!yR|BW;#y~SkSSi`BQK^ni6u6w07Cv@*= zgr?~o0?GVB-z3KzE^@LKcknS~7_ER=@wlXiry;uRc;u5T!_T^Ax$EtSP=p0L*=)OX U@Io-zdJlt;z|a7(|FLs_0$a%5;{X5v 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"