瀏覽代碼

reduce scroll sensitivity

Thomas Buck 1 年之前
父節點
當前提交
326e04032c
共有 3 個檔案被更改,包括 30 行新增6 行删除
  1. 1
    0
      firmware/include/config.h
  2. 1
    0
      firmware/include/controls.h
  3. 28
    6
      firmware/src/controls.c

+ 1
- 0
firmware/include/config.h 查看文件

@@ -18,6 +18,7 @@
18 18
 
19 19
 #define INVERT_SCROLL_X_AXIS false
20 20
 #define INVERT_SCROLL_Y_AXIS false
21
+#define SCROLL_REDUCE_SENSITIVITY 10
21 22
 #define MIN_SCROLL_SUPPRESS_CLICK 10
22 23
 
23 24
 #define DEBOUNCE_DELAY_MS 5

+ 1
- 0
firmware/include/controls.h 查看文件

@@ -20,6 +20,7 @@ struct mouse_state {
20 20
     int16_t delta_x, delta_y;
21 21
     int16_t scroll_x, scroll_y;
22 22
     bool scroll_lock, fake_middle;
23
+    int16_t internal_scroll_x, internal_scroll_y;
23 24
 };
24 25
 
25 26
 void controls_init(void);

+ 28
- 6
firmware/src/controls.c 查看文件

@@ -76,17 +76,39 @@ struct mouse_state controls_mouse_read(void) {
76 76
         mouse.delta_y = motion.delta_y;
77 77
     }
78 78
 
79
+    mouse.scroll_x = 0;
80
+    mouse.scroll_y = 0;
81
+
79 82
     if (mouse.scroll_lock) {
80
-        mouse.scroll_x = mouse.delta_x;
81
-        mouse.scroll_y = mouse.delta_y;
83
+        scroll_sum += abs(mouse.delta_x);
84
+        scroll_sum += abs(mouse.delta_y);
85
+
86
+        mouse.internal_scroll_x += mouse.delta_x;
87
+        mouse.internal_scroll_y += mouse.delta_y;
88
+
82 89
         mouse.delta_x = 0;
83 90
         mouse.delta_y = 0;
84 91
 
85
-        scroll_sum += abs(mouse.scroll_x);
86
-        scroll_sum += abs(mouse.scroll_y);
92
+        while (mouse.internal_scroll_x > SCROLL_REDUCE_SENSITIVITY) {
93
+            mouse.scroll_x += 1;
94
+            mouse.internal_scroll_x -= SCROLL_REDUCE_SENSITIVITY;
95
+        }
96
+        while (mouse.internal_scroll_x < -SCROLL_REDUCE_SENSITIVITY) {
97
+            mouse.scroll_x -= 1;
98
+            mouse.internal_scroll_x += SCROLL_REDUCE_SENSITIVITY;
99
+        }
100
+
101
+        while (mouse.internal_scroll_y > SCROLL_REDUCE_SENSITIVITY) {
102
+            mouse.scroll_y += 1;
103
+            mouse.internal_scroll_y -= SCROLL_REDUCE_SENSITIVITY;
104
+        }
105
+        while (mouse.internal_scroll_y < -SCROLL_REDUCE_SENSITIVITY) {
106
+            mouse.scroll_y -= 1;
107
+            mouse.internal_scroll_y += SCROLL_REDUCE_SENSITIVITY;
108
+        }
87 109
     } else {
88
-        mouse.scroll_x = 0;
89
-        mouse.scroll_y = 0;
110
+        mouse.internal_scroll_x = 0;
111
+        mouse.internal_scroll_y = 0;
90 112
     }
91 113
 
92 114
     if (mouse.fake_middle) {

Loading…
取消
儲存