]> git.donarmstrong.com Git - qmk_firmware.git/blob - keyboard/planck/keymaps/cbbrowne/keymap.c
Merge branch 'master' of github.com:cbbrowne/qmk_firmware
[qmk_firmware.git] / keyboard / planck / keymaps / cbbrowne / keymap.c
1 #include "planck.h"
2 #ifdef BACKLIGHT_ENABLE
3   #include "backlight.h"
4 #endif
5
6 /* Each layer is given a name to aid in readability, which is then
7    used in the keymap matrix below.  The underscores do not denote 
8    anything - you can have a layer called STUFF or any other name.
9
10    Layer names don't all need to be of the same length, obviously, and
11    you could also skip them entirely and just use numbers, though that
12    means needing to manage the numbers.
13
14    It is preferable to keep the symbols short so that a line worth of
15    key mappings fits compactly onto a line of code. */
16
17 /* This was originally based on planck/keymaps/default/default.c, and
18    then cbbrowne has revised things */
19
20 /* Things I did not like about the default mapping 
21
22    - I find control too hard to get to.  I think I'll want it on a
23      left finger.  Gonna need to lose something to do that...
24    - Almost certainly, KC_LCTL should be on [2][1]
25    - having dash on [lower-j] is a bit nonintuitive, but may be OK
26    - I'll bet I should switch ESC/TAB
27    - I'm suspicious that I want to shift M(0) from [4][1] to [4][2],
28      and shift ESC off the first column so KC_LCTL and KC_LALT can
29      be on the first column.
30    - I think I wanna swap ' and ENTER
31
32    - All of the above are done :-)
33
34    - I'm keeping Colemak and Dvorak around for reference, and added
35      Workman just for fun.  They're useless to me, though.
36 */
37
38 /* Other things to do...
39
40    - Need to think about what zsh and readline actions I use lots
41    - Wanna figure out macros, so I can put in a "cbbrowne" macro
42    - Ought to ensure that Control-Alt-Delete is convenient enough
43    - How about Alt-F1 thru Alt-F8?
44    - What's the keystroke to get from X to console these days?
45    - I do indeed want a sweet number pad!
46    - A layer for doing console switching would not be a bad idea
47    - Random data generator
48      - A key that generates values in the range 0-9 at random
49      - A key that generates values in the range a-z at random
50      - A key that generates values in the range a-z,A-Z,0-9 at random
51
52    - Figure out the MACRO example in https://github.com/tmk/tmk_keyboard/blob/master/tmk_core/doc/keymap.md
53      - section 2.3.2
54      - where does the HELLO come from???
55      - What are the types of the T() calls? 
56 */
57
58 enum layers {
59   _QW = 0,  /* Qwerty mapping */
60   _LW, /* Lower layer, where top line has symbols !@#$%^&*() */
61   _RS, /* Raised layer, where top line has digits 1234567890 */
62   _KP, /* Key pad */
63 };
64
65 enum macro_id {
66   M_LED = 0,
67   M_USERNAME,
68   M_RANDDIGIT
69 };
70
71 /* Note that Planck has dimensions 4 rows x 12 columns */
72
73 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
74 [_QW] = { /* Qwerty */
75   {KC_ESC,  KC_Q,    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_U,    KC_I,    KC_O,    KC_P,    KC_BSPC},
76   {KC_LCTL, KC_A,    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_J,    KC_K,    KC_L,    KC_SCLN, KC_ENT},
77   {KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_M,    KC_COMM, KC_DOT,  KC_SLSH, KC_QUOT },
78   {KC_TAB,  M(M_LED), KC_LALT, KC_LGUI, MO(_LW), KC_SPC,  KC_SPC,  MO(_RS), KC_LEFT, KC_DOWN, KC_UP,   KC_RGHT}
79 },
80 [_RS] = { /* RAISE */
81   {KC_GRV,  KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,    KC_8,    KC_9,    KC_0,    KC_BSPC},
82   {KC_TRNS, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_MINS, KC_EQL,  KC_LBRC, KC_RBRC, KC_BSLS},
83   {KC_TRNS, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  DF(_QW), DF(_KP), DF(_KP), RESET,   KC_TRNS},
84   {KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
85 },
86 [_LW] = { /* LOWER */
87   {KC_TILD, KC_EXLM, KC_AT,   KC_HASH, KC_DLR,  KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC},
88   {KC_TRNS, KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE},
89   {KC_TRNS, KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  DF(_QW), DF(_KP), DF(_KP), RESET,   KC_TRNS},
90   {KC_TRNS, DF(_KP), KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY}
91 },
92 [_KP] = { /* Key Pad */
93   {KC_ESC,  M(M_USERNAME),    KC_W,    KC_E,    KC_R,    KC_T,    KC_Y,    KC_KP_ENTER, KC_KP_PLUS, KC_KP_PLUS, KC_KP_ENTER, KC_KP_ENTER},
94   {KC_LCTL, M(M_RANDDIGIT),    KC_S,    KC_D,    KC_F,    KC_G,    KC_H,    KC_KP_MINUS, KC_7, KC_8,    KC_9,  KC_KP_DOT},
95   {KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    KC_N,    KC_KP_PLUS,    KC_4, KC_5,  KC_6, KC_0},
96   {BL_STEP, M(M_LED), KC_LALT, KC_LGUI, KC_NO, KC_SPC,  KC_SPC,  DF(_QW),   KC_1, KC_2, KC_3,  KC_0}
97 }
98 };
99
100 const uint16_t PROGMEM fn_actions[] = {
101 };
102
103 static uint16_t random_value = 157;
104 #define randadd 53
105 #define randmul 181
106 #define randmod 167
107
108 const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
109 {
110   // MACRODOWN only works in this function
111   switch(id) {
112   case M_LED:
113     if (record->event.pressed) {
114       register_code(KC_RSFT);
115 #ifdef BACKLIGHT_ENABLE
116       backlight_step();
117 #endif
118     } else {
119       unregister_code(KC_RSFT);
120     }
121     break;          
122   case M_USERNAME:
123     if (record->event.pressed) {
124       return MACRO( I(1), T(C), T(B), T(B), T(R), T(O), T(W), T(N), T(E));
125     } else {
126       return MACRO_NONE ;
127     }
128     break;
129   case M_RANDDIGIT:
130     random_value = ((random_value + randadd) * randmul) % randmod;
131     if (record->event.pressed) 
132     switch(random_value % 10) {
133     case 0:
134       return MACRO(T(0));
135       break;
136     case 1:
137       return MACRO(T(1));
138       break;
139     case 2:
140       return MACRO(T(2));
141       break;
142     case 3:
143       return MACRO(T(3));
144       break;
145     case 4:
146       return MACRO(T(4));
147       break;
148     case 5:
149       return MACRO(T(5));
150       break;
151     case 6:
152       return MACRO(T(6));
153       break;
154     case 7:
155       return MACRO(T(7));
156       break;
157     case 8:
158       return MACRO(T(8));
159       break;
160     case 9:
161       return MACRO(T(9));
162       break;
163     }
164     break;
165   }
166   return MACRO_NONE;
167 };