aboutsummaryrefslogtreecommitdiff
path: root/quantum/keymap_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'quantum/keymap_common.h')
-rw-r--r--quantum/keymap_common.h292
1 files changed, 0 insertions, 292 deletions
diff --git a/quantum/keymap_common.h b/quantum/keymap_common.h
deleted file mode 100644
index c72c0bc29..000000000
--- a/quantum/keymap_common.h
+++ /dev/null
@@ -1,292 +0,0 @@
1/*
2Copyright 2012,2013 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#ifndef KEYMAP_H
19#define KEYMAP_H
20
21#include <stdint.h>
22#include <stdbool.h>
23#include "action.h"
24#include <avr/pgmspace.h>
25#include "keycode.h"
26#include "keymap.h"
27#include "action_macro.h"
28#include "report.h"
29#include "host.h"
30// #include "print.h"
31#include "debug.h"
32
33/* NOTE: Not portable. Bit field order depends on implementation */
34typedef union {
35 uint16_t raw;
36 struct {
37 bool swap_control_capslock:1;
38 bool capslock_to_control:1;
39 bool swap_lalt_lgui:1;
40 bool swap_ralt_rgui:1;
41 bool no_gui:1;
42 bool swap_grave_esc:1;
43 bool swap_backslash_backspace:1;
44 bool nkro:1;
45 };
46} keymap_config_t;
47
48
49/* translates key to keycode */
50uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
51
52/* translates Fn keycode to action */
53action_t keymap_fn_to_action(uint16_t keycode);
54
55/* translates Fn keycode to action */
56action_t keymap_func_to_action(uint16_t keycode);
57
58extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
59extern const uint16_t fn_actions[];
60
61// Ability to use mods in layouts
62#define LCTL(kc) kc | 0x0100
63#define LSFT(kc) kc | 0x0200
64#define LALT(kc) kc | 0x0400
65#define LGUI(kc) kc | 0x0800
66#define HYPR(kc) kc | 0x0F00
67#define MEH(kc) kc | 0x0700
68#define LCAG(kc) kc | 0x0D00 // Modifier Ctrl Alt and GUI
69
70#define MOD_HYPR 0xf
71#define MOD_MEH 0x7
72
73#define RCTL(kc) kc | 0x1100
74#define RSFT(kc) kc | 0x1200
75#define RALT(kc) kc | 0x1400
76#define RGUI(kc) kc | 0x1800
77
78// Aliases for shifted symbols
79// Each key has a 4-letter code, and some have longer aliases too.
80// While the long aliases are descriptive, the 4-letter codes
81// make for nicer grid layouts (everything lines up), and are
82// the preferred style for Quantum.
83#define KC_TILD LSFT(KC_GRV) // ~
84#define KC_TILDE KC_TILD
85
86#define KC_EXLM LSFT(KC_1) // !
87#define KC_EXCLAIM KC_EXLM
88
89#define KC_AT LSFT(KC_2) // @
90
91#define KC_HASH LSFT(KC_3) // #
92
93#define KC_DLR LSFT(KC_4) // $
94#define KC_DOLLAR KC_DLR
95
96#define KC_PERC LSFT(KC_5) // %
97#define KC_PERCENT KC_PERC
98
99#define KC_CIRC LSFT(KC_6) // ^
100#define KC_CIRCUMFLEX KC_CIRC
101
102#define KC_AMPR LSFT(KC_7) // &
103#define KC_AMPERSAND KC_AMPR
104
105#define KC_ASTR LSFT(KC_8) // *
106#define KC_ASTERISK KC_ASTR
107
108#define KC_LPRN LSFT(KC_9) // (
109#define KC_LEFT_PAREN KC_LPRN
110
111#define KC_RPRN LSFT(KC_0) // )
112#define KC_RIGHT_PAREN KC_RPRN
113
114#define KC_UNDS LSFT(KC_MINS) // _
115#define KC_UNDERSCORE KC_UNDS
116
117#define KC_PLUS LSFT(KC_EQL) // +
118
119#define KC_LCBR LSFT(KC_LBRC) // {
120#define KC_LEFT_CURLY_BRACE KC_LCBR
121
122#define KC_RCBR LSFT(KC_RBRC) // }
123#define KC_RIGHT_CURLY_BRACE KC_RCBR
124
125#define KC_LABK LSFT(KC_COMM) // <
126#define KC_LEFT_ANGLE_BRACKET KC_LABK
127
128#define KC_RABK LSFT(KC_DOT) // >
129#define KC_RIGHT_ANGLE_BRACKET KC_RABK
130
131#define KC_COLN LSFT(KC_SCLN) // :
132#define KC_COLON KC_COLN
133
134#define KC_PIPE LSFT(KC_BSLS) // |
135
136#define KC_LT LSFT(KC_COMM) // <
137
138#define KC_GT LSFT(KC_DOT) // >
139
140#define KC_QUES LSFT(KC_SLSH) // ?
141#define KC_QUESTION KC_QUES
142
143#define KC_DQT LSFT(KC_QUOT) // "
144#define KC_DOUBLE_QUOTE KC_DQT
145#define KC_DQUO KC_DQT
146
147#define KC_DELT KC_DELETE // Del key (four letter code)
148
149// Alias for function layers than expand past FN31
150#define FUNC(kc) kc | 0x2000
151
152// Aliases
153#define S(kc) LSFT(kc)
154#define F(kc) FUNC(kc)
155
156#define M(kc) (kc | 0x3000)
157
158#define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
159
160// 0x3100+ is free
161
162// L-ayer, T-ap - 256 keycode max, 16 layer max
163#define LT(layer, kc) (kc | 0x4000 | ((layer & 0xF) << 8))
164
165#define RESET 0x5000
166#define DEBUG 0x5001
167
168// MAGIC keycodes
169#define MAGIC_SWAP_CONTROL_CAPSLOCK 0x5002
170#define MAGIC_UNSWAP_CONTROL_CAPSLOCK 0x5003
171#define MAGIC_CAPSLOCK_TO_CONTROL 0x5004
172#define MAGIC_UNCAPSLOCK_TO_CONTROL 0x5005
173#define MAGIC_SWAP_LALT_LGUI 0x5006
174#define MAGIC_UNSWAP_LALT_LGUI 0x5007
175#define MAGIC_SWAP_RALT_RGUI 0x5008
176#define MAGIC_UNSWAP_RALT_RGUI 0x5009
177#define MAGIC_NO_GUI 0x500a
178#define MAGIC_UNNO_GUI 0x500b
179#define MAGIC_SWAP_GRAVE_ESC 0x500c
180#define MAGIC_UNSWAP_GRAVE_ESC 0x500d
181#define MAGIC_SWAP_BACKSLASH_BACKSPACE 0x500e
182#define MAGIC_UNSWAP_BACKSLASH_BACKSPACE 0x500f
183#define MAGIC_HOST_NKRO 0x5010
184#define MAGIC_UNHOST_NKRO 0x5011
185#define MAGIC_SWAP_ALT_GUI 0x5012
186#define MAGIC_UNSWAP_ALT_GUI 0x5013
187
188#define AG_SWAP MAGIC_SWAP_ALT_GUI
189#define AG_NORM MAGIC_UNSWAP_ALT_GUI
190
191#define KC_LEAD 0x5014
192
193// Audio on/off
194#define AU_ON 0x5020
195#define AU_OFF 0x5021
196#define AU_TOG 0x5022
197
198// Music mode on/off
199#define MU_ON 0x5023
200#define MU_OFF 0x5024
201#define MU_TOG 0x5025
202
203// Music voice iterate
204#define MUV_IN 0x5026
205#define MUV_DE 0x5027
206
207// Midi mode on/off
208#define MI_ON 0x5028
209#define MI_OFF 0x5029
210
211// These affect the backlight (if your keyboard has one).
212// We don't need to comment them out if your keyboard doesn't have a backlight,
213// since they don't take up any space.
214#define BL_ON 0x5079
215#define BL_OFF 0x5070
216#define BL_0 0x5070
217#define BL_1 0x5071
218#define BL_2 0x5072
219#define BL_3 0x5073
220#define BL_4 0x5074
221#define BL_5 0x5075
222#define BL_6 0x5076
223#define BL_7 0x5077
224#define BL_8 0x5078
225#define BL_9 0x5079
226#define BL_10 0x507A
227#define BL_11 0x507B
228#define BL_12 0x507C
229#define BL_13 0x507D
230#define BL_14 0x507E
231#define BL_15 0x507F
232#define BL_DEC 0x5080
233#define BL_INC 0x5081
234#define BL_TOGG 0x5082
235#define BL_STEP 0x5083
236
237#define KC_LSPO 0x5084 // Left shift, open parens when tapped
238#define KC_RSPC 0x5085 // Right shift, close parens when tapped
239// GOTO layer - 16 layers max
240// when:
241// ON_PRESS = 1
242// ON_RELEASE = 2
243// Unless you have a good reason not to do so, prefer ON_PRESS (1) as your default.
244#define TO(layer, when) (layer | 0x5100 | (when << 0x4))
245
246// Momentary switch layer - 256 layer max
247#define MO(layer) (layer | 0x5200)
248
249// Set default layer - 256 layer max
250#define DF(layer) (layer | 0x5300)
251
252// Toggle to layer - 256 layer max
253#define TG(layer) (layer | 0x5400)
254
255// One-shot layer - 256 layer max
256#define OSL(layer) (layer | 0x5500)
257
258// One-shot mod
259#define OSM(layer) (layer | 0x5600)
260
261// chording is currently at 0x57xx
262
263// M-od, T-ap - 256 keycode max
264#define MT(mod, kc) (kc | 0x7000 | ((mod & 0xF) << 8))
265#define CTL_T(kc) MT(0x1, kc)
266#define SFT_T(kc) MT(0x2, kc)
267#define ALT_T(kc) MT(0x4, kc)
268#define GUI_T(kc) MT(0x8, kc)
269#define C_S_T(kc) MT(0x3, kc) // Control + Shift e.g. for gnome-terminal
270#define MEH_T(kc) MT(0x7, kc) // Meh is a less hyper version of the Hyper key -- doesn't include Win or Cmd, so just alt+shift+ctrl
271#define LCAG_T(kc) MT(0xD, kc) // Left control alt and gui
272#define ALL_T(kc) MT(0xF, kc) // see http://brettterpstra.com/2012/12/08/a-useful-caps-lock-key/
273
274// Dedicated keycode versions for Hyper and Meh, if you want to use them as standalone keys rather than mod-tap
275#define KC_HYPR HYPR(KC_NO)
276#define KC_MEH MEH(KC_NO)
277
278#ifdef UNICODE_ENABLE
279 // For sending unicode codes.
280 // You may not send codes over 7FFF -- this supports most of UTF8.
281 // To have a key that sends out Œ, go UC(0x0152)
282 #define UNICODE(n) (n | 0x8000)
283 #define UC(n) UNICODE(n)
284#endif
285
286// For tri-layer
287void update_tri_layer(uint8_t layer1, uint8_t layer2, uint8_t layer3);
288#define IS_LAYER_ON(layer) (layer_state & (1UL << (layer)))
289#define IS_LAYER_OFF(layer) (~layer_state & (1UL << (layer)))
290
291
292#endif