Skip to content
This repository has been archived by the owner on Nov 19, 2024. It is now read-only.

Mouse Jiggler Amendment #599

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions applications/system/hid_app/views/hid_mouse_jiggler.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "hid_mouse_jiggler.h"
#include <gui/elements.h>
#include "../hid.h"
#include <stdlib.h>

#include "hid_icons.h"

Expand All @@ -20,7 +21,7 @@ typedef struct {
HidTransport transport;
} HidMouseJigglerModel;

const int intervals[6] = {500, 2000, 5000, 10000, 30000, 60000};
const int intervals[6] = {15000, 30000, 60000, 120000, 180000, 250000};

static void hid_mouse_jiggler_draw_callback(Canvas* canvas, void* context) {
furi_assert(context);
Expand Down Expand Up @@ -80,10 +81,19 @@ static void hid_mouse_jiggler_timer_callback(void* context) {
{
if(model->running) {
model->counter++;
//Randomised mouse movement
int MOUSE_MOVE_MAX = 50;
int mouse_move_x = (rand() % (2 * MOUSE_MOVE_MAX + 1)) - MOUSE_MOVE_MAX;
int mouse_move_y = (rand() % (2 * MOUSE_MOVE_MAX + 1)) - MOUSE_MOVE_MAX;

hid_hal_mouse_move(
hid_mouse_jiggler->hid,
(model->counter % 2 == 0) ? MOUSE_MOVE_SHORT : -MOUSE_MOVE_SHORT,
0);
mouse_move_x,
mouse_move_y);
//Random Interval between 1250ms and the chosen interval
int random_interval = (rand() % intervals[model->interval_idx]) + 1250;
furi_timer_stop(hid_mouse_jiggler->timer);
furi_timer_start(hid_mouse_jiggler->timer, random_interval);
}
},
false);
Expand All @@ -110,7 +120,10 @@ static bool hid_mouse_jiggler_input_callback(InputEvent* event, void* context) {
if(model->running) {
furi_timer_stop(hid_mouse_jiggler->timer);
furi_timer_start(hid_mouse_jiggler->timer, intervals[model->interval_idx]);
};
} else {
// Stopping the timer when jiggler isn't running
furi_timer_stop(hid_mouse_jiggler->timer);
}
consumed = true;
}
if(event->type == InputTypePress && event->key == InputKeyRight && !model->running &&
Expand Down