]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Fix build option MOUSEKEY_ENABLE.
authortmk <nobody@nowhere>
Wed, 10 Oct 2012 02:06:47 +0000 (11:06 +0900)
committertmk <nobody@nowhere>
Wed, 17 Oct 2012 06:55:37 +0000 (15:55 +0900)
common/keyboard.c
common/mousekey.c
keyboard/hhkb/config.h
keyboard/hhkb/config_vusb.h

index 37d3b06ba2b672102890cbc3e682f0cdd37d4853..43abf4236f62d6f693f242d99b31d4c7a7cd974d 100644 (file)
@@ -90,8 +90,10 @@ static void clear_keyboard(void)
     host_system_send(0);
     host_consumer_send(0);
 
+#ifdef MOUSEKEY_ENABLE
     mousekey_clear();
     mousekey_send();
+#endif
 }
 
 static void clear_keyboard_but_mods(void)
@@ -102,8 +104,10 @@ static void clear_keyboard_but_mods(void)
     host_system_send(0);
     host_consumer_send(0);
 
+#ifdef MOUSEKEY_ENABLE
     mousekey_clear();
     mousekey_send();
+#endif
 }
 
 static void layer_switch_on(uint8_t code)
@@ -159,8 +163,10 @@ static void register_code(uint8_t code)
         host_send_keyboard_report();
     }
     else if IS_MOUSEKEY(code) {
+#ifdef MOUSEKEY_ENABLE
         mousekey_on(code);
         mousekey_send();
+#endif
     }
     else if IS_CONSUMER(code) {
         uint16_t usage = 0;
@@ -251,8 +257,10 @@ static void unregister_code(uint8_t code)
         host_send_keyboard_report();
     }
     else if IS_MOUSEKEY(code) {
+#ifdef MOUSEKEY_ENABLE
         mousekey_off(code);
         mousekey_send();
+#endif
     }
     else if IS_CONSUMER(code) {
         host_consumer_send(0x0000);
@@ -390,7 +398,7 @@ static inline void process_key(keyevent_t event)
                 case KEY_UP:
                 case MOD_UP:
                     unregister_code(code);
-                    // no key registered? mousekey, mediakey, systemkey
+                    // TODO: no key registered? mousekey, mediakey, systemkey
                     if (!host_has_anykey())
                         NEXT(IDLE);
                     break;
@@ -570,8 +578,10 @@ void keyboard_task(void)
         }
     }
 
+#ifdef MOUSEKEY_ENABLE
     // mousekey repeat & acceleration
     mousekey_task();
+#endif
 
     // FAIL SAFE: clear all key if no key down
     if (matrix_change) {
index 58a6e35bb09352b5b0b9fd814226c9adcc143a4d..6fe8e2d2658b9c6a0744b0d1a8871d0847313955 100644 (file)
@@ -37,7 +37,7 @@ static void mousekey_debug(void);
  * see wikipedia http://en.wikipedia.org/wiki/Mouse_keys
  */
 #ifndef MOUSEKEY_DELAY_TIME
-#   define MOUSEKEY_DELAY_TIME 20
+#   define MOUSEKEY_DELAY_TIME 100
 #endif
 
 #define MOUSEKEY_MOVE_INIT      5
@@ -54,10 +54,16 @@ static uint16_t last_timer = 0;
 
 static inline uint8_t move_unit(void)
 {
-    uint16_t unit = 5 + mousekey_repeat*4;
+    uint16_t unit = MOUSEKEY_MOVE_INIT + MOUSEKEY_MOVE_ACCEL * mousekey_repeat;
     return (unit > 63 ? 63 : unit);
 }
 
+static inline uint8_t wheel_unit(void)
+{
+    uint16_t unit = MOUSEKEY_WHEEL_INIT + MOUSEKEY_WHEEL_ACCEL * mousekey_repeat;
+    return (unit > 15 ? 15 : unit);
+}
+
 void mousekey_task(void)
 {
     if (timer_elapsed(last_timer) < MOUSEKEY_DELAY_TIME)
@@ -80,10 +86,10 @@ void mousekey_task(void)
         report.y *= 0.7;
     }
 
-    if (report.v > 0) report.v = move_unit();
-    if (report.v < 0) report.v = move_unit() * -1;
-    if (report.h > 0) report.h = move_unit();
-    if (report.h < 0) report.h = move_unit() * -1;
+    if (report.v > 0) report.v = wheel_unit();
+    if (report.v < 0) report.v = wheel_unit() * -1;
+    if (report.h > 0) report.h = wheel_unit();
+    if (report.h < 0) report.h = wheel_unit() * -1;
 
     mousekey_send();
 }
