Skip to content

Commit 6f45b0e

Browse files
authored
Merge pull request #3 from rorosaurus/main
adjust button function (add scrolling)
2 parents 971a8f6 + 08b94b1 commit 6f45b0e

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

views/bt_mouse.c

+9
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct BtMouse {
4646

4747
#define MOUSE_MOVE_SHORT 5
4848
#define MOUSE_MOVE_LONG 20
49+
#define MOUSE_SCROLL 20
4950

5051
static void bt_mouse_notify_event(BtMouse* bt_mouse) {
5152
FuriThreadId thread_id = furi_thread_get_id(bt_mouse->thread);
@@ -100,6 +101,14 @@ static void bt_mouse_process(BtMouse* bt_mouse, InputEvent* event) {
100101
} else if(event->type == InputTypeRelease) {
101102
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_WHEEL, false);
102103
}
104+
} else if(event->key == InputKeyRight) {
105+
if(event->type == InputTypePress) {
106+
bt_mouse->wheel = MOUSE_SCROLL;
107+
}
108+
} else if(event->key == InputKeyLeft) {
109+
if(event->type == InputTypePress) {
110+
bt_mouse->wheel = -MOUSE_SCROLL;
111+
}
103112
}
104113
},
105114
true);

views/usb_mouse.c

+10
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ static void usb_mouse_draw_callback(Canvas* canvas, void* context) {
2121
canvas_draw_str(canvas, 0, 63, "Hold [back] to exit");
2222
}
2323

24+
#define MOUSE_SCROLL 20
25+
2426
static void usb_mouse_process(UsbMouse* usb_mouse, InputEvent* event) {
2527
with_view_model(
2628
usb_mouse->view,
@@ -45,6 +47,14 @@ static void usb_mouse_process(UsbMouse* usb_mouse, InputEvent* event) {
4547
} else if(event->type == InputTypeRelease) {
4648
furi_hal_hid_mouse_release(HID_MOUSE_BTN_WHEEL);
4749
}
50+
} else if(event->key == InputKeyRight) {
51+
if(event->type == InputTypePress) {
52+
furi_hal_hid_mouse_scroll(MOUSE_SCROLL);
53+
}
54+
} else if(event->key == InputKeyLeft) {
55+
if(event->type == InputTypePress) {
56+
furi_hal_hid_mouse_scroll(-MOUSE_SCROLL);
57+
}
4858
}
4959
},
5060
true);

0 commit comments

Comments
 (0)