]> git.friedersdorff.com Git - max/tmk_keyboard.git/commitdiff
Cleanup file structure to more closely match tmk
authorMark Sikora <marknsikora@gmail.com>
Sat, 28 May 2016 23:51:38 +0000 (19:51 -0400)
committerMark Sikora <marknsikora@gmail.com>
Sat, 28 May 2016 23:51:38 +0000 (19:51 -0400)
keyboard/ergodox/Makefile.lufa
keyboard/ergodox/Makefile.pjrc
keyboard/ergodox/keymap_blazak.c [moved from keyboard/ergodox/keymap.c with 51% similarity]
keyboard/ergodox/keymap_colemak.h [deleted file]
keyboard/ergodox/keymap_common.c [new file with mode: 0644]
keyboard/ergodox/keymap_common.h [new file with mode: 0644]
keyboard/ergodox/keymap_cub.c [moved from keyboard/ergodox/keymap_cub.h with 98% similarity]
keyboard/ergodox/keymap_dvorak.h [deleted file]
keyboard/ergodox/keymap_micro.c [moved from keyboard/ergodox/keymap_micro.h with 98% similarity]
keyboard/ergodox/keymap_workman.h [deleted file]

index abb57017aee97184744a8a45127b9f21fc9ac409..976877e110e6e4ced94c8277b79dc08ade3409bf 100644 (file)
@@ -48,12 +48,18 @@ TMK_DIR = ../../tmk_core
 TARGET_DIR = .
 
 # project specific files
-SRC =  keymap.c \
+SRC =  keymap_common.c \
        matrix.c \
        led.c \
        ergodox.c \
        twimaster.c
 
+ifdef KEYMAP
+    SRC := keymap_$(KEYMAP).c $(SRC)
+else
+    SRC := keymap_blazak.c $(SRC)
+endif
+
 CONFIG_H = config.h
 
 
@@ -121,20 +127,3 @@ include $(TMK_DIR)/protocol.mk
 include $(TMK_DIR)/protocol/lufa.mk
 include $(TMK_DIR)/common.mk
 include $(TMK_DIR)/rules.mk
-
-dvorak: OPT_DEFS += -DKEYMAP_DVORAK
-dvorak: all
-
-colemak: OPT_DEFS += -DKEYMAP_COLEMAK
-colemak: all
-
-workman: OPT_DEFS += -DKEYMAP_WORKMAN
-workman: all
-
-micro: OPT_DEFS += -DKEYMAP_MICRO
-micro: all
-
-cub: OPT_DEFS += -DKEYMAP_CUB
-cub: all
-
-
index aa29a361c33726c9e8ecb950e9076991f0dd84e0..04b07d9fb03bab41b67d92a05a6d2c84a98d9da0 100644 (file)
@@ -48,12 +48,18 @@ TMK_DIR = ../../tmk_core
 TARGET_DIR = .
 
 # project specific files
-SRC =  keymap.c \
+SRC =  keymap_common.c \
        matrix.c \
        led.c \
        ergodox.c \
        twimaster.c
 
+ifdef KEYMAP
+    SRC := keymap_$(KEYMAP).c $(SRC)
+else
+    SRC := keymap_blazak.c $(SRC)
+endif
+
 CONFIG_H = config.h
 
 
@@ -100,20 +106,3 @@ include $(TMK_DIR)/protocol.mk
 include $(TMK_DIR)/protocol/pjrc.mk
 include $(TMK_DIR)/common.mk
 include $(TMK_DIR)/rules.mk