@@ -107,19 +113,19 @@ void mousekey_on(uint8_t code)
 
 void mousekey_off(uint8_t code)
 {
-    if      (code == KC_MS_UP    && report.y < 0) report.y = 0;
-    else if (code == KC_MS_DOWN  && report.y > 0) report.y = 0;
-    else if (code == KC_MS_LEFT  && report.x < 0) report.x = 0;
-    else if (code == KC_MS_RIGHT && report.x > 0) report.x = 0;
+    if      (code == KC_MS_UP       && report.y < 0) report.y = 0;
+    else if (code == KC_MS_DOWN     && report.y > 0) report.y = 0;
+    else if (code == KC_MS_LEFT     && report.x < 0) report.x = 0;
+    else if (code == KC_MS_RIGHT    && report.x > 0) report.x = 0;
     else if (code == KC_MS_WH_UP    && report.v > 0) report.v = 0;
     else if (code == KC_MS_WH_DOWN  && report.v < 0) report.v = 0;
     else if (code == KC_MS_WH_LEFT  && report.h < 0) report.h = 0;
     else if (code == KC_MS_WH_RIGHT && report.h > 0) report.h = 0;
-    else if (code == KC_MS_BTN1) report.buttons &= ~MOUSE_BTN1;
-    else if (code == KC_MS_BTN2) report.buttons &= ~MOUSE_BTN2;
-    else if (code == KC_MS_BTN3) report.buttons &= ~MOUSE_BTN3;
-    else if (code == KC_MS_BTN4) report.buttons &= ~MOUSE_BTN4;
-    else if (code == KC_MS_BTN5) report.buttons &= ~MOUSE_BTN5;
+    else if (code == KC_MS_BTN1)                     report.buttons &= ~MOUSE_BTN1;
+    else if (code == KC_MS_BTN2)                     report.buttons &= ~MOUSE_BTN2;
+    else if (code == KC_MS_BTN3)                     report.buttons &= ~MOUSE_BTN3;
+    else if (code == KC_MS_BTN4)                     report.buttons &= ~MOUSE_BTN4;
+    else if (code == KC_MS_BTN5)                     report.buttons &= ~MOUSE_BTN5;
 
     if (report.x == 0 && report.y == 0 && report.v == 0 && report.h == 0)
         mousekey_repeat = 0;
index e10a7ab37f78be0c96c0d36034183231e65727a4..cca75f2434d9692d2ea09cc53ed5095d3e008aa9 100644 (file)
@@ -42,7 +42,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 /* mouse keys */
 #ifdef MOUSEKEY_ENABLE
-#   define MOUSEKEY_DELAY_TIME 192
+#   define MOUSEKEY_DELAY_TIME 100
 #endif
 
 
index b85e16fa3f2b14b54024f6068a888bcde785d6d3..44d5e4557dc82e3039938b2cbeaede9ecf74b6b2 100644 (file)
@@ -37,7 +37,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 /* mouse keys */
 #ifdef MOUSEKEY_ENABLE
-#   define MOUSEKEY_DELAY_TIME 255
+#   define MOUSEKEY_DELAY_TIME 100
 #endif