Skip to content

Commit

Permalink
Merge pull request #3 from rorosaurus/main
Browse files Browse the repository at this point in the history
adjust button function (add scrolling)
  • Loading branch information
ginkage authored Dec 30, 2022
2 parents 971a8f6 + 08b94b1 commit 6f45b0e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions views/bt_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct BtMouse {

#define MOUSE_MOVE_SHORT 5
#define MOUSE_MOVE_LONG 20
#define MOUSE_SCROLL 20

static void bt_mouse_notify_event(BtMouse* bt_mouse) {
FuriThreadId thread_id = furi_thread_get_id(bt_mouse->thread);
Expand Down Expand Up @@ -100,6 +101,14 @@ static void bt_mouse_process(BtMouse* bt_mouse, InputEvent* event) {
} else if(event->type == InputTypeRelease) {
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_WHEEL, false);
}
} else if(event->key == InputKeyRight) {
if(event->type == InputTypePress) {
bt_mouse->wheel = MOUSE_SCROLL;
}
} else if(event->key == InputKeyLeft) {
if(event->type == InputTypePress) {
bt_mouse->wheel = -MOUSE_SCROLL;
}
}
},
true);
Expand Down
10 changes: 10 additions & 0 deletions views/usb_mouse.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ static void usb_mouse_draw_callback(Canvas* canvas, void* context) {
canvas_draw_str(canvas, 0, 63, "Hold [back] to exit");
}

#define MOUSE_SCROLL 20

static void usb_mouse_process(UsbMouse* usb_mouse, InputEvent* event) {
with_view_model(
usb_mouse->view,
Expand All @@ -45,6 +47,14 @@ static void usb_mouse_process(UsbMouse* usb_mouse, InputEvent* event) {
} else if(event->type == InputTypeRelease) {
furi_hal_hid_mouse_release(HID_MOUSE_BTN_WHEEL);
}
} else if(event->key == InputKeyRight) {
if(event->type == InputTypePress) {
furi_hal_hid_mouse_scroll(MOUSE_SCROLL);
}
} else if(event->key == InputKeyLeft) {
if(event->type == InputTypePress) {
furi_hal_hid_mouse_scroll(-MOUSE_SCROLL);
}
}
},
true);
Expand Down

0 comments on commit 6f45b0e

Please sign in to comment.