-
-dvorak: OPT_DEFS += -DKEYMAP_DVORAK
-dvorak: all
-
-colemak: OPT_DEFS += -DKEYMAP_COLEMAK
-colemak: all
-
-workman: OPT_DEFS += -DKEYMAP_WORKMAN
-workman: all
-
-micro: OPT_DEFS += -DKEYMAP_MICRO
-micro: all
-
-cub: OPT_DEFS += -DKEYMAP_CUB
-cub: all
-
-
similarity index 51%
rename from keyboard/ergodox/keymap.c
rename to keyboard/ergodox/keymap_blazak.c
index 39713e5026ae4a1fb9d745a9ae02901f71ab85bc..2a8164c5481e4601ae65d2455db7c54656586c01 100644 (file)
@@ -14,80 +14,12 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
-#include <stdint.h>
-#include <stdbool.h>
-#include <avr/pgmspace.h>
 #include <util/delay.h>
-#include "keycode.h"
-#include "action.h"
-#include "action_util.h"
-#include "action_code.h"
-#include "action_macro.h"
-#include "action_layer.h"
 #include "bootloader.h"
-#include "report.h"
-#include "host.h"
-#include "print.h"
-#include "debug.h"
-#include "keymap.h"
-#include "ergodox.h"
+#include "keymap_common.h"
 
 
-/* ErgoDox keymap definition macro */
-#define KEYMAP(                                                 \
-                                                                \
-    /* left hand, spatial positions */                          \
-    k00,k01,k02,k03,k04,k05,k06,                                \
-    k10,k11,k12,k13,k14,k15,k16,                                \
-    k20,k21,k22,k23,k24,k25,                                    \
-    k30,k31,k32,k33,k34,k35,k36,                                \
-    k40,k41,k42,k43,k44,                                        \
-                            k55,k56,                            \
-                                k54,                            \
-                        k53,k52,k51,                            \
-                                                                \
-    /* right hand, spatial positions */                         \
-        k07,k08,k09,k0A,k0B,k0C,k0D,                            \
-        k17,k18,k19,k1A,k1B,k1C,k1D,                            \
-            k28,k29,k2A,k2B,k2C,k2D,                            \
-        k37,k38,k39,k3A,k3B,k3C,k3D,                            \
-                k49,k4A,k4B,k4C,k4D,                            \
-    k57,k58,                                                    \
-    k59,                                                        \
-    k5C,k5B,k5A )                                               \
-                                                                \
-   /* matrix positions */                                       \
-   {                                                            \
-    { KC_##k00,KC_##k10,KC_##k20,KC_##k30,KC_##k40,KC_NO   },   \
-    { KC_##k01,KC_##k11,KC_##k21,KC_##k31,KC_##k41,KC_##k51},   \
-    { KC_##k02,KC_##k12,KC_##k22,KC_##k32,KC_##k42,KC_##k52},   \
-    { KC_##k03,KC_##k13,KC_##k23,KC_##k33,KC_##k43,KC_##k53},   \
-    { KC_##k04,KC_##k14,KC_##k24,KC_##k34,KC_##k44,KC_##k54},   \
-    { KC_##k05,KC_##k15,KC_##k25,KC_##k35,KC_NO,   KC_##k55},   \
-    { KC_##k06,KC_##k16,KC_NO,   KC_##k36,KC_NO,   KC_##k56},   \
-                                                                \
-    { KC_##k07,KC_##k17,KC_NO,   KC_##k37,KC_NO,   KC_##k57},   \
-    { KC_##k08,KC_##k18,KC_##k28,KC_##k38,KC_NO,   KC_##k58},   \
-    { KC_##k09,KC_##k19,KC_##k29,KC_##k39,KC_##k49,KC_##k59},   \
-    { KC_##k0A,KC_##k1A,KC_##k2A,KC_##k3A,KC_##k4A,KC_##k5A},   \
-    { KC_##k0B,KC_##k1B,KC_##k2B,KC_##k3B,KC_##k4B,KC_##k5B},   \
-    { KC_##k0C,KC_##k1C,KC_##k2C,KC_##k3C,KC_##k4C,KC_##k5C},   \
-    { KC_##k0D,KC_##k1D,KC_##k2D,KC_##k3D,KC_##k4D,KC_NO   }    \
-   }
-
-#if defined(KEYMAP_DVORAK)
-#include "keymap_dvorak.h"
-#elif defined(KEYMAP_COLEMAK)
-#include "keymap_colemak.h"
-#elif defined(KEYMAP_WORKMAN)
-#include "keymap_workman.h"
-#elif defined(KEYMAP_MICRO)
-#include "keymap_micro.h"
-#elif defined(KEYMAP_CUB)
-#include "keymap_cub.h"
-#else
-
-static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     KEYMAP(  // layer 0 : default
         // left hand
         EQL, 1,   2,   3,   4,   5,   ESC,
@@ -182,7 +114,7 @@ enum function_id {
 /*
  * Fn action definition
  */
-static const uint16_t PROGMEM fn_actions[] = {
+const uint16_t PROGMEM fn_actions[] = {
     ACTION_FUNCTION(TEENSY_KEY),                    // FN0 - Teensy key
     ACTION_LAYER_MOMENTARY(1),                      // FN1 - switch to Layer1
     ACTION_LAYER_SET(2, ON_PRESS),                  // FN2 - set Layer2
@@ -200,39 +132,3 @@ void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
         print("not supported.\n");
     }
 }
-
-#endif
-
-
-#define KEYMAPS_SIZE    (sizeof(keymaps) / sizeof(keymaps[0]))
-#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
-
-/* translates key to keycode */
-uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
-{
-    if (layer < KEYMAPS_SIZE) {
-        return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
-    } else {
-        // fall back to layer 0
-        return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
-    }
-}
-
-#if defined(KEYMAP_CUB)
-
-// function keymap_fn_to_action will be defined in keymap_cub.h
-
-#else
-/* translates Fn keycode to action */
-action_t keymap_fn_to_action(uint8_t keycode)
-{
-    action_t action;
-    if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
-        action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
-    } else {
-        action.code = ACTION_NO;
-    }
-    return action;
-}
-#endif
-
diff --git a/keyboard/ergodox/keymap_colemak.h b/keyboard/ergodox/keymap_colemak.h
deleted file mode 100644 (file)
index 4e5565e..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#error Colemak layout is not defined yet
-static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-};
-static const uint16_t PROGMEM fn_actions[] = {};
diff --git a/keyboard/ergodox/keymap_common.c b/keyboard/ergodox/keymap_common.c
new file mode 100644 (file)
index 0000000..5bae063
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
+Copyright 2016 Mark Sikora <marknsikora@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "keymap_common.h"
+
+/* translates key to keycode */
+__attribute__ ((weak))
+uint8_t keymap_key_to_keycode(uint8_t layer, keypos_t key)
+{
+    return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+}
+
+/* translates Fn keycode to action */
+__attribute__ ((weak))
+action_t keymap_fn_to_action(uint8_t keycode)
+{
+    return (action_t){ .code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]) };
+}
diff --git a/keyboard/ergodox/keymap_common.h b/keyboard/ergodox/keymap_common.h
new file mode 100644 (file)
index 0000000..656c28f
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+Copyright 2013 Oleg Kostyuk <cub.uanic@gmail.com>
+Copyright 2016 Mark Sikora <marknsikora@gmail.com>
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program.  If not, see <http://www.gnu.org/licenses/>.
+*/
+#ifndef KEYMAP_COMMON_H
+#define KEYMAP_COMMON_H
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <avr/pgmspace.h>
+#include "keycode.h"
+#include "action.h"
+#include "action_macro.h"
+#include "report.h"
+#include "host.h"
+#include "print.h"
+#include "debug.h"
+#include "keymap.h"
+
+
+extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
+extern const uint16_t fn_actions[];
+
+
+/* ErgoDox keymap definition macro */
+#define KEYMAP(                                                 \
+                                                                \
+    /* left hand, spatial positions */                          \
+    k00,k01,k02,k03,k04,k05,k06,                                \
+    k10,k11,k12,k13,k14,k15,k16,                                \
+    k20,k21,k22,k23,k24,k25,                                    \
+    k30,k31,k32,k33,k34,k35,k36,                                \
+    k40,k41,k42,k43,k44,                                        \
+                            k55,k56,                            \
+                                k54,                            \
+                        k53,k52,k51,                            \
+                                                                \
+    /* right hand, spatial positions */                         \
+        k07,k08,k09,k0A,k0B,k0C,k0D,                            \
+        k17,k18,k19,k1A,k1B,k1C,k1D,                            \
+            k28,k29,k2A,k2B,k2C,k2D,                            \
+        k37,k38,k39,k3A,k3B,k3C,k3D,                            \
+                k49,k4A,k4B,k4C,k4D,                            \
+    k57,k58,                                                    \
+    k59,                                                        \
+    k5C,k5B,k5A )                                               \
+                                                                \
+   /* matrix positions */                                       \
+   {                                                            \
+    { KC_##k00,KC_##k10,KC_##k20,KC_##k30,KC_##k40,KC_NO   },   \
+    { KC_##k01,KC_##k11,KC_##k21,KC_##k31,KC_##k41,KC_##k51},   \
+    { KC_##k02,KC_##k12,KC_##k22,KC_##k32,KC_##k42,KC_##k52},   \
+    { KC_##k03,KC_##k13,KC_##k23,KC_##k33,KC_##k43,KC_##k53},   \
+    { KC_##k04,KC_##k14,KC_##k24,KC_##k34,KC_##k44,KC_##k54},   \
+    { KC_##k05,KC_##k15,KC_##k25,KC_##k35,KC_NO,   KC_##k55},   \
+    { KC_##k06,KC_##k16,KC_NO,   KC_##k36,KC_NO,   KC_##k56},   \
+                                                                \
+    { KC_##k07,KC_##k17,KC_NO,   KC_##k37,KC_NO,   KC_##k57},   \
+    { KC_##k08,KC_##k18,KC_##k28,KC_##k38,KC_NO,   KC_##k58},   \
+    { KC_##k09,KC_##k19,KC_##k29,KC_##k39,KC_##k49,KC_##k59},   \
+    { KC_##k0A,KC_##k1A,KC_##k2A,KC_##k3A,KC_##k4A,KC_##k5A},   \
+    { KC_##k0B,KC_##k1B,KC_##k2B,KC_##k3B,KC_##k4B,KC_##k5B},   \
+    { KC_##k0C,KC_##k1C,KC_##k2C,KC_##k3C,KC_##k4C,KC_##k5C},   \
+    { KC_##k0D,KC_##k1D,KC_##k2D,KC_##k3D,KC_##k4D,KC_NO   }    \
+   }
+
+#endif
similarity index 98%
rename from keyboard/ergodox/keymap_cub.h
rename to keyboard/ergodox/keymap_cub.c
index 322730259ce6d6e906b004a125f3cb45ad2e4903..aba7c79a81d106b9b8f7d5ea5b62b44dad3e6755 100644 (file)
@@ -1,4 +1,11 @@
-static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+#include <util/delay.h>
+#include "action_layer.h"
+#include "action_util.h"
+#include "bootloader.h"
+#include "keymap_common.h"
+
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     /*
      * Keymap: Default Layer in QWERTY
      *
@@ -378,7 +385,7 @@ enum macro_id {
 /*
  * Fn action definition
  */
-static const uint16_t PROGMEM fn_actions[] = {
+const uint16_t PROGMEM fn_actions[] = {
     [0] =   ACTION_FUNCTION(TEENSY_KEY),                    // FN0  - Teensy key
 
     [1] =   ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),             // FN1  = Shifted BackSlash // " in Workman
@@ -425,7 +432,7 @@ static const uint16_t PROGMEM fn_actions[] = {
     [27] =  ACTION_LAYER_TAP_KEY(9, KC_V),                  // FN27 = momentary Layer9 on V key, to use with application-specific shortcuts
 };
 
-static const uint16_t PROGMEM fn_actions_4[] = {
+const uint16_t PROGMEM fn_actions_4[] = {
     [1]  =  ACTION_MODS_KEY(MOD_LSFT, KC_BSLS),             // FN1  = Shifted BackSlash // " in Workman
     [2]  =  ACTION_MODS_KEY(MOD_LSFT, KC_MINS),             // FN2  = Shifted Minus     // \ in Workman
     [3]  =  ACTION_MODS_KEY(MOD_LSFT, KC_COMM),             // FN3  = Shifted comma     // < in Workman
@@ -433,14 +440,14 @@ static const uint16_t PROGMEM fn_actions_4[] = {
     [5]  =  ACTION_MODS_KEY(MOD_LSFT, KC_SLSH),             // FN5  = Shifted slash     // ? in Workman
 };
 
-static const uint16_t PROGMEM fn_actions_7[] = {
+const uint16_t PROGMEM fn_actions_7[] = {
     [0]  =  ACTION_MACRO(XMONAD_RESET),                     // FN0  = xmonad-reanimator
     [1]  =  ACTION_MACRO(PASSWORD1),                        // FN1  = default password
     [2]  =  ACTION_MACRO(PASSWORD1),                        // FN2  = other password
     [3]  =  ACTION_MACRO(PASSWORD1),                        // FN3  = mega password
 };
 
-static const uint16_t PROGMEM fn_actions_9[] = {
+const uint16_t PROGMEM fn_actions_9[] = {
     [0]  =  ACTION_MODS_KEY(MOD_LCTL,          KC_P0),      // FN0  = Ctrl+0
     [1]  =  ACTION_MODS_KEY(MOD_LALT,          KC_P1),      // FN1  = Alt+1
     [2]  =  ACTION_MODS_KEY(MOD_LALT,          KC_P2),      // FN2  = Alt+2
diff --git a/keyboard/ergodox/keymap_dvorak.h b/keyboard/ergodox/keymap_dvorak.h
deleted file mode 100644 (file)
index 198709c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#error Dvorak layout is not defined yet
-static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-};
-static const uint16_t PROGMEM fn_actions[] = {};
similarity index 98%
rename from keyboard/ergodox/keymap_micro.h
rename to keyboard/ergodox/keymap_micro.c
index 4e878d353d0b38749662e00ec9f36721292f86b7..809067870950b8f7bbf83020810b2cf035ad9b8f 100644 (file)
@@ -3,8 +3,12 @@
 // http://geekhack.org/index.php?topic=42231.msg1062851#msg1062851
 // https://www.massdrop.com/ext/ergodox/?referer=CTL63V&hash=9ff8ddbb75e03e517aaa39acabc81669
 //
+#include <util/delay.h>
+#include "bootloader.h"
+#include "keymap_common.h"
 
-static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
     /*
      * Keymap: Default Layer in QWERTY
      *
@@ -199,12 +203,12 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
                                            TRNS,
                                  TRNS,TRNS,TRNS,
 
-        // in Workman right hand will be:
-        //
-        //    ^ { } ( ) +
-        //    ' ! $ " ; =
-        //    # [ < > ] \
-        //
+        /* in Workman right hand will be:
+         *
+         *    ^ { } ( ) +
+         *    ' ! $ " ; =
+         *    # [ < > ] \
+         */
 
         // right hand
              TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
@@ -361,7 +365,7 @@ enum function_id {
 /*
  * Fn action definition
  */
-static const uint16_t PROGMEM fn_actions[] = {
+const uint16_t PROGMEM fn_actions[] = {
     ACTION_FUNCTION(TEENSY_KEY),                    // FN0  - Teensy key
 
     // Layer4: unconvenient keys on right hand
diff --git a/keyboard/ergodox/keymap_workman.h b/keyboard/ergodox/keymap_workman.h
deleted file mode 100644 (file)
index b157065..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-#error Workman layout is not defined yet
-static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
-};
-static const uint16_t PROGMEM fn_actions[] = {};