]> git.donarmstrong.com Git - tmk_firmware.git/commitdiff
Fix legacy keymap support
authortmk <nobody@nowhere>
Mon, 11 Mar 2013 05:39:06 +0000 (14:39 +0900)
committertmk <nobody@nowhere>
Mon, 11 Mar 2013 05:39:06 +0000 (14:39 +0900)
- need to define USE_LEGACY_KEYMAP to use legacy keymap

common/keymap.c
common/keymap.h
converter/pc98_usb/config.h
converter/sun_usb/config.h
keyboard/gh60/config.h
keyboard/hhkb/config.h
keyboard/hhkb/config_iwrap.h

index aa8d944a79301f400ee1e3b24de0d7c1b8a8c2d1..ace3f49b69c01303a9a601b7f097086c4ec9b214 100644 (file)
@@ -26,7 +26,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 static action_t keycode_to_action(uint8_t keycode);
 
-#ifdef USE_KEYMAP_V2
+
 /* converts key to action */
 action_t action_for_key(uint8_t layer, key_t key)
 {
@@ -38,42 +38,20 @@ action_t action_for_key(uint8_t layer, key_t key)
             return keycode_to_action(keycode);
     }
 }
-#else
-/* 
- * legacy keymap support
- */
-/* translation for legacy keymap */
-action_t action_for_key(uint8_t layer, key_t key)
-{
-    /* convert from legacy keycode to action */
-    /* layer 16-31 indicate 'overlay' but not supported in legacy keymap */
-    uint8_t keycode = keymap_get_keycode((layer & OVERLAY_MASK), key.row, key.col);
-    action_t action;
-    switch (keycode) {
-        case KC_FN0 ... KC_FN31:
-            {
-                uint8_t layer = keymap_fn_layer(FN_INDEX(keycode));
-                uint8_t key = keymap_fn_keycode(FN_INDEX(keycode));
-                if (key) {
-                    action.code = ACTION_KEYMAP_TAP_KEY(layer, key);
-                } else {
-                    action.code = ACTION_KEYMAP_MOMENTARY(layer);
-                }
-            }
-            return action;
-        default:
-            return keycode_to_action(keycode);
-    }
-}
-#endif
 
 
+/* Macro */
 __attribute__ ((weak))
-const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { return MACRO_NONE; }
+const prog_macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+    return MACRO_NONE;
+}
 
+/* Function */
 __attribute__ ((weak))
-void action_function(keyrecord_t *record, uint8_t id, uint8_t opt) {}
-
+void action_function(keyrecord_t *record, uint8_t id, uint8_t opt)
+{
+}
 
 
 
@@ -83,14 +61,9 @@ static action_t keycode_to_action(uint8_t keycode)
     action_t action;
     switch (keycode) {
         case KC_A ... KC_EXSEL:
+        case KC_LCTRL ... KC_RGUI:
             action.code = ACTION_KEY(keycode);
             break;
-        case KC_LCTRL ... KC_LGUI:
-            action.code = ACTION_LMOD(keycode);
-            break;
-        case KC_RCTRL ... KC_RGUI:
-            action.code = ACTION_RMOD(keycode);
-            break;
         case KC_SYSTEM_POWER ... KC_SYSTEM_WAKE:
             action.code = ACTION_USAGE_SYSTEM(KEYCODE2SYSTEM(keycode));
             break;
@@ -109,3 +82,40 @@ static action_t keycode_to_action(uint8_t keycode)
     }
     return action;
 }
+
+
+
+#ifdef USE_LEGACY_KEYMAP
+/*
+ * Legacy keymap support
+ *      Consider using new keymap API instead.
+ */
+__attribute__ ((weak))
+uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
+{
+    return keymap_get_keycode(layer, key.row, key.col);
+}
+
+
+/* Legacy keymap support */
+__attribute__ ((weak))
+action_t keymap_fn_to_action(uint8_t keycode)
+{
+    action_t action = { .code = ACTION_NO };
+    switch (keycode) {
+        case KC_FN0 ... KC_FN31:
+            {
+                uint8_t layer = keymap_fn_layer(FN_INDEX(keycode));
+                uint8_t key = keymap_fn_keycode(FN_INDEX(keycode));
+                if (key) {
+                    action.code = ACTION_KEYMAP_TAP_KEY(layer, key);
+                } else {
+                    action.code = ACTION_KEYMAP_MOMENTARY(layer);
+                }
+            }
+            return action;
+        default:
+            return action;
+    }
+}
+#endif
index 0c483483fb89f6daf6204555abd93a042d879a73..7efd91f704ab7fcd0f80080857337553998097d1 100644 (file)
@@ -23,24 +23,29 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include "action.h"
 
 
-#ifdef USE_KEYMAP_V2
-/* translates key to keycode
- *      layer:  0-15 for base layers
- *              16-31 for overlays
- */
+/* translates key to keycode */
 uint8_t keymap_key_to_keycode(uint8_t layer, key_t key);
