Skip to content

Commit 7007db8

Browse files
authored
adjust button function (add scrolling)
1 parent 971a8f6 commit 7007db8

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

views/bt_mouse.c

+11-2
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);
@@ -82,13 +83,13 @@ static void bt_mouse_process(BtMouse* bt_mouse, InputEvent* event) {
8283
void* model,
8384
{
8485
UNUSED(model);
85-
if(event->key == InputKeyUp) {
86+
if(event->key == InputKeyLeft) {
8687
if(event->type == InputTypePress) {
8788
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_LEFT, true);
8889
} else if(event->type == InputTypeRelease) {
8990
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_LEFT, false);
9091
}
91-
} else if(event->key == InputKeyDown) {
92+
} else if(event->key == InputKeyRight) {
9293
if(event->type == InputTypePress) {
9394
bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_RIGHT, true);
9495
} else if(event->type == InputTypeRelease) {
@@ -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 == InputKeyUp) {
105+
if(event->type == InputTypePress) {
106+
bt_mouse->wheel = MOUSE_SCROLL;
107+
}
108+
} else if(event->key == InputKeyDown) {
109+
if(event->type == InputTypePress) {
110+
bt_mouse->wheel = -MOUSE_SCROLL;
111+
}
103112
}
104113
},
105114
true);

views/usb_mouse.c

+12-2
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,21 @@ 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,
2729
void* model,
2830
{
2931
UNUSED(model);
30-
if(event->key == InputKeyUp) {
32+
if(event->key == InputKeyLeft) {
3133
if(event->type == InputTypePress) {
3234
furi_hal_hid_mouse_press(HID_MOUSE_BTN_LEFT);
3335
} else if(event->type == InputTypeRelease) {
3436
furi_hal_hid_mouse_release(HID_MOUSE_BTN_LEFT);
3537
}
36-
} else if(event->key == InputKeyDown) {
38+
} else if(event->key == InputKeyRight) {
3739
if(event->type == InputTypePress) {
3840
furi_hal_hid_mouse_press(HID_MOUSE_BTN_RIGHT);
3941
} else if(event->type == InputTypeRelease) {
@@ -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 == InputKeyUp) {
51+
if(event->type == InputTypePress) {
52+
furi_hal_hid_mouse_scroll(MOUSE_SCROLL);
53+
}
54+
} else if(event->key == InputKeyDown) {
55+
if(event->type == InputTypePress) {
56+
furi_hal_hid_mouse_scroll(-MOUSE_SCROLL);
57+
}
4858
}
4959
},
5060
true);

0 commit comments

Comments
 (0)