Kaynağa Gözat

Merge pull request #3 from rorosaurus/main

adjust button function (add scrolling)
Ivan Podogov 3 yıl önce
ebeveyn
işleme
6f45b0e34e
2 değiştirilmiş dosya ile 19 ekleme ve 0 silme
  1. 9 0
      views/bt_mouse.c
  2. 10 0
      views/usb_mouse.c

+ 9 - 0
views/bt_mouse.c

@@ -46,6 +46,7 @@ struct BtMouse {
 
 
 #define MOUSE_MOVE_SHORT 5
 #define MOUSE_MOVE_SHORT 5
 #define MOUSE_MOVE_LONG 20
 #define MOUSE_MOVE_LONG 20
+#define MOUSE_SCROLL 20
 
 
 static void bt_mouse_notify_event(BtMouse* bt_mouse) {
 static void bt_mouse_notify_event(BtMouse* bt_mouse) {
     FuriThreadId thread_id = furi_thread_get_id(bt_mouse->thread);
     FuriThreadId thread_id = furi_thread_get_id(bt_mouse->thread);
@@ -100,6 +101,14 @@ static void bt_mouse_process(BtMouse* bt_mouse, InputEvent* event) {
                 } else if(event->type == InputTypeRelease) {
                 } else if(event->type == InputTypeRelease) {
                     bt_mouse_button_state(bt_mouse, HID_MOUSE_BTN_WHEEL, false);
                     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);
         true);

+ 10 - 0
views/usb_mouse.c

@@ -21,6 +21,8 @@ static void usb_mouse_draw_callback(Canvas* canvas, void* context) {
     canvas_draw_str(canvas, 0, 63, "Hold [back] to exit");
     canvas_draw_str(canvas, 0, 63, "Hold [back] to exit");
 }
 }
 
 
+#define MOUSE_SCROLL 20
+
 static void usb_mouse_process(UsbMouse* usb_mouse, InputEvent* event) {
 static void usb_mouse_process(UsbMouse* usb_mouse, InputEvent* event) {
     with_view_model(
     with_view_model(
         usb_mouse->view,
         usb_mouse->view,
@@ -45,6 +47,14 @@ static void usb_mouse_process(UsbMouse* usb_mouse, InputEvent* event) {
                 } else if(event->type == InputTypeRelease) {
                 } else if(event->type == InputTypeRelease) {
                     furi_hal_hid_mouse_release(HID_MOUSE_BTN_WHEEL);
                     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);
         true);