aboutsummaryrefslogtreecommitdiff
path: root/keyboard/hid_liber/keymap.c
diff options
context:
space:
mode:
Diffstat (limited to 'keyboard/hid_liber/keymap.c')
-rw-r--r--keyboard/hid_liber/keymap.c195
1 files changed, 195 insertions, 0 deletions
diff --git a/keyboard/hid_liber/keymap.c b/keyboard/hid_liber/keymap.c
new file mode 100644
index 000000000..e35f7245d
--- /dev/null
+++ b/keyboard/hid_liber/keymap.c
@@ -0,0 +1,195 @@
1/*
2Copyright 2011 Jun Wako <wakojun@gmail.com>
3
4This program is free software: you can redistribute it and/or modify
5it under the terms of the GNU General Public License as published by
6the Free Software Foundation, either version 2 of the License, or
7(at your option) any later version.
8
9This program is distributed in the hope that it will be useful,
10but WITHOUT ANY WARRANTY; without even the implied warranty of
11MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12GNU General Public License for more details.
13
14You should have received a copy of the GNU General Public License
15along with this program. If not, see <http://www.gnu.org/licenses/>.
16*/
17
18/*
19 * Keymap for HID Liberator controller
20 */
21#include <stdint.h>
22#include <stdbool.h>
23#include <avr/pgmspace.h>
24#include "keycode.h"
25#include "print.h"
26#include "debug.h"
27#include "util.h"
28#include "keymap.h"
29
30
31// Convert physical keyboard layout to matrix array.
32// This is a macro to define keymap easily in keyboard layout form.
33#define KEYMAP( \
34 KG1, KH7, KJ7, KJ6, KJ1, KO5, KL1, KA6, KA7, KD7, KD5, KD1, KD2, KB5, KB3, KO3, \
35 KG7, KG5, KH5, KJ5, KI5, KI7, KK7, KK5, KL5, KA5, KC5, KC7, KL7, KD6, KQ7, KN7, KM7, \
36 KG6, KG3, KH3, KJ3, KI3, KI6, KK6, KK3, KL3, KA3, KC3, KC6, KL6, KD4, KP7, KN5, KM5, \
37 KH6, KG4, KH4, KJ4, KI4, KI1, KK1, KK4, KL4, KA4, KC4, KC1, KD0, \
38 KF6, KH1, KG0, KH0, KJ0, KI0, KI2, KK2, KK0, KL0, KA0, KC2, KF4, KN1, \
39 KO7, KE6, KB1, KP1, KB2, KR4, KA2, KO0, KN2, KP2, KQ2 \
40) { \
41/* 0 1 2 3 4 5 6 7 */ \
42/* A */ { KC_##KA0, KC_NO , KC_##KA2, KC_##KA3, KC_##KA4, KC_##KA5, KC_##KA6, KC_##KA7 }, \
43/* B */ { KC_NO , KC_##KB1, KC_##KB2, KC_##KB3, KC_NO , KC_##KB5, KC_NO , KC_NO }, \
44/* C */ { KC_NO , KC_##KC1, KC_##KC2, KC_##KC3, KC_##KC4, KC_##KC5, KC_##KC6, KC_##KC7 }, \
45/* D */ { KC_##KD0, KC_##KD1, KC_##KD2, KC_NO , KC_##KD4, KC_##KD5, KC_##KD6, KC_##KD7 }, \
46/* E */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_##KE6, KC_NO }, \
47/* F */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_##KF4, KC_NO , KC_##KF6, KC_NO }, \
48/* G */ { KC_##KG0, KC_##KG1, KC_NO , KC_##KG3, KC_##KG4, KC_##KG5, KC_##KG6, KC_##KG7 }, \
49/* H */ { KC_##KH0, KC_##KH1, KC_NO , KC_##KH3, KC_##KH4, KC_##KH5, KC_##KH6, KC_##KH7 }, \
50/* I */ { KC_##KI0, KC_##KI1, KC_##KI2, KC_##KI3, KC_##KI4, KC_##KI5, KC_##KI6, KC_##KI7 }, \
51/* J */ { KC_##KJ0, KC_##KJ1, KC_NO , KC_##KJ3, KC_##KJ4, KC_##KJ5, KC_##KJ6, KC_##KJ7 }, \
52/* K */ { KC_##KK0, KC_##KK1, KC_##KK2, KC_##KK3, KC_##KK4, KC_##KK5, KC_##KK6, KC_##KK7 }, \
53/* L */ { KC_##KL0, KC_##KL1, KC_NO , KC_##KL3, KC_##KL4, KC_##KL5, KC_##KL6, KC_##KL7 }, \
54/* M */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_NO , KC_##KM5, KC_NO , KC_##KM7 }, \
55/* N */ { KC_NO , KC_##KN1, KC_##KN2, KC_NO , KC_NO , KC_##KN5, KC_NO , KC_##KN7 }, \
56/* O */ { KC_##KO0, KC_NO , KC_NO , KC_##KO3, KC_NO , KC_##KO5, KC_NO , KC_##KO7 }, \
57/* P */ { KC_NO , KC_##KP1, KC_##KP2, KC_NO , KC_NO , KC_NO , KC_NO , KC_##KP7 }, \
58/* Q */ { KC_NO , KC_NO , KC_##KQ2, KC_NO , KC_NO , KC_NO , KC_NO , KC_##KQ7 }, \
59/* R */ { KC_NO , KC_NO , KC_NO , KC_NO , KC_##KR4, KC_NO , KC_NO , KC_NO } \
60}
61
62#define KEYCODE(layer, row, col) (pgm_read_byte(&keymaps[(layer)][(row)][(col)]))
63
64
65// Assign Fn key(0-7) to a layer to which switch with the Fn key pressed.
66static const uint8_t PROGMEM fn_layer[] = {
67 0, // Fn0
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/*
91 * 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
93 * switch in the ASD row next to enter. Use NUBS as keycode for the first and
94 * NUHS as the keycode for the second.
95 *
96 * ,---. ,---------------. ,---------------. ,---------------. ,-----------.
97 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
98 * `---' `---------------' `---------------' `---------------' `-----------'
99 * ,-----------------------------------------------------------. ,-----------.
100 * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
101 * |-----------------------------------------------------------| |-----------|
102 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
103 * |-----------------------------------------------------------| `-----------'
104 * |Caps | A| S| D| F| G| H| J| K| L| ;| '|Return |
105 * |-----------------------------------------------------------| ,---.
106 * |Shft|ISO| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
107 * |-----------------------------------------------------------| ,-----------.
108 * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
109 * `-----------------------------------------------------------' `-----------'
110 */
111
112
113static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
114/* Layer 0: Default Layer
115 *
116 * ANSI:
117 *
118 * ,---. ,---------------. ,---------------. ,---------------. ,-----------.
119 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Pau|
120 * `---' `---------------' `---------------' `---------------' `-----------'
121 * ,-----------------------------------------------------------. ,-----------.
122 * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9| 0| -| =|Backsp | |Ins|Hom|PgU|
123 * |-----------------------------------------------------------| |-----------|
124 * |Tab | Q| W| E| R| T| Y| U| I| O| P| [| ]| \| |Del|End|PgD|
125 * |-----------------------------------------------------------| `-----------'
126 * |FN1 | A| S| D| F| G| H| J| K| L| ;| '|Return |
127 * |-----------------------------------------------------------| ,---.
128 * |Shft|iso| Z| X| C| V| B| N| M| ,| .| /|Shift | |Up |
129 * |-----------------------------------------------------------| ,-----------.
130 * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
131 * `-----------------------------------------------------------' `-----------'
132 */
133
134 KEYMAP(\
135 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \
136 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \
137 TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, BSLS, DEL, END, PGDN, \
138 FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \
139 LSFT, NUBS, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, \
140 LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
141
142/* EXAMPLE ISO keymap, see the NUBS and NUHS keycodes
143 * KEYMAP(\
144 * ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, BRK, \
145 * GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, MINS, EQL, BSPC, INS, HOME, PGUP, \
146 * TAB, Q, W, E, R, T, Y, U, I, O, P, LBRC, RBRC, NUHS, DEL, END, PGDN, \
147 * CAPS, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \
148 * LSFT, NUBS, Z, X, C, V, B, N, M, COMM, DOT, SLSH, RSFT, UP, \
149 * LCTL, FN1, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
150 */
151
152
153/*
154 * ,---. ,---------------. ,---------------. ,---------------. ,-----------.
155 * |Esc| |F1 |F2 |F3 |F4 | |F5 |F6 |F7 |F8 | |F9 |F10|F11|F12| |PrS|ScL|Slp|
156 * `---' `---------------' `---------------' `---------------' `-----------'
157 * ,-----------------------------------------------------------. ,-----------.
158 * |~ | 1| 2| 3| 4| 5| 6| 7| 8| 9|Mut|V- |V+ |Backsp | |Ins|Hom|PgU|
159 * |-----------------------------------------------------------| |-----------|
160 * |Tab | Q| W| E| R| T| Y| U| I|MSt|Ply|Prv|Nxt|Media| |Del|End|PgD|
161 * |-----------------------------------------------------------| `-----------'
162 * |FN1 | A| S| D| F| G| H| J| K| L| ;| '|Return |
163 * |-----------------------------------------------------------| ,---.
164 * |Shft|iso| Z| X|Clc| V| B| N| M| ,| .| /|Caps | |Up |
165 * |-----------------------------------------------------------| ,-----------.
166 * |Ctl|Gui|Alt| Space |Alt|Gui|App|Ctl| |Lef|Dow|Rig|
167 * `-----------------------------------------------------------' `-----------'
168 */
169
170 KEYMAP(\
171 ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, PSCR, SLCK, SLEP, \
172 GRV, 1, 2, 3, 4, 5, 6, 7, 8, 9,MUTE, VOLD, VOLU, BSPC, INS, HOME, PGUP, \
173 TAB, Q, W, E, R, T, Y, U, I,MSTP,MPLY, MPRV, MNXT, MSEL, DEL, END, PGDN, \
174 FN1, A, S, D, F, G, H, J, K, L, SCLN, QUOT, ENT, \
175 LSFT, NUBS, Z, X,CALC, V, B, N, M, COMM, DOT, SLSH, CAPS, UP, \
176 LCTL, LGUI, LALT, SPC, RALT, RGUI, APP, RCTL, LEFT, DOWN, RGHT),
177
178
179};
180
181
182uint8_t keymap_get_keycode(uint8_t layer, uint8_t row, uint8_t col)
183{
184 return KEYCODE(layer, row, col);
185}
186
187uint8_t keymap_fn_layer(uint8_t index)
188{
189 return pgm_read_byte(&fn_layer[index]);
190}
191
192uint8_t keymap_fn_keycode(uint8_t index)
193{
194 return pgm_read_byte(&fn_keycode[index]);
195}