aboutsummaryrefslogtreecommitdiff
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 2d560b9a6..498f17ed7 100644
--- a/keyboard/hid_liber/Makefile.lufa
+++ b/keyboard/hid_liber/Makefile.lufa
@@ -93,15 +93,8 @@ ARCH = AVR8
93# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU. 93# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
94F_USB = $(F_CPU) 94F_USB = $(F_CPU)
95 95
96 96# Interrupt driven control endpoint task(+60)
97# Build Options 97#OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT
98# comment out to disable the options.
99#
100#MOUSEKEY_ENABLE = yes # Mouse keys
101EXTRAKEY_ENABLE = yes # Audio control and System control
102CONSOLE_ENABLE = yes # Console for debug
103#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
104#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
105 98
106 99
107# Boot Section Size in bytes 100# Boot Section Size in bytes
@@ -111,6 +104,19 @@ CONSOLE_ENABLE = yes # Console for debug
111OPT_DEFS += -DBOOT_SIZE=4096 104OPT_DEFS += -DBOOT_SIZE=4096
112 105
113 106
107# Build Options
108# comment out to disable the options.
109#
110BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
111#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
112EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
113CONSOLE_ENABLE = yes # Console for debug(+400)
114COMMAND_ENABLE = yes # Commands for debug and configuration
115#SLEEP_LED_ENABLE = yes # Breathing sleep LED during USB suspend
116#NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
117#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
118
119
114# Search Path 120# Search Path
115VPATH += $(TARGET_DIR) 121VPATH += $(TARGET_DIR)
116VPATH += $(TOP_DIR) 122VPATH += $(TOP_DIR)
@@ -118,3 +124,6 @@ VPATH += $(TOP_DIR)
118include $(TOP_DIR)/protocol/lufa.mk 124include $(TOP_DIR)/protocol/lufa.mk
119include $(TOP_DIR)/common.mk 125include $(TOP_DIR)/common.mk
120include $(TOP_DIR)/rules.mk 126include $(TOP_DIR)/rules.mk
127
128custom: OPT_DEFS += -DKEYMAP_CUSTOM
129custom: all
diff --git a/keyboard/hid_liber/Makefile.pjrc b/keyboard/hid_liber/Makefile.pjrc
index 8e349c8da..70ad47f29 100644
--- a/keyboard/hid_liber/Makefile.pjrc
+++ b/keyboard/hid_liber/Makefile.pjrc
@@ -71,14 +71,23 @@ MCU = atmega32u4 # Teensy 2.0
71F_CPU = 16000000 71F_CPU = 16000000
72 72
73 73
74# Boot Section Size in bytes
75# Teensy halfKay 512
76# Atmel DFU loader 4096
77# LUFA bootloader 4096
78OPT_DEFS += -DBOOT_SIZE=4096
79
80
74# Build Options 81# Build Options
75# comment out to disable the options. 82# comment out to disable the options.
76# 83#
77#MOUSEKEY_ENABLE = yes # Mouse keys 84BOOTMAGIC_ENABLE = yes # Virtual DIP switch configuration(+1000)
78#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support 85#MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
79EXTRAKEY_ENABLE = yes # Audio control and System control 86EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
80NKRO_ENABLE = yes # USB Nkey Rollover 87CONSOLE_ENABLE = yes # Console for debug(+400)
81CONSOLE_ENABLE = yes # Console for debug 88COMMAND_ENABLE = yes # Commands for debug and configuration
89NKRO_ENABLE = yes # USB Nkey Rollover - not yet supported in LUFA
90#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
82 91
83 92
84# Search Path 93# Search Path
@@ -88,3 +97,6 @@ VPATH += $(TOP_DIR)
88include $(TOP_DIR)/protocol/pjrc.mk 97include $(TOP_DIR)/protocol/pjrc.mk
89include $(TOP_DIR)/common.mk 98include $(TOP_DIR)/common.mk
90include $(TOP_DIR)/rules.mk 99include $(TOP_DIR)/rules.mk
100
101custom: OPT_DEFS += -DKEYMAP_CUSTOM
102custom: all
diff --git a/keyboard/hid_liber/config.h b/keyboard/hid_liber/config.h
index 61a75dd0c..17fc2ed89 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/>.
41/* Set 0 if need no debouncing */ 41/* Set 0 if need no debouncing */
42#define DEBOUNCE 8 42#define DEBOUNCE 8
43 43
44/* legacy keymap support */
45#define USE_LEGACY_KEYMAP
46
47/* key combination for command */ 44/* key combination for command */
48#define IS_COMMAND() ( \ 45#define IS_COMMAND() ( \
49 keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ 46 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 e35f7245d..f3d6bfa2e 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/>.
22#include <stdbool.h> 22#include <stdbool.h>
23#include <avr/pgmspace.h> 23#include <avr/pgmspace.h>
24#include "keycode.h" 24#include "keycode.h"
25#include "action.h"
26#include "action_macro.h"
27#include "layer_switch.h"
28#include "report.h"
29#include "host.h"
25#include "print.h" 30#include "print.h"
26#include "debug.h" 31#include "debug.h"
27#include "util.h"
28#include "keymap.h" 32#include "keymap.h"
29 33
30 34
@@ -59,34 +63,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
59/* R */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_##KR4, KC_NO , KC_NO , KC_NO } \ 63/* R */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_##KR4, KC_NO , KC_NO , KC_NO } \
60} 64}
61 65
62#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)])) 66/*
63 67 * Add custom layouts. If no custom layout is defined the default layout is used.
64 68*/
65// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed. 69#if defined(KEYMAP_CUSTOM)
66static const uint8_t PROGMEM fn_layer[] = { 70 #include "keymap_custom.h"
67 0, // Fn0 71#else
68 1, // Fn1
69 2, // Fn2
70 3, // Fn3
71 4, // Fn4
72 5, // Fn5
73 6, // Fn6
74 7 // Fn7
75};
76
77// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
78// See layer.c for details.
79static const uint8_t PROGMEM fn_keycode[] = {
80 KC_NO, // Fn0
81 KC_NO, // Fn1
82 KC_NO, // Fn2
83 KC_NO, // Fn3
84 KC_NO, // Fn4
85 KC_NO, // Fn5
86 KC_NO, // Fn6
87 KC_NO // Fn7
88};
89
90/* 72/*
91 * Tenkeyless keyboard default layout, ISO & ANSI (ISO is between Left Shift 73 * Tenkeyless keyboard default layout, ISO & ANSI (ISO is between Left Shift
92 * and Z, and the ANSI \ key above Return/Enter is used for the additional ISO 74 * 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] = {
178 160
179}; 161};
180 162
163static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {};
181 164
182uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) 165/*
183{ 166 * Fn action definition
184 return KEYCODE(layer, row, col); 167 */
185} 168static const uint16_t PROGMEM fn_actions[] = {
169 [0] = ACTION_DEFAULT_LAYER_SET(0),
170 [1] = ACTION_DEFAULT_LAYER_SET(1),
171 [2] = ACTION_DEFAULT_LAYER_SET(2),
172 [3] = ACTION_DEFAULT_LAYER_SET(3),
173 [4] = ACTION_DEFAULT_LAYER_SET(4),
174 [5] = ACTION_DEFAULT_LAYER_SET(5),
175 [6] = ACTION_DEFAULT_LAYER_SET(6),
176 [7] = ACTION_DEFAULT_LAYER_SET(7),
177 [8] = ACTION_DEFAULT_LAYER_SET(8),
178};
179#endif
180
181#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
182#define OVERLAYS_SIZE (sizeof(overlays) / sizeof(overlays[0]))
183#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
186 184
187uint8_t keymap_fn_layer(uint8_t index) 185/* translates key to keycode */
186uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
188{ 187{
189 return pgm_read_byte(&fn_layer[index]); 188 /* Overlay: 16-31(OVERLAY_BIT(0x10) | overlay_layer) */
189 if (layer & OVERLAY_BIT) {
190 layer &= OVERLAY_MASK;
191 if (layer < OVERLAYS_SIZE) {
192 return pgm_read_byte(&overlays[(layer)][(key.row)][(key.col)]);
193 } else {
194 // XXX: this may cuaes bootlaoder_jump incositent fail.
195 //debug("key_to_keycode: overlay "); debug_dec(layer); debug(" is invalid.\n");
196 return KC_TRANSPARENT;
197 }
198 }
199 /* Keymap: 0-15 */
200 else {
201 if (layer < KEYMAPS_SIZE) {
202 return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
203 } else {
204 // XXX: this may cuaes bootlaoder_jump incositent fail.
205 //debug("key_to_keycode: base "); debug_dec(layer); debug(" is invalid.\n");
206 // fall back to layer 0
207 return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
208 }
209 }
190} 210}
191 211
192uint8_t keymap_fn_keycode(uint8_t index) 212/* translates Fn keycode to action */
213action_t keymap_fn_to_action(uint8_t keycode)
193{ 214{
194 return pgm_read_byte(&fn_keycode[index]); 215 action_t action;
216 if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
217 action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
218 } else {
219 action.code = ACTION_NO;
220 }
221 return action;
195} 222}
diff --git a/keyboard/hid_liber/keymap_custom.h b/keyboard/hid_liber/keymap_custom.h
new file mode 100644
index 000000000..d138ab20e
--- /dev/null
+++ b/keyboard/hid_liber/keymap_custom.h
@@ -0,0 +1,65 @@
1static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
2/* Layer 0: Default Layer
3 *
4 * ANSI:
5 *
6 * ,---. ,---------------. ,---------------. ,---------------. ,-----------.
7 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
8 * `---' `---------------' `---------------' `---------------' `-----------'
9 * ,-----------------------------------------------------------. ,-----------.
10 * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
11 * |-----------------------------------------------------------| |-----------|
12 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
13 * |-----------------------------------------------------------| `-----------'
14 * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
15 * |-----------------------------------------------------------| ,---.
16 * |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
17 * |-----------------------------------------------------------| ,-----------.
18 * |Ctl|Gui|Alt| Space |Alt|Gui|FN0|Ctl| |Lef|Dow|Rig|
19 * `-----------------------------------------------------------' `-----------'
20 */
21
22 KEYMAP(
23 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \
24 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \
25 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \
26 CAPS, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \
27 LSFT, NUBS, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, \
28 LCTL, LGUI, LALT, SPC, RALT, RGUI, FN0, RCTL, LEFT, DOWN, RGHT),
29
30
31
32};
33
34static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {
35/*
36 * Layer 1: Media Keys
37 *
38 * ,---. ,---------------. ,---------------. ,---------------. ,-----------.
39 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
40 * `---' `---------------' `---------------' `---------------' `-----------'
41 * ,-----------------------------------------------------------. ,-----------.
42 * |~ |KP1|KP2|KP3|KP4|KP5|KP6|KP7|KP8|KP9|KP0| -| =|Backsp | |Ins|Med|Vl+|
43 * |-----------------------------------------------------------| |-----------|
44 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|Mut|Vl-|
45 * |-----------------------------------------------------------| `-----------'
46 * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
47 * |-----------------------------------------------------------| ,---.
48 * |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Ply|
49 * |-----------------------------------------------------------| ,-----------.
50 * |Ctl|Gui|Alt| Space |Alt|Gui|FN0|Ctl| |Prv|Stp|Nxt|
51 * `-----------------------------------------------------------' `-----------'
52 */
53
54 KEYMAP(
55 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
56 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MSEL, VOLU, \
57 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MUTE, VOLD, \
58 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, \
59 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, MPLY, \
60 TRNS, TRNS, TRNS, TRNS, TRNS, TRNS, FN0, TRNS, MPRV, MSTP, MNXT),
61};
62
63static const uint16_t PROGMEM fn_actions[] = {
64 [0] = ACTION_OVERLAY_MOMENTARY(0), // activate LAYER1 when FN0 pressed
65};