aboutsummaryrefslogtreecommitdiffstats
path: root/layouts/community/ortho_4x12/symbolic/keymap.c
blob: c2923737111444a8efb8065d88c4df9e9e0260c6 (plain) (blame)
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
#include QMK_KEYBOARD_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 _QWERTY  0
#define _LOWER   1
#define _RAISE   2
#define _NEUTRAL 3

enum custom_keycodes {
  QWERTY = SAFE_RANGE,
  L_LOWER,
  R_LOWER,
  L_RAISE,
  R_RAISE
};


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

/* Qwerty
 * ,------------------------------------------------------------------------------------.
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * | Esc  |   Q  |   W  |   E  |   R  |   T  ||   Y  |   U  |   I  |   O  |   P  | Bksp |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |LCTL_T|      |      |      |      |      ||      |      |      |      |      |      |
 * | Tab  |   A  |   S  |   D  |   F  |   G  ||   H  |   J  |   K  |   L  |   ;  |Enter |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * |Shift |   Z  |   X  |   C  |   V  |   B  ||   N  |   M  |   ,  |   .  |   !  |Shift |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * |LRaise| Alt  | GUI  |      |LLower|Space ||Space |RLower|      | GUI  | Del  |RRaise|
 * `------------------------------------------------------------------------------------'
 */
[_QWERTY] = LAYOUT_ortho_4x12( \
  KC_ESC,         KC_Q,     KC_W,     KC_E,     KC_R,     KC_T,     KC_Y,     KC_U,     KC_I,     KC_O,     KC_P,     KC_BSPC, \
  LCTL_T(KC_TAB), KC_A,     KC_S,     KC_D,     KC_F,     KC_G,     KC_H,     KC_J,     KC_K,     KC_L,     KC_SCLN,  KC_ENT,  \
  KC_LSFT,        KC_Z,     KC_X,     KC_C,     KC_V,     KC_B,     KC_N,     KC_M,     KC_COMM,  KC_DOT,   KC_EXLM,  KC_RSFT, \
  L_RAISE,        KC_LALT,  KC_LGUI,  XXXXXXX,  L_LOWER,  KC_SPC,   KC_SPC,   R_LOWER,  XXXXXXX,  KC_RGUI,  KC_DEL,   R_RAISE  \
),

/* Raise
 * ,------------------------------------------------------------------------------------.
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * | Esc  |      |   &  |   {  |   }  |   %  ||   \  |   [  |   ]  |   #  |      | Bksp |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |LCTL_T|      |      |      |      |      ||      |      |      |      |      |      |
 * | Tab  |   ~  |   |  |   (  |   )  |   *  ||   /  |   <  |   >  |   '  |   :  |Enter |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * |Shift |   `  |   ^  |   @  |   $  |   +  ||   -  |   =  |   _  |   "  |   ?  |Shift |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * |LRaise| Alt  | GUI  |      |LLower|Space ||Space |RLower|      | GUI  | Del  |RRaise|
 * `------------------------------------------------------------------------------------'
 */
[_RAISE] = LAYOUT_ortho_4x12( \
  _______,  XXXXXXX,  KC_AMPR,  KC_LCBR,  KC_RCBR,  KC_PERC,  KC_BSLS,  KC_LBRC,  KC_RBRC,  KC_HASH,  XXXXXXX,  _______, \
  _______,  KC_TILD,  KC_PIPE,  KC_LPRN,  KC_RPRN,  KC_ASTR,  KC_SLSH,  KC_LABK,  KC_RABK,  KC_DQUO,  KC_COLN,  _______, \
  _______,  KC_GRV,   KC_CIRC,  KC_AT,    KC_DLR,   KC_PLUS,  KC_MINS,  KC_EQL,   KC_UNDS,  KC_QUOT,  KC_QUES,  _______, \
  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______  \
),
/* Lower
 * ,------------------------------------------------------------------------------------.
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * | Esc  |   1  |   2  |   3  |   4  |   5  ||   6  |   7  |   8  |   9  |   0  | Bksp |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |LCTL_T|      |      |      |      |      ||      |      |      |      |      |      |
 * | Tab  |      |VolDn |VolUp | Mute |      || Left | Down |  Up  |Right |      |Enter |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * |Shift |      |      |      |      | PrSc || Home | PgDn | PgUp | End  |      |Shift |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * |LRaise| Alt  | GUI  |      |LLower|Space ||Space |RLower|      | GUI  | Del  |RRaise|
 * `------------------------------------------------------------------------------------'
 */
