You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

490 lines
18 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. /*
  2. * Copyright 2011 Jun Wako <wakojun@gmail.com>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include <stdint.h>
  18. #include "keycode.h"
  19. #include "host.h"
  20. #include "timer.h"
  21. #include "print.h"
  22. #include "debug.h"
  23. #include "mousekey.h"
  24. inline int8_t times_inv_sqrt2(int8_t x) {
  25. // 181/256 is pretty close to 1/sqrt(2)
  26. // 0.70703125 0.707106781
  27. // 1 too small for x=99 and x=198
  28. // This ends up being a mult and discard lower 8 bits
  29. return (x * 181) >> 8;
  30. }
  31. static report_mouse_t mouse_report = {0};
  32. static void mousekey_debug(void);
  33. static uint8_t mousekey_accel = 0;
  34. static uint8_t mousekey_repeat = 0;
  35. static uint8_t mousekey_wheel_repeat = 0;
  36. #ifdef MK_KINETIC_SPEED
  37. static uint16_t mouse_timer = 0;
  38. #endif
  39. #ifndef MK_3_SPEED
  40. static uint16_t last_timer_c = 0;
  41. static uint16_t last_timer_w = 0;
  42. /*
  43. * Mouse keys acceleration algorithm
  44. * http://en.wikipedia.org/wiki/Mouse_keys
  45. *
  46. * speed = delta * max_speed * (repeat / time_to_max)**((1000+curve)/1000)
  47. */
  48. /* milliseconds between the initial key press and first repeated motion event (0-2550) */
  49. uint8_t mk_delay = MOUSEKEY_DELAY / 10;
  50. /* milliseconds between repeated motion events (0-255) */
  51. uint8_t mk_interval = MOUSEKEY_INTERVAL;
  52. /* steady speed (in action_delta units) applied each event (0-255) */
  53. uint8_t mk_max_speed = MOUSEKEY_MAX_SPEED;
  54. /* number of events (count) accelerating to steady speed (0-255) */
  55. uint8_t mk_time_to_max = MOUSEKEY_TIME_TO_MAX;
  56. /* ramp used to reach maximum pointer speed (NOT SUPPORTED) */
  57. // int8_t mk_curve = 0;
  58. /* wheel params */
  59. /* milliseconds between the initial key press and first repeated motion event (0-2550) */
  60. uint8_t mk_wheel_delay = MOUSEKEY_WHEEL_DELAY / 10;
  61. /* milliseconds between repeated motion events (0-255) */
  62. uint8_t mk_wheel_interval = MOUSEKEY_WHEEL_INTERVAL;
  63. uint8_t mk_wheel_max_speed = MOUSEKEY_WHEEL_MAX_SPEED;
  64. uint8_t mk_wheel_time_to_max = MOUSEKEY_WHEEL_TIME_TO_MAX;
  65. # ifndef MK_COMBINED
  66. static uint8_t move_unit(void) {
  67. uint16_t unit;
  68. if (mousekey_accel & (1 << 0)) {
  69. unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed) / 4;
  70. } else if (mousekey_accel & (1 << 1)) {
  71. unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed) / 2;
  72. } else if (mousekey_accel & (1 << 2)) {
  73. unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed);
  74. } else if (mousekey_repeat == 0) {
  75. unit = MOUSEKEY_MOVE_DELTA;
  76. } else if (mousekey_repeat >= mk_time_to_max) {
  77. unit = MOUSEKEY_MOVE_DELTA * mk_max_speed;
  78. } else {
  79. unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed * mousekey_repeat) / mk_time_to_max;
  80. }
  81. return (unit > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : (unit == 0 ? 1 : unit));
  82. }
  83. static uint8_t wheel_unit(void) {
  84. uint16_t unit;
  85. if (mousekey_accel & (1 << 0)) {
  86. unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed) / 4;
  87. } else if (mousekey_accel & (1 << 1)) {
  88. unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed) / 2;
  89. } else if (mousekey_accel & (1 << 2)) {
  90. unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed);
  91. } else if (mousekey_wheel_repeat == 0) {
  92. unit = MOUSEKEY_WHEEL_DELTA;
  93. } else if (mousekey_wheel_repeat >= mk_wheel_time_to_max) {
  94. unit = MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed;
  95. } else {
  96. unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed * mousekey_wheel_repeat) / mk_wheel_time_to_max;
  97. }
  98. return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
  99. }
  100. # else /* #ifndef MK_COMBINED */
  101. # ifdef MK_KINETIC_SPEED
  102. /*
  103. * Kinetic movement acceleration algorithm
  104. *
  105. * current speed = I + A * T/50 + A * 0.5 * T^2 | maximum B
  106. *
  107. * T: time since the mouse movement started
  108. * E: mouse events per second (set through MOUSEKEY_INTERVAL, UHK sends 250, the
  109. * pro micro on my Signum 3.0 sends only 125!)
  110. * I: initial speed at time 0
  111. * A: acceleration
  112. * B: base mouse travel speed
  113. */
  114. const uint16_t mk_accelerated_speed = MOUSEKEY_ACCELERATED_SPEED;
  115. const uint16_t mk_base_speed = MOUSEKEY_BASE_SPEED;
  116. const uint16_t mk_decelerated_speed = MOUSEKEY_DECELERATED_SPEED;
  117. const uint16_t mk_initial_speed = MOUSEKEY_INITIAL_SPEED;
  118. static uint8_t move_unit(void) {
  119. float speed = mk_initial_speed;
  120. if (mousekey_accel & ((1 << 0) | (1 << 2))) {
  121. speed = mousekey_accel & (1 << 2) ? mk_accelerated_speed : mk_decelerated_speed;
  122. } else if (mousekey_repeat && mouse_timer) {
  123. const float time_elapsed = timer_elapsed(mouse_timer) / 50;
  124. speed = mk_initial_speed + MOUSEKEY_MOVE_DELTA * time_elapsed + MOUSEKEY_MOVE_DELTA * 0.5 * time_elapsed * time_elapsed;
  125. speed = speed > mk_base_speed ? mk_base_speed : speed;
  126. }
  127. /* convert speed to USB mouse speed 1 to 127 */
  128. speed = (uint8_t)(speed / (1000.0f / mk_interval));
  129. speed = speed < 1 ? 1 : speed;
  130. return speed > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : speed;
  131. }
  132. float mk_wheel_interval = 1000.0f / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
  133. static uint8_t wheel_unit(void) {
  134. float speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
  135. if (mousekey_accel & ((1 << 0) | (1 << 2))) {
  136. speed = mousekey_accel & (1 << 2) ? MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS : MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS;
  137. } else if (mousekey_repeat && mouse_timer) {
  138. if (mk_wheel_interval != MOUSEKEY_WHEEL_BASE_MOVEMENTS) {
  139. const float time_elapsed = timer_elapsed(mouse_timer) / 50;
  140. speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS + 1 * time_elapsed + 1 * 0.5 * time_elapsed * time_elapsed;
  141. }
  142. speed = speed > MOUSEKEY_WHEEL_BASE_MOVEMENTS ? MOUSEKEY_WHEEL_BASE_MOVEMENTS : speed;
  143. }
  144. mk_wheel_interval = 1000.0f / speed;
  145. return 1;
  146. }
  147. # else /* #ifndef MK_KINETIC_SPEED */
  148. static uint8_t move_unit(void) {
  149. uint16_t unit;
  150. if (mousekey_accel & (1 << 0)) {
  151. unit = 1;
  152. } else if (mousekey_accel & (1 << 1)) {
  153. unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed) / 2;
  154. } else if (mousekey_accel & (1 << 2)) {
  155. unit = MOUSEKEY_MOVE_MAX;
  156. } else if (mousekey_repeat == 0) {
  157. unit = MOUSEKEY_MOVE_DELTA;
  158. } else if (mousekey_repeat >= mk_time_to_max) {
  159. unit = MOUSEKEY_MOVE_DELTA * mk_max_speed;
  160. } else {
  161. unit = (MOUSEKEY_MOVE_DELTA * mk_max_speed * mousekey_repeat) / mk_time_to_max;
  162. }
  163. return (unit > MOUSEKEY_MOVE_MAX ? MOUSEKEY_MOVE_MAX : (unit == 0 ? 1 : unit));
  164. }
  165. static uint8_t wheel_unit(void) {
  166. uint16_t unit;
  167. if (mousekey_accel & (1 << 0)) {
  168. unit = 1;
  169. } else if (mousekey_accel & (1 << 1)) {
  170. unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed) / 2;
  171. } else if (mousekey_accel & (1 << 2)) {
  172. unit = MOUSEKEY_WHEEL_MAX;
  173. } else if (mousekey_repeat == 0) {
  174. unit = MOUSEKEY_WHEEL_DELTA;
  175. } else if (mousekey_repeat >= mk_wheel_time_to_max) {
  176. unit = MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed;
  177. } else {
  178. unit = (MOUSEKEY_WHEEL_DELTA * mk_wheel_max_speed * mousekey_repeat) / mk_wheel_time_to_max;
  179. }
  180. return (unit > MOUSEKEY_WHEEL_MAX ? MOUSEKEY_WHEEL_MAX : (unit == 0 ? 1 : unit));
  181. }
  182. # endif /* #ifndef MK_KINETIC_SPEED */
  183. # endif /* #ifndef MK_COMBINED */
  184. void mousekey_task(void) {
  185. // report cursor and scroll movement independently
  186. report_mouse_t const tmpmr = mouse_report;
  187. mouse_report.x = 0;
  188. mouse_report.y = 0;
  189. mouse_report.v = 0;
  190. mouse_report.h = 0;
  191. if ((tmpmr.x || tmpmr.y) && timer_elapsed(last_timer_c) > (mousekey_repeat ? mk_interval : mk_delay * 10)) {
  192. if (mousekey_repeat != UINT8_MAX) mousekey_repeat++;
  193. if (tmpmr.x != 0) mouse_report.x = move_unit() * ((tmpmr.x > 0) ? 1 : -1);
  194. if (tmpmr.y != 0) mouse_report.y = move_unit() * ((tmpmr.y > 0) ? 1 : -1);
  195. /* diagonal move [1/sqrt(2)] */
  196. if (mouse_report.x && mouse_report.y) {
  197. mouse_report.x = times_inv_sqrt2(mouse_report.x);
  198. if (mouse_report.x == 0) {
  199. mouse_report.x = 1;
  200. }
  201. mouse_report.y = times_inv_sqrt2(mouse_report.y);
  202. if (mouse_report.y == 0) {
  203. mouse_report.y = 1;
  204. }
  205. }
  206. }
  207. if ((tmpmr.v || tmpmr.h) && timer_elapsed(last_timer_w) > (mousekey_wheel_repeat ? mk_wheel_interval : mk_wheel_delay * 10)) {
  208. if (mousekey_wheel_repeat != UINT8_MAX) mousekey_wheel_repeat++;
  209. if (tmpmr.v != 0) mouse_report.v = wheel_unit() * ((tmpmr.v > 0) ? 1 : -1);
  210. if (tmpmr.h != 0) mouse_report.h = wheel_unit() * ((tmpmr.h > 0) ? 1 : -1);
  211. /* diagonal move [1/sqrt(2)] */
  212. if (mouse_report.v && mouse_report.h) {
  213. mouse_report.v = times_inv_sqrt2(mouse_report.v);
  214. if (mouse_report.v == 0) {
  215. mouse_report.v = 1;
  216. }
  217. mouse_report.h = times_inv_sqrt2(mouse_report.h);
  218. if (mouse_report.h == 0) {
  219. mouse_report.h = 1;
  220. }
  221. }
  222. }
  223. if (mouse_report.x || mouse_report.y || mouse_report.v || mouse_report.h) mousekey_send();
  224. mouse_report = tmpmr;
  225. }
  226. void mousekey_on(uint8_t code) {
  227. # ifdef MK_KINETIC_SPEED
  228. if (mouse_timer == 0) {
  229. mouse_timer = timer_read();
  230. }
  231. # endif /* #ifdef MK_KINETIC_SPEED */
  232. if (code == KC_MS_UP)
  233. mouse_report.y = move_unit() * -1;
  234. else if (code == KC_MS_DOWN)
  235. mouse_report.y = move_unit();
  236. else if (code == KC_MS_LEFT)
  237. mouse_report.x = move_unit() * -1;
  238. else if (code == KC_MS_RIGHT)
  239. mouse_report.x = move_unit();
  240. else if (code == KC_MS_WH_UP)
  241. mouse_report.v = wheel_unit();
  242. else if (code == KC_MS_WH_DOWN)
  243. mouse_report.v = wheel_unit() * -1;
  244. else if (code == KC_MS_WH_LEFT)
  245. mouse_report.h = wheel_unit() * -1;
  246. else if (code == KC_MS_WH_RIGHT)
  247. mouse_report.h = wheel_unit();
  248. else if (IS_MOUSEKEY_BUTTON(code))
  249. mouse_report.buttons |= 1 << (code - KC_MS_BTN1);
  250. else if (code == KC_MS_ACCEL0)
  251. mousekey_accel |= (1 << 0);
  252. else if (code == KC_MS_ACCEL1)
  253. mousekey_accel |= (1 << 1);
  254. else if (code == KC_MS_ACCEL2)
  255. mousekey_accel |= (1 << 2);
  256. }
  257. void mousekey_off(uint8_t code) {
  258. if (code == KC_MS_UP && mouse_report.y < 0)
  259. mouse_report.y = 0;
  260. else if (code == KC_MS_DOWN && mouse_report.y > 0)
  261. mouse_report.y = 0;
  262. else if (code == KC_MS_LEFT && mouse_report.x < 0)
  263. mouse_report.x = 0;
  264. else if (code == KC_MS_RIGHT && mouse_report.x > 0)
  265. mouse_report.x = 0;
  266. else if (code == KC_MS_WH_UP && mouse_report.v > 0)
  267. mouse_report.v = 0;
  268. else if (code == KC_MS_WH_DOWN && mouse_report.v < 0)
  269. mouse_report.v = 0;
  270. else if (code == KC_MS_WH_LEFT && mouse_report.h < 0)
  271. mouse_report.h = 0;
  272. else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0)
  273. mouse_report.h = 0;
  274. else if (IS_MOUSEKEY_BUTTON(code))
  275. mouse_report.buttons &= ~(1 << (code - KC_MS_BTN1));
  276. else if (code == KC_MS_ACCEL0)
  277. mousekey_accel &= ~(1 << 0);
  278. else if (code == KC_MS_ACCEL1)
  279. mousekey_accel &= ~(1 << 1);
  280. else if (code == KC_MS_ACCEL2)
  281. mousekey_accel &= ~(1 << 2);
  282. if (mouse_report.x == 0 && mouse_report.y == 0) {
  283. mousekey_repeat = 0;
  284. # ifdef MK_KINETIC_SPEED
  285. mouse_timer = 0;
  286. # endif /* #ifdef MK_KINETIC_SPEED */
  287. }
  288. if (mouse_report.v == 0 && mouse_report.h == 0) mousekey_wheel_repeat = 0;
  289. }
  290. #else /* #ifndef MK_3_SPEED */
  291. enum { mkspd_unmod, mkspd_0, mkspd_1, mkspd_2, mkspd_COUNT };
  292. # ifndef MK_MOMENTARY_ACCEL
  293. static uint8_t mk_speed = mkspd_1;
  294. # else
  295. static uint8_t mk_speed = mkspd_unmod;
  296. static uint8_t mkspd_DEFAULT = mkspd_unmod;
  297. # endif
  298. static uint16_t last_timer_c = 0;
  299. static uint16_t last_timer_w = 0;
  300. uint16_t c_offsets[mkspd_COUNT] = {MK_C_OFFSET_UNMOD, MK_C_OFFSET_0, MK_C_OFFSET_1, MK_C_OFFSET_2};
  301. uint16_t c_intervals[mkspd_COUNT] = {MK_C_INTERVAL_UNMOD, MK_C_INTERVAL_0, MK_C_INTERVAL_1, MK_C_INTERVAL_2};
  302. uint16_t w_offsets[mkspd_COUNT] = {MK_W_OFFSET_UNMOD, MK_W_OFFSET_0, MK_W_OFFSET_1, MK_W_OFFSET_2};
  303. uint16_t w_intervals[mkspd_COUNT] = {MK_W_INTERVAL_UNMOD, MK_W_INTERVAL_0, MK_W_INTERVAL_1, MK_W_INTERVAL_2};
  304. void mousekey_task(void) {
  305. // report cursor and scroll movement independently
  306. report_mouse_t const tmpmr = mouse_report;
  307. mouse_report.x = 0;
  308. mouse_report.y = 0;
  309. mouse_report.v = 0;
  310. mouse_report.h = 0;
  311. if ((tmpmr.x || tmpmr.y) && timer_elapsed(last_timer_c) > c_intervals[mk_speed]) {
  312. mouse_report.x = tmpmr.x;
  313. mouse_report.y = tmpmr.y;
  314. }
  315. if ((tmpmr.h || tmpmr.v) && timer_elapsed(last_timer_w) > w_intervals[mk_speed]) {
  316. mouse_report.v = tmpmr.v;
  317. mouse_report.h = tmpmr.h;
  318. }
  319. if (mouse_report.x || mouse_report.y || mouse_report.v || mouse_report.h) mousekey_send();
  320. mouse_report = tmpmr;
  321. }
  322. void adjust_speed(void) {
  323. uint16_t const c_offset = c_offsets[mk_speed];
  324. uint16_t const w_offset = w_offsets[mk_speed];
  325. if (mouse_report.x > 0) mouse_report.x = c_offset;
  326. if (mouse_report.x < 0) mouse_report.x = c_offset * -1;
  327. if (mouse_report.y > 0) mouse_report.y = c_offset;
  328. if (mouse_report.y < 0) mouse_report.y = c_offset * -1;
  329. if (mouse_report.h > 0) mouse_report.h = w_offset;
  330. if (mouse_report.h < 0) mouse_report.h = w_offset * -1;
  331. if (mouse_report.v > 0) mouse_report.v = w_offset;
  332. if (mouse_report.v < 0) mouse_report.v = w_offset * -1;
  333. // adjust for diagonals
  334. if (mouse_report.x && mouse_report.y) {
  335. mouse_report.x = times_inv_sqrt2(mouse_report.x);
  336. if (mouse_report.x == 0) {
  337. mouse_report.x = 1;
  338. }
  339. mouse_report.y = times_inv_sqrt2(mouse_report.y);
  340. if (mouse_report.y == 0) {
  341. mouse_report.y = 1;
  342. }
  343. }
  344. if (mouse_report.h && mouse_report.v) {
  345. mouse_report.h = times_inv_sqrt2(mouse_report.h);
  346. mouse_report.v = times_inv_sqrt2(mouse_report.v);
  347. }
  348. }
  349. void mousekey_on(uint8_t code) {
  350. uint16_t const c_offset = c_offsets[mk_speed];
  351. uint16_t const w_offset = w_offsets[mk_speed];
  352. uint8_t const old_speed = mk_speed;
  353. if (code == KC_MS_UP)
  354. mouse_report.y = c_offset * -1;
  355. else if (code == KC_MS_DOWN)
  356. mouse_report.y = c_offset;
  357. else if (code == KC_MS_LEFT)
  358. mouse_report.x = c_offset * -1;
  359. else if (code == KC_MS_RIGHT)
  360. mouse_report.x = c_offset;
  361. else if (code == KC_MS_WH_UP)
  362. mouse_report.v = w_offset;
  363. else if (code == KC_MS_WH_DOWN)
  364. mouse_report.v = w_offset * -1;
  365. else if (code == KC_MS_WH_LEFT)
  366. mouse_report.h = w_offset * -1;
  367. else if (code == KC_MS_WH_RIGHT)
  368. mouse_report.h = w_offset;
  369. else if (IS_MOUSEKEY_BUTTON(code))
  370. mouse_report.buttons |= 1 << (code - KC_MS_BTN1);
  371. else if (code == KC_MS_ACCEL0)
  372. mk_speed = mkspd_0;
  373. else if (code == KC_MS_ACCEL1)
  374. mk_speed = mkspd_1;
  375. else if (code == KC_MS_ACCEL2)
  376. mk_speed = mkspd_2;
  377. if (mk_speed != old_speed) adjust_speed();
  378. }
  379. void mousekey_off(uint8_t code) {
  380. # ifdef MK_MOMENTARY_ACCEL
  381. uint8_t const old_speed = mk_speed;
  382. # endif
  383. if (code == KC_MS_UP && mouse_report.y < 0)
  384. mouse_report.y = 0;
  385. else if (code == KC_MS_DOWN && mouse_report.y > 0)
  386. mouse_report.y = 0;
  387. else if (code == KC_MS_LEFT && mouse_report.x < 0)
  388. mouse_report.x = 0;
  389. else if (code == KC_MS_RIGHT && mouse_report.x > 0)
  390. mouse_report.x = 0;
  391. else if (code == KC_MS_WH_UP && mouse_report.v > 0)
  392. mouse_report.v = 0;
  393. else if (code == KC_MS_WH_DOWN && mouse_report.v < 0)
  394. mouse_report.v = 0;
  395. else if (code == KC_MS_WH_LEFT && mouse_report.h < 0)
  396. mouse_report.h = 0;
  397. else if (code == KC_MS_WH_RIGHT && mouse_report.h > 0)
  398. mouse_report.h = 0;
  399. else if (IS_MOUSEKEY_BUTTON(code))
  400. mouse_report.buttons &= ~(1 << (code - KC_MS_BTN1));
  401. # ifdef MK_MOMENTARY_ACCEL
  402. else if (code == KC_MS_ACCEL0)
  403. mk_speed = mkspd_DEFAULT;
  404. else if (code == KC_MS_ACCEL1)
  405. mk_speed = mkspd_DEFAULT;
  406. else if (code == KC_MS_ACCEL2)
  407. mk_speed = mkspd_DEFAULT;
  408. if (mk_speed != old_speed) adjust_speed();
  409. # endif
  410. }
  411. #endif /* #ifndef MK_3_SPEED */
  412. void mousekey_send(void) {
  413. mousekey_debug();
  414. uint16_t time = timer_read();
  415. if (mouse_report.x || mouse_report.y) last_timer_c = time;
  416. if (mouse_report.v || mouse_report.h) last_timer_w = time;
  417. host_mouse_send(&mouse_report);
  418. }
  419. void mousekey_clear(void) {
  420. mouse_report = (report_mouse_t){};
  421. mousekey_repeat = 0;
  422. mousekey_wheel_repeat = 0;
  423. mousekey_accel = 0;
  424. }
  425. static void mousekey_debug(void) {
  426. if (!debug_mouse) return;
  427. print("mousekey [btn|x y v h](rep/acl): [");
  428. print_hex8(mouse_report.buttons);
  429. print("|");
  430. print_decs(mouse_report.x);
  431. print(" ");
  432. print_decs(mouse_report.y);
  433. print(" ");
  434. print_decs(mouse_report.v);
  435. print(" ");
  436. print_decs(mouse_report.h);
  437. print("](");
  438. print_dec(mousekey_repeat);
  439. print("/");
  440. print_dec(mousekey_accel);
  441. print(")\n");
  442. }
  443. report_mouse_t mousekey_get_report(void) { return mouse_report; }