summaryrefslogtreecommitdiffstats
path: root/keyboards/dz60/keymaps/kifinnsson/keymap.c
blob: 6fbb4466ab9c3848dfaf9a3c34430473d327a359 (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
#include QMK_KEYBOARD_H

bool is_lgui_active = false;
uint16_t lgui_timer = 0;


//Macro Declarations
enum my_keycodes {
  KI_NO = SAFE_RANGE,
    KI_1,
    KI_2,
    KI_3,
    KI_4,
    KI_5,
    KI_6,
    KI_7,
    KI_8,
    KI_9,
    KI_10,
    KI_11,
    KI_12,
    KI_ESC,
    KI_BKSP,
    KI_BSLS,
    KI_WLFT,
    KI_WRGT,
    };

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

	LAYOUT_all(
		QK_GESC, KC_1,    KC_2,    KC_3,    KC_4,    KC_5,    KC_6,    KC_7,   KC_8,     KC_9,    KC_0,    KC_MINS, KC_EQL,  XXXXXXX, KC_BSPC,
		KC_TAB,  KC_Q,    KC_W,    KC_F,    KC_P,    KC_G,    KC_J,    KC_L,   KC_U,     KC_Y,    KC_SCLN, KC_LBRC, KC_RBRC, KC_BSLS,
		MO(1),   KC_A,    KC_R,    KC_S,    KC_T,    KC_D,    KC_H,    KC_N,   KC_E,     KC_I,    KC_O,    KC_QUOT, KC_ENT,
		KC_LSFT, KC_Z,    KC_X,    KC_C,    KC_V,    KC_B,    MO(2),   KC_K,   KC_M,     KC_COMM, KC_DOT,  KC_SLSH, XXXXXXX, KC_RSFT, XXXXXXX,
		KC_LCTL, KC_LGUI, KC_LALT, KC_SPC,  KC_SPC,  KC_SPC,  KC_RALT, MO(1),  XXXXXXX,  MO(3),   KC_RCTL),

	LAYOUT_all(
		KC_GRV,  KC_F1,   KC_F2,   KC_F3,   KC_F4,   KC_F5,   KC_F6,   KC_F7,   KC_F8,   KC_F9,   KC_F10,  KC_F11,  KC_F12,  KC_DEL,
		_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_PGUP, KC_HOME, KC_UP,   KC_END,  XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
		_______, XXXXXXX, KC_TAB,  KC_LSFT, KC_LCTL, XXXXXXX, KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, KC_DEL,  KC_CAPS, XXXXXXX,
		_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, KC_BSPC, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,,
		_______, _______, XXXXXXX, KC_ENT,  KC_ENT,  KC_ENT,  _______, _______, _______, _______, QK_BOOT),

	LAYOUT_all(
		KI_ESC,  _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX, KI_BKSP,
		_______, KI_1,    KI_2,    KI_3,    KI_4,    KI_5,    KI_6,    KI_7,    KI_8,    KI_9,    KI_10,   KI_11,   KI_12,   KI_BSLS,
		_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
		_______, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _______, XXXXXXX, XXXXXXX, KI_WLFT, KI_WRGT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
		_______, _______, _______, _______, _______, _______, _______, _______, XXXXXXX, _______, XXXXXXX),

	LAYOUT_all(
		_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
		_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
		_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
		_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
		_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______),
};

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  switch (keycode) {
    // Keycodes Starting with KI_ are place holders for my personal macros. They are set below. Most are simple SEND_STRINGS().
    case KI_ESC:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_1:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_2:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_3:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_4:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_5:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_6:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_7:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_8:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_9:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_10:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_11:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_12:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_BKSP:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key
    case KI_BSLS:
      if (record->event.pressed) {
        SEND_STRING("");
      } else {
        
      }
      return false; // Skip all further processing of this key

    //Windows Win+Left tap to move window without resetting KC_LGUI
    //Additional code is in matrix_scan_user()
    case KI_WLFT:
      if (record->event.pressed) {
        if (!is_lgui_active) {
          is_lgui_active = true;
          register_code(KC_LGUI);
        } 
        lgui_timer = timer_read();
        tap_code(KC_LEFT);
      } else {
        
      }
      return false; // Skip all further processing of this key
    //Windows Win+Right tap to move window without resetting KC_LGUI
    //Additional code is in matrix_scan_user()
    case KI_WRGT:
      if (record->event.pressed) {
        if (!is_lgui_active) {
          is_lgui_active = true;
          register_code(KC_LGUI);
        } 
        lgui_timer = timer_read();
        tap_code(KC_RIGHT);
      } else {
        
      }
      return false; // Skip all further processing of this key
    default:
      return true; // Process all other keycodes normally
  }
}

//Check if KC_LGUI is active in KI_WLFT and KI_WRGT
void matrix_scan_user(void) { 
  if (is_lgui_active) {
    if (timer_elapsed(lgui_timer) > 1000) {
      unregister_code(KC_LGUI);
      is_lgui_active = false;
    }
  }
}