]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboard/preonic/extended_keymap_common.h
good enough for a preview
[qmk_firmware.git] / keyboard / preonic / extended_keymap_common.h
1 /*
2 Copyright 2012,2013 Jun Wako <wakojun@gmail.com>
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along 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 #ifdef BOOTMAGIC_ENABLE
34 /* NOTE: Not portable. Bit field order depends on implementation */
35 typedef union {
36     uint16_t raw;
37     struct {
38         bool swap_control_capslock:1;
39         bool capslock_to_control:1;
40         bool swap_lalt_lgui:1;
41         bool swap_ralt_rgui:1;
42         bool no_gui:1;
43         bool swap_grave_esc:1;
44         bool swap_backslash_backspace:1;
45         bool nkro:1;
46     };
47 } keymap_config_t;
48 keymap_config_t keymap_config;
49 #endif
50
51
52 /* translates key to keycode */
53 uint16_t keymap_key_to_keycode(uint8_t layer, keypos_t key);
54
55 /* translates Fn keycode to action */
56 action_t keymap_fn_to_action(uint16_t keycode);
57
58 /* translates Fn keycode to action */
59 action_t keymap_func_to_action(uint16_t keycode);
60
61 extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS];
62 extern const uint16_t fn_actions[];
63
64 // Ability to use mods in layouts
65 #define LCTL(kc) kc | 0x0100
66 #define LSFT(kc) kc | 0x0200
67 #define LALT(kc) kc | 0x0400
68 #define LGUI(kc) kc | 0x0800
69 #define RCTL(kc) kc | 0x1100
70 #define RSFT(kc) kc | 0x1200
71 #define RALT(kc) kc | 0x1400
72 #define RGUI(kc) kc | 0x1800
73
74 // Alias for function layers than expand past FN31
75 #define FUNC(kc) kc | 0x2000
76
77 // Aliases
78 #define S(kc) LSFT(kc)
79 #define F(kc) FUNC(kc)
80
81 // For software implementation of colemak
82 #define CM_Q    KC_Q
83 #define CM_W    KC_W
84 #define CM_F    KC_E
85 #define CM_P    KC_R
86 #define CM_G    KC_T
87 #define CM_J    KC_Y
88 #define CM_L    KC_U
89 #define CM_U    KC_I
90 #define CM_Y    KC_O
91 #define CM_SCLN KC_P
92
93 #define CM_A    KC_A
94 #define CM_R    KC_S
95 #define CM_S    KC_D
96 #define CM_T    KC_F
97 #define CM_D    KC_G
98 #define CM_H    KC_H
99 #define CM_N    KC_J
100 #define CM_E    KC_K
101 #define CM_I    KC_L
102 #define CM_O    KC_SCLN
103
104 #define CM_Z    KC_Z
105 #define CM_X    KC_X
106 #define CM_C    KC_C
107 #define CM_V    KC_V
108 #define CM_B    KC_B
109 #define CM_K    KC_N
110 #define CM_M    KC_M
111 #define CM_COMM KC_COMM
112 #define CM_DOT  KC_DOT
113 #define CM_SLSH KC_SLSH
114
115 // Make it easy to support these in macros
116 #define KC_CM_Q    CM_Q    
117 #define KC_CM_W    CM_W    
118 #define KC_CM_F    CM_F    
119 #define KC_CM_P    CM_P    
120 #define KC_CM_G    CM_G    
121 #define KC_CM_J    CM_J    
122 #define KC_CM_L    CM_L    
123 #define KC_CM_U    CM_U    
124 #define KC_CM_Y    CM_Y    
125 #define KC_CM_SCLN CM_SCLN 
126
127 #define KC_CM_A    CM_A    
128 #define KC_CM_R    CM_R    
129 #define KC_CM_S    CM_S    
130 #define KC_CM_T    CM_T    
131 #define KC_CM_D    CM_D    
132 #define KC_CM_H    CM_H    
133 #define KC_CM_N    CM_N    
134 #define KC_CM_E    CM_E    
135 #define KC_CM_I    CM_I    
136 #define KC_CM_O    CM_O    
137
138 #define KC_CM_Z    CM_Z    
139 #define KC_CM_X    CM_X    
140 #define KC_CM_C    CM_C    
141 #define KC_CM_V    CM_V    
142 #define KC_CM_B    CM_B    
143 #define KC_CM_K    CM_K    
144 #define KC_CM_M    CM_M    
145 #define KC_CM_COMM CM_COMM 
146 #define KC_CM_DOT  CM_DOT  
147 #define KC_CM_SLSH CM_SLSH 
148
149 #define M(kc) kc | 0x3000
150
151 #define MACRODOWN(...) (record->event.pressed ? MACRO(__VA_ARGS__) : MACRO_NONE)
152
153 #define BL_ON 0x4009
154 #define BL_OFF 0x4000
155 #define BL_0 0x4000
156 #define BL_1 0x4001
157 #define BL_2 0x4002
158 #define BL_3 0x4003
159 #define BL_4 0x4004
160 #define BL_5 0x4005
161 #define BL_6 0x4006
162 #define BL_7 0x4007
163 #define BL_8 0x4008
164 #define BL_9 0x4009
165 #define BL_10 0x400A
166 #define BL_11 0x400B
167 #define BL_12 0x400C
168 #define BL_13 0x400D
169 #define BL_14 0x400E
170 #define BL_15 0x400F
171 #define BL_DEC 0x4010
172 #define BL_INC 0x4011
173 #define BL_TOGG 0x4012
174 #define BL_STEP 0x4013
175
176 #define RESET 0x5000
177 #define DEBUG 0x5001
178
179 #define MIDI(n) n | 0x6000
180
181 #endif