summaryrefslogtreecommitdiff
path: root/keyboards/roadkit/keymaps/singlesBrent/keymap.c
blob: 13197346a908819b66067287c1b690604881ac2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
#include "roadkit.h"
#include "action_layer.h"
#include "eeconfig.h"

extern keymap_config_t keymap_config;

// Each layer gets a name for readability, which is then used in the keymap matrix below.
// The underscores don't mean anything - you can have a layer called STUFF or any other name.
// Layer names don't all need to be of the same length, obviously, and you can also skip them
// entirely and just use numbers.

#define _NP 0
#define _L1 1
#define _L2 2
#define _L3 3

// Macro name shortcuts
#define NUMPAD M(_NP)
#define LAYER1 M(_L1)
#define LAYER2 M(_L2)
#define LAYER3 M(_L3)

// Fillers to make layering more clear
#define _______ KC_TRNS
#define XXXXXXX KC_NO

void matrix_init_user(void) {
	backlight_level(4);
}



//Tap Dance Declarations

enum {

  TD_EQUAL_NP = 0,
  TD_KP_PLUS_L1,
  TD_DOT_L2,
  TD_0_L3

};

//Tap Dance Definitions


	//TD equal to turn on layer NP
void _td_equal_tg_finished (qk_tap_dance_state_t *state, void *user_data) {
  if (state->count == 1) {
    register_code(KC_EQUAL);
  } else if (state->count == 2) {
    backlight_set(3);
	layer_on(_NP);
	layer_off(_L1);
	layer_off(_L2);
	layer_off(_L3);
  }
}

void _td_equal_tg_reset (qk_tap_dance_state_t *state, void *user_data) {
  if (state->count == 1) {
    unregister_code(KC_EQUAL);
  }
}


	//TD kp plus to toggle layer 1
void _td_kp_plus_tg_finished (qk_tap_dance_state_t *state, void *user_data) {
  if (state->count == 1) {
    register_code(KC_KP_PLUS);
  } else if (state->count == 2) {
//    layer_invert(_L1);
    backlight_set(2);
	layer_on(_L1);
	layer_off(_L2);
	layer_off(_L3);
  }
}

void _td_kp_plus_tg_reset (qk_tap_dance_state_t *state, void *user_data) {
  if (state->count == 1) {
    unregister_code(KC_KP_PLUS);
  }
}


	//TD dot to toggle layer 2
void _td_dot_tg_finished (qk_tap_dance_state_t *state, void *user_data) {
  if (state->count == 1) {
    register_code(KC_DOT);
  } else if (state->count == 2) {
    backlight_set(1);
	layer_on(_L2);
	layer_off(_L1);
	layer_off(_L3);
  }
}

void _td_dot_tg_reset (qk_tap_dance_state_t *state, void *user_data) {
  if (state->count == 1) {
    unregister_code(KC_DOT);
  }
}

	//TD 0 to toggle layer 3
void _td_0_tg_finished (qk_tap_dance_state_t *state, void *user_data) {
  if (state->count == 1) {
    register_code(KC_0);
  } else if (state->count == 2) {
    backlight_set(0);
	layer_on(_L3);
	layer_off(_L1);
	layer_off(_L2);
  }
}

void _td_0_tg_reset (qk_tap_dance_state_t *state, void *user_data) {
  if (state->count == 1) {
    unregister_code(KC_0);
  }
}

//TD Actions
qk_tap_dance_action_t tap_dance_actions[] = {
  [TD_EQUAL_NP] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_equal_tg_finished, _td_equal_tg_reset),
  [TD_KP_PLUS_L1] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_kp_plus_tg_finished, _td_kp_plus_tg_reset),
  [TD_DOT_L2] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_dot_tg_finished, _td_dot_tg_reset),
  [TD_0_L3] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, _td_0_tg_finished, _td_0_tg_reset)
};



const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