+
 /* translates Fn keycode to action */
 action_t keymap_fn_to_action(uint8_t keycode);
-#else
-#warning "You are using LEGACY KEYAMP. Consider using NEW KEYMAP."
+
+
+
+#ifdef USE_LEGACY_KEYMAP
 /* 
- * legacy keymap support
+ * Legacy keymap
+ *      Consider using new keymap API above instead.
  */
 /* keycode of key */
+__attribute__ ((deprecated))
 uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col);
+
 /* layer to move during press Fn key */
+__attribute__ ((deprecated))
 uint8_t keymap_fn_layer(uint8_t fn_bits);
+
 /* keycode to send when release Fn key without using */
+__attribute__ ((deprecated))
 uint8_t keymap_fn_keycode(uint8_t fn_bits);
 #endif
 
index 4f91c07ce440e6777c926983acc1a4388579282b..b8d676e4cfacae5d5435fcedfe93005e94d37b50 100644 (file)
@@ -30,9 +30,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define MATRIX_ROWS     16
 #define MATRIX_COLS     8
 
-/* To use new keymap framework */
-#define USE_KEYMAP_V2
-
 /* key combination for command */
 #define IS_COMMAND()    ( \
     host_get_first_key() == KC_CANCEL \
index 65ce9daf6102a432652612a0c9c023292f5bec54..32303cd32b0305bc292b8d8f80518e21ed0b9ef9 100644 (file)
@@ -25,12 +25,10 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define PRODUCT         Sun keyboard converter
 #define DESCRIPTION     converts Sun keyboard protocol into USB
 
-
 /* matrix size */
 #define MATRIX_ROWS 16
 #define MATRIX_COLS 8
 
-
 /* key combination for command */
 #define IS_COMMAND() ( \
     keyboard_report->mods == (MOD_BIT(KC_LALT) | MOD_BIT(KC_RALT)) || \
@@ -38,6 +36,18 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
     keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
 )
 
+/* legacy keymap support */
+#define USE_LEGACY_KEYMAP
+
+/* Boot Section Size in *BYTEs*
+ *   Teensy   halfKay    512
+ *   Teensy++ halfKay    1024
+ *   Atmel DFU loader    4096
+ *   LUFA bootloader     4096
+ *   USBaspLoader        2048
+ */
+#define BOOTLOADER_SIZE 4096
+
 
 /* Serial(USART) configuration
  *     asynchronous, negative logic, 1200baud, no flow control
index be4d72384eaf1d9ddfe380558b615c74dd47ab2f..cd98395eb50da985c99d91c0f7af195d2d92a16e 100644 (file)
@@ -25,20 +25,8 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define DEVICE_VER      0x0001
 #define MANUFACTURER    geekhack
 #define PRODUCT         GH60
-/* message strings */
 #define DESCRIPTION     t.m.k. keyboard firmware for GH60
 
-
-/* Boot Section Size in *BYTEs*
- *   Teensy   halfKay    512
- *   Teensy++ halfKay    1024
- *   Atmel DFU loader    4096
- *   LUFA bootloader     4096
- *   USBaspLoader        2048
- */
-#define BOOTLOADER_SIZE 4096
-
-
 /* matrix size */
 #define MATRIX_ROWS 5
 #define MATRIX_COLS 14
@@ -49,14 +37,20 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 /* Set 0 if need no debouncing */
 #define DEBOUNCE    5
 
-/* To use new keymap framework */
-#define USE_KEYMAP_V2
-
 /* key combination for command */
 #define IS_COMMAND() ( \
     keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
 )
 
+/* Boot Section Size in *BYTEs*
+ *   Teensy   halfKay    512
+ *   Teensy++ halfKay    1024
+ *   Atmel DFU loader    4096
+ *   LUFA bootloader     4096
+ *   USBaspLoader        2048
+ */
+#define BOOTLOADER_SIZE 4096
+
 /* 
  * Boot magic keys
  * call some function by pressing key when pluging cable or powering on.
index 3bfeb45ed4c71f07275641e3766749f75c66ffa1..ef2958981c96e00580f6027516ddd2851fb13720 100644 (file)
@@ -44,9 +44,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define MATRIX_ROWS 8
 #define MATRIX_COLS 8
 
-/* To use new keymap framework */
-#define USE_KEYMAP_V2
-
 /* 
  * Boot magic keys
  * call some function by pressing key when pluging cable or powering on.
index 2c18cd817a51ab9f42c4941f97cec43df63706c2..7a4ec3711858e2cba758b513a0c42bca86ed5c55 100644 (file)
@@ -41,9 +41,6 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define MATRIX_ROWS 8
 #define MATRIX_COLS 8
 
-/* To use new keymap framework */
-#define USE_KEYMAP_V2
-
 /* key combination for command */
 #define IS_COMMAND() (keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)))