summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboard/hid_liber/Makefile.lufa27
-rw-r--r--keyboard/hid_liber/Makefile.pjrc22
-rw-r--r--keyboard/hid_liber/config.h3
-rw-r--r--keyboard/hid_liber/keymap.c101
-rw-r--r--keyboard/hid_liber/keymap_custom.h65
5 files changed, 164 insertions, 54 deletions
diff --git a/keyboard/hid_liber/Makefile.lufa b/keyboard/hid_liber/Makefile.lufa
index 2d560b9a66..498f17ed78 100644
--- a/keyboard/hid_liber/Makefile.lufa
+++ b/keyboard/hid_liber/Makefile.lufa
@@ -93,15 +93,8 @@ ARCH = AVR8
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_USB = $(F_CPU)
-
-# Build Options
-# comment out to disable the options.
-#
-#MOUSEKEY_ENABLE = yes # Mouse keys
-EXTRAKEY_ENABLE = yes # Audio control and System control
-CONSOLE_ENABLE = yes # Console for debug
-#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
-#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
+# Interrupt driven control endpoint task(+60)
+#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
# Boot Section Size in bytes
@@ -111,6 +104,19 @@ CONSOLE_ENABLE = yes # Console for debug
OPT_DEFS += -DBOOT_SIZE=4096
+# Build Options
+# comment out to disable the options.
+#
+BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
+#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
+CONSOLE_ENABLE = yes # Console for debug(+400)
+COMMAND_ENABLE = yes # Commands for debug and configuration
+#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
+#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
+#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
+
+
# Search Path
VPATH += $(TARGET_DIR)
VPATH += $(TOP_DIR)
@@ -118,3 +124,6 @@ VPATH += $(TOP_DIR)
include $(TOP_DIR)/protocol/lufa.mk
include $(TOP_DIR)/common.mk
include $(TOP_DIR)/rules.mk
+
+custom: OPT_DEFS += -DKEYMAP_CUSTOM
+custom: all
diff --git a/keyboard/hid_liber/Makefile.pjrc b/keyboard/hid_liber/Makefile.pjrc
index 8e349c8da6..70ad47f29a 100644
--- a/keyboard/hid_liber/Makefile.pjrc
+++ b/keyboard/hid_liber/Makefile.pjrc
@@ -71,14 +71,23 @@ MCU = atmega32u4 # Teensy 2.0
F_CPU = 16000000
+# Boot Section Size in bytes
+# Teensy halfKay 512
+# Atmel DFU loader 4096
+# LUFA bootloader 4096
+OPT_DEFS += -DBOOT_SIZE=4096
+
+
# Build Options
# comment out to disable the options.
#
-#MOUSEKEY_ENABLE = yes # Mouse keys
-#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
-EXTRAKEY_ENABLE = yes # Audio control and System control
-NKRO_ENABLE = yes # USB Nkey Rollover
-CONSOLE_ENABLE = yes # Console for debug
+BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
+#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
+EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
+CONSOLE_ENABLE = yes # Console for debug(+400)
+COMMAND_ENABLE = yes # Commands for debug and configuration
+NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
+#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
# Search Path
@@ -88,3 +97,6 @@ VPATH += $(TOP_DIR)
include $(TOP_DIR)/protocol/pjrc.mk
include $(TOP_DIR)/common.mk
include $(TOP_DIR)/rules.mk
+
+custom: OPT_DEFS += -DKEYMAP_CUSTOM
+custom: all
diff --git a/keyboard/hid_liber/config.h b/keyboard/hid_liber/config.h
index 61a75dd0cf..17fc2ed892 100644
--- a/keyboard/hid_liber/config.h
+++ b/keyboard/hid_liber/config.h
@@ -41,9 +41,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Set 0 if need no debouncing */
#define DEBOUNCE 8
-/* legacy keymap support */
-#define USE_LEGACY_KEYMAP
-
/* key combination for command */
#define IS_COMMAND() ( \
keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \
diff --git a/keyboard/hid_liber/keymap.c b/keyboard/hid_liber/keymap.c
index e35f7245d0..f3d6bfa2ef 100644
--- a/keyboard/hid_liber/keymap.c
+++ b/keyboard/hid_liber/keymap.c
@@ -22,9 +22,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <stdbool.h>
#include <avr/pgmspace.h>
#include "keycode.h"
+#include "action.h"
+#include "action_macro.h"
+#include "layer_switch.h"
+#include "report.h"
+#include "host.h"
#include "print.h"
#include "debug.h"
-#include "util.h"
#include "keymap.h"
@@ -59,34 +63,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
/* R */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_##KR4, KC_NO , KC_NO , KC_NO } \
}
-#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
-
-
-// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
-static const uint8_t PROGMEM fn_layer[] = {
- 0, // Fn0
- 1, // Fn1
- 2, // Fn2
- 3, // Fn3
- 4, // Fn4
- 5, // Fn5
- 6, // Fn6
- 7 // Fn7
-};
-
-// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
-// See layer.c for details.
-static const uint8_t PROGMEM fn_keycode[] = {
- KC_NO, // Fn0
- KC_NO, // Fn1
- KC_NO, // Fn2
- KC_NO, // Fn3
- KC_NO, // Fn4
- KC_NO, // Fn5
- KC_NO, // Fn6
- KC_NO // Fn7
-};
-
+/*
+ * Add custom layouts. If no custom layout is defined the default layout is used.
+*/
+#if defined(KEYMAP_CUSTOM)
+ #include "keymap_custom.h"
+#else
/*
* Tenkeyless keyboard default layout, ISO & ANSI (ISO is between Left Shift
* and Z, and the ANSI \ key above Return/Enter is used for the additional ISO
@@ -178,18 +160,63 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
};
+static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {};
-uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
-{
- return KEYCODE(layer, row, col);
-}
+/*
+ * Fn action definition
+ */
+static const uint16_t PROGMEM fn_actions[] = {
+ [0] = ACTION_DEFAULT_LAYER_SET(0),
+ [1] = ACTION_DEFAULT_LAYER_SET(1),
+ [2] = ACTION_DEFAULT_LAYER_SET(2),
+ [3] = ACTION_DEFAULT_LAYER_SET(3),
+ [4] = ACTION_DEFAULT_LAYER_SET(4),
+ [5] = ACTION_DEFAULT_LAYER_SET(5),
+ [6] = ACTION_DEFAULT_LAYER_SET(6),
+ [7] = ACTION_DEFAULT_LAYER_SET(7),
+ [8] = ACTION_DEFAULT_LAYER_SET(8),
+};
+#endif
+
+#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
+#define OVERLAYS_SIZE (sizeof(overlays) / sizeof(overlays[0]))
+#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
-uint8_t keymap_fn_layer(uint8_t index)
+/* translates key to keycode */
+uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
{
- return pgm_read_byte(&fn_layer[index]);
+ /* Overlay: 16-31(OVERLAY_BIT(0x10) | overlay_layer) */
+ if (layer & OVERLAY_BIT) {
+ layer &= OVERLAY_MASK;
+ if (layer < OVERLAYS_SIZE) {
+ return pgm_read_byte(&overlays[(layer)][(key.row)][(key.col)]);
+ } else {
+ // XXX: this may cuaes bootlaoder_jump incositent fail.
+ //debug("key_to_keycode: overlay "); debug_dec(layer); debug(" is invalid.\n");
+ return KC_TRANSPARENT;
+ }
+ }
+ /* Keymap: 0-15 */
+ else {
+ if (layer < KEYMAPS_SIZE) {
+ return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
+ } else {
+ // XXX: this may cuaes bootlaoder_jump incositent fail.
+ //debug("key_to_keycode: base "); debug_dec(layer); debug(" is invalid.\n");
+ // fall back to layer 0
+ return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
+ }
+ }
}
-uint8_t keymap_fn_keycode(uint8_t index)
+/* translates Fn keycode to action */
+action_t keymap_fn_to_action(uint8_t keycode)
{
- return pgm_read_byte(&fn_keycode[index]);
+ 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;
}
diff --git a/keyboard/hid_liber/keymap_custom.h b/keyboard/hid_liber/keymap_custom.h
new file mode 100644
index 0000000000..d138ab20e9
--- /dev/null
+++ b/keyboard/hid_liber/keymap_custom.h
@@ -0,0 +1,65 @@
+static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+/* Layer 0: Default Layer
+ *
+ * ANSI:
+ *
+ * ,---. ,---------------. ,---------------. ,---------------. ,-----------.
+ * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
+ * `---' `---------------' `---------------' `---------------' `-----------'
+ * ,-----------------------------------------------------------. ,-----------.
+ * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
+ * |-----------------------------------------------------------| |-----------|
+ * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
+ * |-----------------------------------------------------------| `-----------'
+ * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
+ * |-----------------------------------------------------------| ,---.
+ * |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
+ * |-----------------------------------------------------------| ,-----------.
+ * |Ctl|Gui|Alt| Space |Alt|Gui|FN0|Ctl| |Lef|Dow|Rig|
+ * `-----------------------------------------------------------' `-----------'
+ */
+
+ KEYMAP(
+ ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \
+ GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \
+ TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \
+ CAPS, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \
+ LSFT, NUBS, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, \
+ LCTL, LGUI, LALT, SPC, RALT, RGUI, FN0, RCTL, LEFT, DOWN, RGHT),
+
+
+
+};
+
+static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {
+/*
+ * Layer 1: Media Keys
+ *
+ * ,---. ,---------------. ,---------------. ,---------------. ,-----------.
+ * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
+ * `---' `---------------' `---------------' `---------------' `-----------'
+ * ,-----------------------------------------------------------. ,-----------.
+ * |~ |KP1|KP2|KP3|KP4|KP5|KP6|KP7|KP8|KP9|KP0| -| =|Backsp | |Ins|Med|Vl+|
+ * |-----------------------------------------------------------| |-----------|
+ * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|Mut|Vl-|
+ * |-----------------------------------------------------------| `-----------'
+ * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
+ * |-----------------------------------------------------------| ,---.
+ * |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Ply|
+ * |-----------------------------------------------------------| ,-----------.
+ * |Ctl|Gui|Alt| Space |Alt|Gui|FN0|Ctl| |Prv|Stp|Nxt|
+ * `-----------------------------------------------------------' `-----------'
+ */
+
+ KEYMAP(
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MSEL, VOLU, \
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MUTE, VOLD, \
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MPLY, \
+ TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN0, TRNS, MPRV, MSTP, MNXT),
+};
+
+static const uint16_t PROGMEM fn_actions[] = {
+ [0] = ACTION_OVERLAY_MOMENTARY(0), // activate LAYER1 when FN0 pressed
+};