|
|
@@ -20,6 +20,7 @@ typedef struct {
|
|
|
bool left_mouse_held;
|
|
|
bool right_mouse_pressed;
|
|
|
bool connected;
|
|
|
+ uint8_t acceleration;
|
|
|
HidTransport transport;
|
|
|
} HidMouseModel;
|
|
|
|
|
|
@@ -117,6 +118,11 @@ static void hid_mouse_process(HidMouse* hid_mouse, InputEvent* event) {
|
|
|
hid_mouse->view,
|
|
|
HidMouseModel * model,
|
|
|
{
|
|
|
+ model->acceleration = (event->type == InputTypePress) ? 1 :
|
|
|
+ (event->type == InputTypeRelease) ? 0 :
|
|
|
+ (model->acceleration >= 20) ? 20 :
|
|
|
+ model->acceleration + 1;
|
|
|
+
|
|
|
if(event->key == InputKeyBack) {
|
|
|
if(event->type == InputTypeShort) {
|
|
|
hid_hal_mouse_press(hid_mouse->hid, HID_MOUSE_BTN_RIGHT);
|
|
|
@@ -148,7 +154,8 @@ 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);
|
|
|
+ for(uint8_t i = model->acceleration; i > 1; i -= 2)
|
|
|
+ hid_hal_mouse_move(hid_mouse->hid, MOUSE_MOVE_LONG, 0);
|
|
|
} else if(event->type == InputTypeRelease) {
|
|
|
model->right_pressed = false;
|
|
|
}
|
|
|
@@ -157,7 +164,8 @@ 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);
|
|
|
+ for(uint8_t i = model->acceleration; i > 1; i -= 2)
|
|
|
+ hid_hal_mouse_move(hid_mouse->hid, -MOUSE_MOVE_LONG, 0);
|
|
|
} else if(event->type == InputTypeRelease) {
|
|
|
model->left_pressed = false;
|
|
|
}
|
|
|
@@ -166,7 +174,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);
|
|
|
+ for(uint8_t i = model->acceleration; i > 1; i -= 2)
|
|
|
+ hid_hal_mouse_move(hid_mouse->hid, 0, MOUSE_MOVE_LONG);
|
|
|
+
|
|
|
} else if(event->type == InputTypeRelease) {
|
|
|
model->down_pressed = false;
|
|
|
}
|
|
|
@@ -175,7 +185,8 @@ 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);
|
|
|
+ for(uint8_t i = model->acceleration; i > 1; i -= 2)
|
|
|
+ hid_hal_mouse_move(hid_mouse->hid, 0, -MOUSE_MOVE_LONG);
|
|
|
} else if(event->type == InputTypeRelease) {
|
|
|
model->up_pressed = false;
|
|
|
}
|