Преглед изворни кода

longer fake middle click for applications that need it (firefox)

Thomas Buck пре 1 година
родитељ
комит
0679e7cb18
3 измењених фајлова са 11 додато и 6 уклоњено
  1. 1
    0
      firmware/include/config.h
  2. 2
    1
      firmware/include/controls.h
  3. 8
    5
      firmware/src/controls.c

+ 1
- 0
firmware/include/config.h Прегледај датотеку

@@ -21,6 +21,7 @@
21 21
 #define INVERT_SCROLL_Y_AXIS false
22 22
 #define SCROLL_REDUCE_SENSITIVITY 10
23 23
 #define MIN_SCROLL_SUPPRESS_CLICK 10
24
+#define MOUSE_FAKE_MIDDLE_CLICK_TIME 10
24 25
 
25 26
 #define DEBOUNCE_DELAY_MS 5
26 27
 

+ 2
- 1
firmware/include/controls.h Прегледај датотеку

@@ -19,7 +19,8 @@ struct mouse_state {
19 19
     bool button[MOUSE_BUTTONS_COUNT];
20 20
     int16_t delta_x, delta_y;
21 21
     int16_t scroll_x, scroll_y;
22
-    bool scroll_lock, fake_middle;
22
+    bool scroll_lock;
23
+    uint16_t fake_middle;
23 24
     int16_t internal_scroll_x, internal_scroll_y;
24 25
 };
25 26
 

+ 8
- 5
firmware/src/controls.c Прегледај датотеку

@@ -24,7 +24,7 @@ void controls_init(void) {
24 24
     mouse.scroll_x = 0;
25 25
     mouse.scroll_y = 0;
26 26
     mouse.scroll_lock = false;
27
-    mouse.fake_middle = false;
27
+    mouse.fake_middle = 0;
28 28
 
29 29
     last_mouse = mouse;
30 30
 }
@@ -111,9 +111,12 @@ struct mouse_state controls_mouse_read(void) {
111 111
         mouse.internal_scroll_y = 0;
112 112
     }
113 113
 
114
-    if (mouse.fake_middle) {
115
-        mouse.button[MOUSE_MIDDLE] = false;
116
-        mouse.fake_middle = false;
114
+    if (mouse.fake_middle > 0) {
115
+        mouse.fake_middle++;
116
+        if (mouse.fake_middle > MOUSE_FAKE_MIDDLE_CLICK_TIME) {
117
+            mouse.fake_middle = 0;
118
+            mouse.button[MOUSE_MIDDLE] = false;
119
+        }
117 120
     }
118 121
 
119 122
     if (!mouse.scroll_lock && last_mouse.scroll_lock) {
@@ -121,7 +124,7 @@ struct mouse_state controls_mouse_read(void) {
121 124
         if (scroll_sum < MIN_SCROLL_SUPPRESS_CLICK) {
122 125
             // fake middle mouse click, user was not scrolling
123 126
             mouse.button[MOUSE_MIDDLE] = true;
124
-            mouse.fake_middle = true;
127
+            mouse.fake_middle = 1;
125 128
         }
126 129
     }
127 130
 

Loading…
Откажи
Сачувај