Browse Source

reduce scroll sensitivity

Thomas Buck 1 year ago
parent
commit
326e04032c
3 changed files with 30 additions and 6 deletions
  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 View File

18
 
18
 
19
 #define INVERT_SCROLL_X_AXIS false
19
 #define INVERT_SCROLL_X_AXIS false
20
 #define INVERT_SCROLL_Y_AXIS false
20
 #define INVERT_SCROLL_Y_AXIS false
21
+#define SCROLL_REDUCE_SENSITIVITY 10
21
 #define MIN_SCROLL_SUPPRESS_CLICK 10
22
 #define MIN_SCROLL_SUPPRESS_CLICK 10
22
 
23
 
23
 #define DEBOUNCE_DELAY_MS 5
24
 #define DEBOUNCE_DELAY_MS 5

+ 1
- 0
firmware/include/controls.h View File

20
     int16_t delta_x, delta_y;
20
     int16_t delta_x, delta_y;
21
     int16_t scroll_x, scroll_y;
21
     int16_t scroll_x, scroll_y;
22
     bool scroll_lock, fake_middle;
22
     bool scroll_lock, fake_middle;
23
+    int16_t internal_scroll_x, internal_scroll_y;
23
 };
24
 };
24
 
25
 
25
 void controls_init(void);
26
 void controls_init(void);

+ 28
- 6
firmware/src/controls.c View File

76
         mouse.delta_y = motion.delta_y;
76
         mouse.delta_y = motion.delta_y;
77
     }
77
     }
78
 
78
 
79
+    mouse.scroll_x = 0;
80
+    mouse.scroll_y = 0;
81
+
79
     if (mouse.scroll_lock) {
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
         mouse.delta_x = 0;
89
         mouse.delta_x = 0;
83
         mouse.delta_y = 0;
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
     } else {
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
     if (mouse.fake_middle) {
114
     if (mouse.fake_middle) {

Loading…
Cancel
Save