diff options
| author | tmk <nobody@nowhere> | 2013-03-25 00:04:54 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-03-25 00:04:54 +0900 |
| commit | 1f19176867b1b1f760c0ec41cd78fbb6832d29ad (patch) | |
| tree | 0569b9df79b2859aaed73e1373be670d710ed982 /keyboard/hid_liber/keymap.c | |
| parent | 2b08a150a41e25e87362436b7307bb1be35529f3 (diff) | |
| parent | b862b4f030b447e067d307a548ed92182515404e (diff) | |
| download | qmk_firmware-1f19176867b1b1f760c0ec41cd78fbb6832d29ad.tar.gz qmk_firmware-1f19176867b1b1f760c0ec41cd78fbb6832d29ad.zip | |
Merge branch 'yeeeargh-patch'
Diffstat (limited to 'keyboard/hid_liber/keymap.c')
| -rw-r--r-- | keyboard/hid_liber/keymap.c | 101 |
1 files changed, 64 insertions, 37 deletions
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) |
| 66 | static 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. | ||
| 79 | static 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 | ||
| 163 | static const uint8_t PROGMEM overlays[][MATRIX_ROWS][MATRIX_COLS] = {}; | ||
| 181 | 164 | ||
| 182 | uint8_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 | } | 168 | static 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 | ||
| 187 | uint8_t keymap_fn_layer(uint8_t index) | 185 | /* translates key to keycode */ |
| 186 | uint8_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 | ||
| 192 | uint8_t keymap_fn_keycode(uint8_t index) | 212 | /* translates Fn keycode to action */ |
| 213 | action_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 | } |
