]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - tmk_core/common/mousekey.c
[Keyboard] fixed pins for numpad_5x4 layout (#6311)
[qmk_firmware.git] / tmk_core / common / mousekey.c
index 87239fbb76b5cc53466c09811ef2347e2e7a279e..bb08576b9faf96d0ca071f68adc28c781226896d 100644 (file)
@@ -114,7 +114,9 @@ void mousekey_task(void) {
   /* diagonal move [1/sqrt(2)] */
   if (mouse_report.x && mouse_report.y) {
     mouse_report.x = times_inv_sqrt2(mouse_report.x);
+    if (mouse_report.x == 0) { mouse_report.x = 1; }
     mouse_report.y = times_inv_sqrt2(mouse_report.y);
+    if (mouse_report.y == 0) { mouse_report.y = 1; }
   }
   if (mouse_report.v > 0) mouse_report.v = wheel_unit();
   if (mouse_report.v < 0) mouse_report.v = wheel_unit() * -1;
@@ -171,28 +173,31 @@ void mousekey_off(uint8_t code) {
 
 
 enum {
-  mkspd_slow,
-  mkspd_med,
-  mkspd_fast,
+  mkspd_unmod,
+  mkspd_0,
+  mkspd_1,
+  mkspd_2,
   mkspd_COUNT
 };
-static uint8_t mk_speed = mkspd_med;
-#ifdef MK_MOMENTARY_ACCEL
-static uint8_t mkspd_DEFAULT = mkspd_med;
+#ifndef MK_MOMENTARY_ACCEL
+static uint8_t mk_speed = mkspd_1;
+#else
+static uint8_t mk_speed = mkspd_unmod;
+static uint8_t mkspd_DEFAULT = mkspd_unmod;
 #endif
 static uint16_t last_timer_c = 0;
 static uint16_t last_timer_w = 0;
 uint16_t c_offsets[mkspd_COUNT] = {
-  MK_C_OFFSET_SLOW, MK_C_OFFSET_MED, MK_C_OFFSET_FAST
+  MK_C_OFFSET_UNMOD, MK_C_OFFSET_0, MK_C_OFFSET_1, MK_C_OFFSET_2
 };
 uint16_t c_intervals[mkspd_COUNT] = {
-  MK_C_INTERVAL_SLOW, MK_C_INTERVAL_MED, MK_C_INTERVAL_FAST
+  MK_C_INTERVAL_UNMOD, MK_C_INTERVAL_0, MK_C_INTERVAL_1, MK_C_INTERVAL_2
 };
 uint16_t w_offsets[mkspd_COUNT] = {
-  MK_W_OFFSET_SLOW, MK_W_OFFSET_MED, MK_W_OFFSET_FAST
+  MK_W_OFFSET_UNMOD, MK_W_OFFSET_0, MK_W_OFFSET_1, MK_W_OFFSET_2
 };
 uint16_t w_intervals[mkspd_COUNT] = {
-  MK_W_INTERVAL_SLOW, MK_W_INTERVAL_MED, MK_W_INTERVAL_FAST
+  MK_W_INTERVAL_UNMOD, MK_W_INTERVAL_0, MK_W_INTERVAL_1, MK_W_INTERVAL_2
 };
 
 
@@ -229,7 +234,9 @@ void adjust_speed(void) {
   // adjust for diagonals
   if (mouse_report.x && mouse_report.y) {
   mouse_report.x = times_inv_sqrt2(mouse_report.x);
+  if (mouse_report.x == 0) { mouse_report.x = 1; }
   mouse_report.y = times_inv_sqrt2(mouse_report.y);
+  if (mouse_report.y == 0) { mouse_report.y = 1; }
   }
   if (mouse_report.h && mouse_report.v) {
   mouse_report.h = times_inv_sqrt2(mouse_report.h);
@@ -254,9 +261,9 @@ void mousekey_on(uint8_t code) {
   else if (code == KC_MS_BTN3)     mouse_report.buttons |= MOUSE_BTN3;
   else if (code == KC_MS_BTN4)     mouse_report.buttons |= MOUSE_BTN4;
   else if (code == KC_MS_BTN5)     mouse_report.buttons |= MOUSE_BTN5;
-  else if (code == KC_MS_ACCEL0)   mk_speed = mkspd_slow;
-  else if (code == KC_MS_ACCEL1)   mk_speed = mkspd_med;
-  else if (code == KC_MS_ACCEL2)   mk_speed = mkspd_fast;
+  else if (code == KC_MS_ACCEL0)   mk_speed = mkspd_0;
+  else if (code == KC_MS_ACCEL1)   mk_speed = mkspd_1;
+  else if (code == KC_MS_ACCEL2)   mk_speed = mkspd_2;
   if (mk_speed != old_speed) adjust_speed();
 }