Skip to content

Commit

Permalink
Accelerated Mouse Pointer. Screen Nav is easy now!
Browse files Browse the repository at this point in the history
  • Loading branch information
Leeroy committed Oct 22, 2023
1 parent b1b727c commit f67680d
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions applications/external/hid_app/views/hid_mouse.c
Expand Up @@ -23,6 +23,8 @@ typedef struct {
HidTransport transport;
} HidMouseModel;

static uint32_t button_press_repeat_count;

static void hid_mouse_draw_callback(Canvas* canvas, void* context) {
furi_assert(context);
HidMouseModel* model = context;
Expand Down Expand Up @@ -117,6 +119,17 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
hid_mouse->view,
HidMouseModel * model,
{
//Save a repeat counter for the acceleration of the mouse pointer...
if(event->type == InputTypeRelease) {
button_press_repeat_count = 0;
} else if(event->type == InputTypePress) {
button_press_repeat_count = 2;
} else if(event->type == InputTypeRepeat) {
button_press_repeat_count =
(button_press_repeat_count > 10) ? 10 : button_press_repeat_count + 1;
}

//Process the button presses.
if(event->key == InputKeyBack) {
if(event->type == InputTypeShort) {
hid_hal_mouse_press(hid_mouse->hid, HID_MOUSE_BTN_RIGHT);
Expand Down Expand Up @@ -148,7 +161,9 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
model->right_pressed = true;
hid_hal_mouse_move(hid_mouse->hid, MOUSE_MOVE_SHORT, 0);
} else if(event->type == InputTypeRepeat) {
hid_hal_mouse_move(hid_mouse->hid, MOUSE_MOVE_LONG, 0);
//Accelerated
for(int32_t i = button_press_repeat_count; i > 1; i = i - 2)
hid_hal_mouse_move(hid_mouse->hid, MOUSE_MOVE_LONG, 0);
} else if(event->type == InputTypeRelease) {
model->right_pressed = false;
}
Expand All @@ -157,7 +172,9 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
model->left_pressed = true;
hid_hal_mouse_move(hid_mouse->hid, -MOUSE_MOVE_SHORT, 0);
} else if(event->type == InputTypeRepeat) {
hid_hal_mouse_move(hid_mouse->hid, -MOUSE_MOVE_LONG, 0);
//Accelerated
for(int32_t i = button_press_repeat_count; i > 1; i = i - 2)
hid_hal_mouse_move(hid_mouse->hid, -MOUSE_MOVE_LONG, 0);
} else if(event->type == InputTypeRelease) {
model->left_pressed = false;
}
Expand All @@ -166,7 +183,9 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
model->down_pressed = true;
hid_hal_mouse_move(hid_mouse->hid, 0, MOUSE_MOVE_SHORT);
} else if(event->type == InputTypeRepeat) {
hid_hal_mouse_move(hid_mouse->hid, 0, MOUSE_MOVE_LONG);
//Accelerated
for(int32_t i = button_press_repeat_count; i > 1; i = i - 2)
hid_hal_mouse_move(hid_mouse->hid, 0, MOUSE_MOVE_LONG);
} else if(event->type == InputTypeRelease) {
model->down_pressed = false;
}
Expand All @@ -175,7 +194,9 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
model->up_pressed = true;
hid_hal_mouse_move(hid_mouse->hid, 0, -MOUSE_MOVE_SHORT);
} else if(event->type == InputTypeRepeat) {
hid_hal_mouse_move(hid_mouse->hid, 0, -MOUSE_MOVE_LONG);
//Accelerated
for(int32_t i = button_press_repeat_count; i > 1; i = i - 2)
hid_hal_mouse_move(hid_mouse->hid, 0, -MOUSE_MOVE_LONG);
} else if(event->type == InputTypeRelease) {
model->up_pressed = false;
}
Expand Down

0 comments on commit f67680d

Please sign in to comment.