diff options
author | QMK Bot <hello@qmk.fm> | 2020-03-13 17:24:38 +0000 |
---|---|---|
committer | QMK Bot <hello@qmk.fm> | 2020-03-13 17:24:38 +0000 |
commit | f89439ae09c06d0e85f59af2bc5e020d141f23d6 (patch) | |
tree | ec6d01493813e51bbde7a766d7dc310b777e7803 /tmk_core/common | |
parent | 3cd2a27ac0f963bc2023c3004f6f8eff0eb62a81 (diff) | |
download | qmk_firmware-f89439ae09c06d0e85f59af2bc5e020d141f23d6.tar.gz qmk_firmware-f89439ae09c06d0e85f59af2bc5e020d141f23d6.zip |
format code according to conventions [skip ci]
Diffstat (limited to 'tmk_core/common')
-rw-r--r-- | tmk_core/common/mousekey.c | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/tmk_core/common/mousekey.c b/tmk_core/common/mousekey.c index 00357f5f6..74fa88abd 100644 --- a/tmk_core/common/mousekey.c +++ b/tmk_core/common/mousekey.c | |||
@@ -39,8 +39,8 @@ static uint16_t last_timer = 0; | |||
39 | 39 | ||
40 | #ifndef MK_3_SPEED | 40 | #ifndef MK_3_SPEED |
41 | 41 | ||
42 | static uint16_t last_timer_c = 0; | 42 | static uint16_t last_timer_c = 0; |
43 | static uint16_t last_timer_w = 0; | 43 | static uint16_t last_timer_w = 0; |
44 | 44 | ||
45 | /* | 45 | /* |
46 | * Mouse keys acceleration algorithm | 46 | * Mouse keys acceleration algorithm |
@@ -62,7 +62,7 @@ uint8_t mk_time_to_max = MOUSEKEY_TIME_TO_MAX; | |||
62 | /* milliseconds between the initial key press and first repeated motion event (0-2550) */ | 62 | /* milliseconds between the initial key press and first repeated motion event (0-2550) */ |
63 | uint8_t mk_wheel_delay = MOUSEKEY_WHEEL_DELAY / 10; | 63 | uint8_t mk_wheel_delay = MOUSEKEY_WHEEL_DELAY / 10; |
64 | /* milliseconds between repeated motion events (0-255) */ | 64 | /* milliseconds between repeated motion events (0-255) */ |
65 | uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL; | 65 | uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL; |
66 | uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED; | 66 | uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED; |
67 | uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX; | 67 | uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX; |
68 | 68 | ||
@@ -105,8 +105,7 @@ static uint8_t wheel_unit(void) { | |||
105 | void mousekey_task(void) { | 105 | void mousekey_task(void) { |
106 | // report cursor and scroll movement independently | 106 | // report cursor and scroll movement independently |
107 | report_mouse_t const tmpmr = mouse_report; | 107 | report_mouse_t const tmpmr = mouse_report; |
108 | if ((mouse_report.x || mouse_report.y) && | 108 | if ((mouse_report.x || mouse_report.y) && timer_elapsed(last_timer_c) > (mousekey_repeat ? mk_interval : mk_delay * 10)) { |
109 | timer_elapsed(last_timer_c) > (mousekey_repeat ? mk_interval : mk_delay * 10)) { | ||
110 | if (mousekey_repeat != UINT8_MAX) mousekey_repeat++; | 109 | if (mousekey_repeat != UINT8_MAX) mousekey_repeat++; |
111 | mouse_report.v = 0; | 110 | mouse_report.v = 0; |
112 | mouse_report.h = 0; | 111 | mouse_report.h = 0; |
@@ -117,16 +116,19 @@ void mousekey_task(void) { | |||
117 | /* diagonal move [1/sqrt(2)] */ | 116 | /* diagonal move [1/sqrt(2)] */ |
118 | if (mouse_report.x && mouse_report.y) { | 117 | if (mouse_report.x && mouse_report.y) { |
119 | mouse_report.x = times_inv_sqrt2(mouse_report.x); | 118 | mouse_report.x = times_inv_sqrt2(mouse_report.x); |
120 | if (mouse_report.x == 0) { mouse_report.x = 1; } | 119 | if (mouse_report.x == 0) { |
120 | mouse_report.x = 1; | ||
121 | } | ||
121 | mouse_report.y = times_inv_sqrt2(mouse_report.y); | 122 | mouse_report.y = times_inv_sqrt2(mouse_report.y); |
122 | if (mouse_report.y == 0) { mouse_report.y = 1; } | 123 | if (mouse_report.y == 0) { |
124 | mouse_report.y = 1; | ||
125 | } | ||
123 | } | 126 | } |
124 | mousekey_send(); | 127 | mousekey_send(); |
125 | last_timer_c = last_timer; | 128 | last_timer_c = last_timer; |
126 | mouse_report = tmpmr; | 129 | mouse_report = tmpmr; |
127 | } | 130 | } |
128 | if ((mouse_report.v || mouse_report.h) && | 131 | if ((mouse_report.v || mouse_report.h) && timer_elapsed(last_timer_w) > (mousekey_repeat ? mk_wheel_interval : mk_wheel_delay * 10)) { |
129 | timer_elapsed(last_timer_w) > (mousekey_repeat ? mk_wheel_interval: mk_wheel_delay * 10)) { | ||
130 | if (mousekey_repeat != UINT8_MAX) mousekey_repeat++; | 132 | if (mousekey_repeat != UINT8_MAX) mousekey_repeat++; |
131 | mouse_report.x = 0; | 133 | mouse_report.x = 0; |
132 | mouse_report.y = 0; | 134 | mouse_report.y = 0; |
@@ -137,9 +139,13 @@ void mousekey_task(void) { | |||
137 | /* diagonal move [1/sqrt(2)] */ | 139 | /* diagonal move [1/sqrt(2)] */ |
138 | if (mouse_report.v && mouse_report.h) { | 140 | if (mouse_report.v && mouse_report.h) { |
139 | mouse_report.v = times_inv_sqrt2(mouse_report.v); | 141 | mouse_report.v = times_inv_sqrt2(mouse_report.v); |
140 | if (mouse_report.v == 0) { mouse_report.v = 1; } | 142 | if (mouse_report.v == 0) { |
143 | mouse_report.v = 1; | ||
144 | } | ||
141 | mouse_report.h = times_inv_sqrt2(mouse_report.h); | 145 | mouse_report.h = times_inv_sqrt2(mouse_report.h); |
142 | if (mouse_report.h == 0) { mouse_report.h = 1; } | 146 | if (mouse_report.h == 0) { |
147 | mouse_report.h = 1; | ||
148 | } | ||
143 | } | 149 | } |
144 | mousekey_send(); | 150 | mousekey_send(); |
145 | last_timer_w = last_timer; | 151 | last_timer_w = last_timer; |