aboutsummaryrefslogtreecommitdiff
path: root/keyboard/phantom/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard/phantom/keymap.c')
-rw-r--r--keyboard/phantom/keymap.c72
1 files changed, 31 insertions, 41 deletions
diff --git a/keyboard/phantom/keymap.c b/keyboard/phantom/keymap.c
index 0a95f9fbb..1a9edd3ea 100644
--- a/keyboard/phantom/keymap.c
+++ b/keyboard/phantom/keymap.c
@@ -22,9 +22,12 @@ 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 "report.h"
28#include "host.h"
25#include "print.h" 29#include "print.h"
26#include "debug.h" 30#include "debug.h"
27#include "util.h"
28#include "keymap.h" 31#include "keymap.h"
29 32
30 33
@@ -47,34 +50,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
47/* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_##K5L, KC_##K5M, KC_##K5N, KC_##K5O, KC_##K5P, KC_##K5Q}, \ 50/* 5 */ { KC_##K5A, KC_##K5B, KC_##K5C, KC_##K5D, KC_##K5E, KC_##K5F, KC_##K5G, KC_##K5H, KC_##K5I, KC_##K5J, KC_##K5K, KC_##K5L, KC_##K5M, KC_##K5N, KC_##K5O, KC_##K5P, KC_##K5Q}, \
48} 51}
49 52
50#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
51
52
53// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
54static const uint8_t PROGMEM fn_layer[] = {
55 0, // Fn0
56 1, // Fn1
57 2, // Fn2
58 3, // Fn3
59 4, // Fn4
60 5, // Fn5
61 6, // Fn6
62 7 // Fn7
63};
64
65// Assign Fn key(0-7) to a keycode sent when release Fn key without use of the layer.
66// See layer.c for details.
67static const uint8_t PROGMEM fn_keycode[] = {
68 KC_NO, // Fn0
69 KC_NO, // Fn1
70 KC_NO, // Fn2
71 KC_NO, // Fn3
72 KC_NO, // Fn4
73 KC_NO, // Fn5
74 KC_NO, // Fn6
75 KC_NO // Fn7
76};
77
78/* 53/*
79 * Phantom keyboard layout with winkeys and 7bit style editing block. I am 54 * Phantom keyboard layout with winkeys and 7bit style editing block. I am
80 * Not in the mood to implement full 7-bit keymap. 55 * Not in the mood to implement full 7-bit keymap.
@@ -122,7 +97,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
122 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \ 97 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \
123 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \ 98 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \
124 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \ 99 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \
125 FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \ 100 FN0, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \
126 LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, 0, UP, 0, \ 101 LSFT, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, 0, UP, 0, \
127 LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT), 102 LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
128 103
@@ -148,25 +123,40 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
148 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, SLEP, \ 123 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, SLEP, \
149 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9,MUTE, VOLD, VOLU, BSPC, INS, HOME, PGUP, \ 124 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9,MUTE, VOLD, VOLU, BSPC, INS, HOME, PGUP, \
150 TAB, Q, W, E, R, T, Y, U, I,MSTP,MPLY, MPRV, MNXT, MSEL, DEL, END, PGDN, \ 125 TAB, Q, W, E, R, T, Y, U, I,MSTP,MPLY, MPRV, MNXT, MSEL, DEL, END, PGDN, \
151 FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \ 126 FN0, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, 0, 0, 0, \
152 LSFT, Z, X,CALC, V, B, N, M, COMM, DOT, SLSH, CAPS, 0, UP, 0, \ 127 LSFT, Z, X,CALC, V, B, N, M, COMM, DOT, SLSH, CAPS, 0, UP, 0, \
153 LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT), 128 LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
154
155
156}; 129};
157 130
131/*
132 * Fn action definition
133 */
134static const uint16_t PROGMEM fn_actions[] = {
135 [0] = ACTION_LAYER_MOMENTARY(1)
136};
158 137
159uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col) 138#define KEYMAPS_SIZE (sizeof(keymaps) / sizeof(keymaps[0]))
160{ 139#define FN_ACTIONS_SIZE (sizeof(fn_actions) / sizeof(fn_actions[0]))
161 return KEYCODE(layer, row, col);
162}
163 140
164uint8_t keymap_fn_layer(uint8_t index) 141/* translates key to keycode */
142uint8_t keymap_key_to_keycode(uint8_t layer, key_t key)
165{ 143{
166 return pgm_read_byte(&fn_layer[index]); 144 if (layer < KEYMAPS_SIZE) {
145 return pgm_read_byte(&keymaps[(layer)][(key.row)][(key.col)]);
146 } else {
147 // fall back to layer 0
148 return pgm_read_byte(&keymaps[0][(key.row)][(key.col)]);
149 }
167} 150}
168 151
169uint8_t keymap_fn_keycode(uint8_t index) 152/* translates Fn keycode to action */
153action_t keymap_fn_to_action(uint8_t keycode)
170{ 154{
171 return pgm_read_byte(&fn_keycode[index]); 155 action_t action;
156 if (FN_INDEX(keycode) < FN_ACTIONS_SIZE) {
157 action.code = pgm_read_word(&fn_actions[FN_INDEX(keycode)]);
158 } else {
159 action.code = ACTION_NO;
160 }
161 return action;
172} 162}