mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2024-12-23 13:21:44 +03:00
* fixes mouse clicking rate * Hid: limit max clicks to 100/s, rewrite code to make it more robust Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
421bd3e1f9
commit
d9d3867ce1
@ -7,7 +7,7 @@
|
|||||||
#define TAG "HidMouseClicker"
|
#define TAG "HidMouseClicker"
|
||||||
|
|
||||||
#define DEFAULT_CLICK_RATE 1
|
#define DEFAULT_CLICK_RATE 1
|
||||||
#define MAXIMUM_CLICK_RATE 60
|
#define MAXIMUM_CLICK_RATE 100
|
||||||
|
|
||||||
struct HidMouseClicker {
|
struct HidMouseClicker {
|
||||||
View* view;
|
View* view;
|
||||||
@ -34,7 +34,9 @@ static void hid_mouse_clicker_start_or_restart_timer(void* context) {
|
|||||||
HidMouseClickerModel * model,
|
HidMouseClickerModel * model,
|
||||||
{
|
{
|
||||||
furi_timer_start(
|
furi_timer_start(
|
||||||
hid_mouse_clicker->timer, furi_kernel_get_tick_frequency() / model->rate);
|
hid_mouse_clicker->timer,
|
||||||
|
furi_kernel_get_tick_frequency() /
|
||||||
|
((model->rate) ? model->rate : MAXIMUM_CLICK_RATE));
|
||||||
},
|
},
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
@ -75,7 +77,11 @@ static void hid_mouse_clicker_draw_callback(Canvas* canvas, void* context) {
|
|||||||
|
|
||||||
// Clicks/s
|
// Clicks/s
|
||||||
char label[20];
|
char label[20];
|
||||||
|
if(model->rate) {
|
||||||
snprintf(label, sizeof(label), "%d clicks/s", model->rate);
|
snprintf(label, sizeof(label), "%d clicks/s", model->rate);
|
||||||
|
} else {
|
||||||
|
snprintf(label, sizeof(label), "max clicks/s");
|
||||||
|
}
|
||||||
elements_multiline_text_aligned(canvas, 28, 37, AlignCenter, AlignBottom, label);
|
elements_multiline_text_aligned(canvas, 28, 37, AlignCenter, AlignBottom, label);
|
||||||
|
|
||||||
canvas_draw_icon(canvas, 25, 20, &I_ButtonUp_7x4);
|
canvas_draw_icon(canvas, 25, 20, &I_ButtonUp_7x4);
|
||||||
@ -139,7 +145,7 @@ static bool hid_mouse_clicker_input_callback(InputEvent* event, void* context) {
|
|||||||
consumed = true;
|
consumed = true;
|
||||||
break;
|
break;
|
||||||
case InputKeyDown:
|
case InputKeyDown:
|
||||||
if(model->rate > 1) {
|
if(model->rate > 0) {
|
||||||
model->rate--;
|
model->rate--;
|
||||||
}
|
}
|
||||||
rate_changed = true;
|
rate_changed = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user