/* Numberpad
 * ,-----------------------.
 * |  7  |  8  |  9  |  /  |
 * |-----`-----`-----`-----|
 * |  4  |  5  |  6  |  *  |
 * |-----`-----`-----`-----|
 * |  1  |  2  |  3  |  -  |
 * |-----`-----`-----`-----|
 * |  0  |  .  |  +  |  =  |
 * `-----`-----`-----`-----'
 * Tapdances:
 * | L3  | L2  | L1  | NP  |
 * `-----`-----`-----`-----'
 */
  [_NP] = /* Numpad */
    SINGLES_KEYMAP(KC_7,        KC_8,          KC_9,              KC_SLASH,  \
                   KC_4,        KC_5,          KC_6,              KC_KP_ASTERISK, \
                   KC_1,        KC_2,          KC_3,              KC_MINUS, \
                   TD(TD_0_L3), TD(TD_DOT_L2), TD(TD_KP_PLUS_L1), TD(TD_EQUAL_NP)),

/* L1
 * ,-----------------------.
 * | Esc |Bksp |Home |PgUp |
 * |-----`-----`-----`-----|
 * | Tab | Up  | End |PgDn |
 * |-----`-----`-----`-----|
 * |Left |Down |Right|Enter|
 * |-----`-----`-----`-----|
 * |  0  |  .  |  +  |  =  |
 * `-----`-----`-----`-----'
 */
  [_L1] = /* LAYER 1 */
    SINGLES_KEYMAP(KC_ESCAPE, KC_BSPACE, KC_HOME,  KC_PGUP, \
                   KC_TAB,    KC_UP,     KC_END,   KC_PGDOWN, \
                   KC_LEFT,   KC_DOWN,   KC_RIGHT, KC_KP_ENTER, \
                   KC_TRNS,   KC_TRNS,   KC_TRNS,  KC_TRNS),

/* L2
 * ,-----------------------.
 * |Sleep|LClik|RClik|VolUp|
 * |-----`-----`-----`-----|
 * |AltF4| F11 |WinTb|VolDn|
 * |-----`-----`-----`-----|
 * |PrvTk|Play |NxtTk|Mute |
 * |-----`-----`-----`-----|
 * |  0  |  .  |  +  |  =  |
 * `-----`-----`-----`-----'
 */				   
  [_L2] = /* LAYER 2 */
    SINGLES_KEYMAP(KC_SYSTEM_SLEEP,     KC_MS_BTN1,          KC_MS_BTN2,          KC_AUDIO_VOL_UP, \
                   LALT(KC_F4),         KC_F11,              LGUI(KC_TAB),        KC_AUDIO_VOL_DOWN, \
                   KC_MEDIA_PREV_TRACK, KC_MEDIA_PLAY_PAUSE, KC_MEDIA_NEXT_TRACK, KC_AUDIO_MUTE, \
                   KC_TRNS,             KC_TRNS,             KC_TRNS,             KC_TRNS),

				   
/* L3 needs cut, copy, paste, undo, again (redo), find, calc, www back, www forward, F5
 * ,-----------------------.
 * |WBack|WHome|WFor | F5  |
 * |-----`-----`-----`-----|
 * |Calc |Undo |Redo |WSrch|
 * |-----`-----`-----`-----|
 * | Cut |Copy |Paste|Find |
 * |-----`-----`-----`-----|
 * |  0  |  .  |  +  |  =  |
 * `-----`-----`-----`-----'
 */	
  [_L3] = /* LAYER 3 */
    SINGLES_KEYMAP(KC_WWW_BACK,   KC_WWW_HOME, KC_WWW_FORWARD, KC_F5, \
                   KC_CALCULATOR, LCTL(KC_Z),  LCTL(KC_Y),     KC_WWW_SEARCH, \
                   LCTL(KC_X),    LCTL(KC_C),  LCTL(KC_V),     LCTL(KC_F), \
                   KC_TRNS,       KC_TRNS,     KC_TRNS,        KC_TRNS),
};

const uint16_t PROGMEM fn_actions[] = {

};

void persistent_default_layer_set(uint16_t default_layer) {
  eeconfig_update_default_layer(default_layer);
  default_layer_set(default_layer);
}

const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
{
      switch(id) {
        case _L3:
          if (record->event.pressed) {
            persistent_default_layer_set(1UL<<_L3);
          }
          break;
		case _L2:
          if (record->event.pressed) {
            persistent_default_layer_set(1UL<<_L2);
          }
          break;
        case _L1:
          if (record->event.pressed) {
            persistent_default_layer_set(1UL<<_L1);
          }
          break;
        case _NP:
          if (record->event.pressed) {
            persistent_default_layer_set(1UL<<_NP);
          }
          break;
      }
    return MACRO_NONE;
};