[_LOWER] = LAYOUT_ortho_4x12( \
  _______,  KC_1,     KC_2,     KC_3,     KC_4,     KC_5,     KC_6,     KC_7,     KC_8,     KC_9,     KC_0,     _______, \
  _______,  XXXXXXX,  KC_VOLD,  KC_VOLU,  KC_MUTE,  XXXXXXX,  KC_LEFT,  KC_DOWN,  KC_UP,    KC_RGHT,  XXXXXXX,  _______, \
  _______,  XXXXXXX,  XXXXXXX,  XXXXXXX,  XXXXXXX,  KC_PSCR,  KC_HOME,  KC_PGDN,  KC_PGUP,  KC_END,   XXXXXXX,  _______, \
  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______,  _______  \
),

/* Neutral
 * ,------------------------------------------------------------------------------------.
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * | Esc  |  F1  |  F2  |  F3  |  F4  |      ||   +  |   -  |   1  |   2  |   3  | Bksp |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |LCTL_T|      |      |      |      |      ||      |      |      |      |      |      |
 * | Tab  |  F5  |  F6  |  F7  |  F8  |      ||   *  |   /  |   4  |   5  |   6  |Enter |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * |Shift |  F9  |  F10 |  F11 |  F12 |      ||   .  |   ,  |   7  |   8  |   9  |Shift |
 * |------+------+------+------+------+------++------+------+------+------+------+------|
 * |      |      |      |      |      |      ||      |      |      |      |      |      |
 * |LRaise| Alt  | GUI  |Reset |LLower|Space ||Space |RLower|Reset |   0  | Del  |RRaise|
 * `------------------------------------------------------------------------------------'
 */
[_NEUTRAL] = LAYOUT_ortho_4x12( \
  _______,  KC_F1,    KC_F2,    KC_F3,    KC_F4,    XXXXXXX,  KC_PPLS,  KC_PMNS,  KC_P1,    KC_P2,    KC_P3,     _______, \
  _______,  KC_F5,    KC_F6,    KC_F7,    KC_F8,    XXXXXXX,  KC_PAST,  KC_PSLS,  KC_P4,    KC_P5,    KC_P6,     _______, \
  _______,  KC_F9,    KC_F10,   KC_F11,   KC_F12,   XXXXXXX,  KC_PDOT,  KC_COMM,  KC_P7,    KC_P8,    KC_P9,     _______, \
  _______,  _______,  _______,  RESET,    _______,  _______,  _______,  _______,  RESET,    KC_P0,    _______,   _______  \
)


};



/****  Raise Layer functions *****/

  /* RaisePressed function */
    /* called RaiseSwitch  */
void RaisePressed ( keyevent_t *event, bool brother_state ){ 
  
  if( brother_state ) { return; }

  layer_on( _RAISE );
  update_tri_layer( _LOWER, _RAISE, _NEUTRAL );
  return;

}


  /* RaiseReleased function */
    /* called RaiseSwitch   */
void RaiseReleased ( bool brother_state ){ 
  
  if( brother_state ) { return; }

  layer_off( _RAISE );
  update_tri_layer( _LOWER, _RAISE, _NEUTRAL );
  return;
}


  /* RaiseSwitch function         */
    /* called process_record_user */
bool RaiseSwitch ( keyrecord_t *record, bool *key_state, bool brother ){ 

  if( record -> event.pressed ) {
    *key_state = true;
    RaisePressed( &(record -> event), brother );
  } else {
    *key_state = false;
    RaiseReleased( brother );
  }
  return false;

}






/**** Lower layer functions ****/

  /* LowerPressed function   */
    /* call from LowerSwitch */
void LowerPressed ( bool brother_state ){

  if( brother_state ) { return; }

  layer_on( _LOWER );
  update_tri_layer(_LOWER, _RAISE, _NEUTRAL );
  return;
}

  /* LowerReleased function  */
    /* call from LowerSwitch */
void LowerReleased ( bool brother_state ){ 

  if( brother_state ) { return; }

  layer_off( _LOWER );
  update_tri_layer(_LOWER, _RAISE, _NEUTRAL );
  return ;
}

  /* LowerSwitch function            */
    /* call from process_record_user */
bool LowerSwitch ( keyrecord_t *record, bool *key_state, bool brother ){ 
  if ( record -> event.pressed ) {
    *key_state = true;
    LowerPressed( brother );
  } else {
    *key_state = false;
    LowerReleased( brother );
  }

  return false;

}



/**** process_record_user ****/
bool process_record_user(uint16_t keycode, keyrecord_t *record) {

  static bool l_lower = false;
  static bool r_lower = false;

  static bool l_raise = false;
  static bool r_raise = false;

  switch (keycode) {


    case L_LOWER : return LowerSwitch( record, &l_lower, r_lower ); break;
    case R_LOWER : return LowerSwitch( record, &r_lower, l_lower ); break;
    case L_RAISE : return RaiseSwitch( record, &l_raise, r_raise ); break;
    case R_RAISE : return RaiseSwitch( record, &r_raise, l_raise ); break;

    default: break;

  }
  return true;
}