From 7007db8d5a2cf9721aa1761ceea87aa427ceff00 Mon Sep 17 00:00:00 2001 From: Rory O Hayes Date: Fri, 23 Dec 2022 13:03:52 -0800 Subject: [PATCH] adjust button function (add scrolling) --- views/bt_mouse.c | 13 +++++++++++-- views/usb_mouse.c | 14 ++++++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/views/bt_mouse.c b/views/bt_mouse.c index 72599b99669..cbb67042bd1 100644 --- a/views/bt_mouse.c +++ b/views/bt_mouse.c @@ -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); @@ -82,13 +83,13 @@ static void bt_mouse_process(BtMouse* bt_mouse, InputEvent* event) { void* model, { UNUSED(model); - if(event->key == InputKeyUp) { + if(event->key == InputKeyLeft) { if(event->type == InputTypePress) { bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_LEFT, true); } else if(event->type == InputTypeRelease) { bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_LEFT, false); } - } else if(event->key == InputKeyDown) { + } else if(event->key == InputKeyRight) { if(event->type == InputTypePress) { bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_RIGHT, true); } else if(event->type == InputTypeRelease) { @@ -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 == InputKeyUp) { + if(event->type == InputTypePress) { + bt_mouse->wheel = MOUSE_SCROLL; + } + } else if(event->key == InputKeyDown) { + if(event->type == InputTypePress) { + bt_mouse->wheel = -MOUSE_SCROLL; + } } }, true); diff --git a/views/usb_mouse.c b/views/usb_mouse.c index 736a94b3afd..8143a8b3d3c 100644 --- a/views/usb_mouse.c +++ b/views/usb_mouse.c @@ -21,19 +21,21 @@ 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, void* model, { UNUSED(model); - if(event->key == InputKeyUp) { + if(event->key == InputKeyLeft) { if(event->type == InputTypePress) { furi_hal_hid_mouse_press(HID_MOUSE_BTN_LEFT); } else if(event->type == InputTypeRelease) { furi_hal_hid_mouse_release(HID_MOUSE_BTN_LEFT); } - } else if(event->key == InputKeyDown) { + } else if(event->key == InputKeyRight) { if(event->type == InputTypePress) { furi_hal_hid_mouse_press(HID_MOUSE_BTN_RIGHT); } else if(event->type == InputTypeRelease) { @@ -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 == InputKeyUp) { + if(event->type == InputTypePress) { + furi_hal_hid_mouse_scroll(MOUSE_SCROLL); + } + } else if(event->key == InputKeyDown) { + if(event->type == InputTypePress) { + furi_hal_hid_mouse_scroll(-MOUSE_SCROLL); + } } }, true);