aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/dz60/keymaps/marianas/customLogic.c138
-rw-r--r--keyboards/dz60/keymaps/marianas/customLogic.h10
-rw-r--r--keyboards/dz60/keymaps/marianas/keyDefinitions.h124
-rw-r--r--keyboards/dz60/keymaps/marianas/keymap.c521
-rw-r--r--keyboards/dz60/keymaps/marianas/keymap.h114
-rw-r--r--keyboards/dz60/keymaps/marianas/relativity.c510
-rw-r--r--keyboards/dz60/keymaps/marianas/relativity.h32
-rw-r--r--keyboards/dz60/keymaps/marianas/rules.mk4
8 files changed, 839 insertions, 614 deletions
diff --git a/keyboards/dz60/keymaps/marianas/customLogic.c b/keyboards/dz60/keymaps/marianas/customLogic.c
new file mode 100644
index 000000000..b7dbcac95
--- /dev/null
+++ b/keyboards/dz60/keymaps/marianas/customLogic.c
@@ -0,0 +1,138 @@
1#include QMK_KEYBOARD_H
2#include "customLogic.h"
3#include "keymap.h"
4#include "keyDefinitions.h"
5#include "relativity.h"
6#include "timer.h"
7
8static int16_t fnTimer = 0;
9
10
11
12uint32_t layer_state_set_user(uint32_t state)
13{
14 switch (biton32(state))
15 {
16 case QWERTY:
17 rgblight_mode(9);
18 break;
19 case NAV_CLUSTER:
20 rgblight_mode(29);
21 break;
22 case GAMING:
23 rgblight_mode(26);
24 break;
25 case SQLMACROS:
26 rgblight_mode(1);
27 break;
28 case FN_LAYER:
29 rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL+5);
30 break;
31 }
32 return state;
33}
34
35
36
37bool printSqlVerbs(uint16_t keycode, keyrecord_t *record)
38{
39 if (record->event.pressed)
40 {
41 switch (keycode)
42 {
43 case S_LFTJN:
44 SEND_STRING("LEFT JOIN");
45 activateRelativity();
46 return false;
47 case S_INRJN:
48 SEND_STRING("INNER JOIN ");
49 activateRelativity();
50 return false;
51 case S_SLCT:
52 SEND_STRING("SELECT "); return
53 false;
54 case S_FROM:
55 SEND_STRING("FROM "); return
56 false;
57 case S_DSNCT:
58 SEND_STRING("DISTINCT "); return
59 false;
60 case S_ORDER:
61 SEND_STRING("ORDER BY "); return
62 false;
63 case S_WHERE:
64 SEND_STRING("WHERE "); return
65 false;
66 case S_ALTER:
67 SEND_STRING("ALTER SESSION SET CURRENT_SCHEMA = SUPPLY;"); return false;
68 case S_ASTRK:
69 SEND_STRING("* "); return false;
70
71 }
72 }
73 return true;
74}
75
76
77bool isFn = false;
78bool didFn = false;
79
80
81bool updateLayerState(uint16_t keycode, keyrecord_t *record)
82{
83
84 if (record->event.pressed)
85 {
86 switch (keycode)
87 {
88 case FN_QT:
89 fnTimer = timer_read();
90 layer_on(FN_LAYER);
91 isFn = true;
92 return false;
93 }
94 if (isFn)
95 {
96 didFn = true;
97 return true;
98 }
99 }
100 else
101 {
102 switch(keycode)
103 {
104 case FN_QT:
105 layer_off(FN_LAYER);
106 if (!didFn)
107 {
108 #if fnTimeout
109 if (TIMER_DIFF_16(timer_read(), fnTimer) <= fnTimeout)
110 {
111 activateRelativity();
112 }
113 else
114 {
115 deactivateRelativity();
116 }
117 #else
118 activateRelativity();
119 #endif
120 }
121 didFn = false;
122 isFn = false;
123 return false;
124 }
125 }
126 return true;
127}
128
129
130
131bool process_record_user(uint16_t keycode, keyrecord_t *record)
132{
133 return
134 storeShiftState(keycode, record) &&
135 printSqlVerbs(keycode, record) &&
136 updateLayerState(keycode, record) &&
137 handleSmartMacros(keycode, record);
138}
diff --git a/keyboards/dz60/keymaps/marianas/customLogic.h b/keyboards/dz60/keymaps/marianas/customLogic.h
new file mode 100644
index 000000000..f0e6ecdca
--- /dev/null
+++ b/keyboards/dz60/keymaps/marianas/customLogic.h
@@ -0,0 +1,10 @@
1#define fnTimeout 500
2
3
4uint32_t layer_state_set_user(uint32_t state);
5
6bool printSqlVerbs(uint16_t keycode, keyrecord_t *record);
7
8bool updateLayerState(uint16_t keycode, keyrecord_t *record);
9
10bool process_record_user(uint16_t keycode, keyrecord_t *record);
diff --git a/keyboards/dz60/keymaps/marianas/keyDefinitions.h b/keyboards/dz60/keymaps/marianas/keyDefinitions.h
new file mode 100644
index 000000000..010ace769
--- /dev/null
+++ b/keyboards/dz60/keymaps/marianas/keyDefinitions.h
@@ -0,0 +1,124 @@
1
2//Control
3#define MO_FNLR MO(FN_LAYER)
4#define BACKSPC KC_BSPC
5#define ENTER_OR_SQL LT(SQLMACROS,KC_ENT)
6#define ESCAP KC_ESC
7#define PSCR KC_PSCREEN
8#define SCRL KC_SCROLLLOCK
9#define PAUS KC_PAUSE
10#define NSRT KC_INSERT
11#define HOME KC_HOME
12#define PGUP KC_PGUP
13#define PGDN KC_PGDN
14#define END_ KC_END
15#define DELT KC_DELETE
16#define UPUP KC_UP
17#define D_WN KC_DOWN
18#define LEFT KC_LEFT
19#define RGHT KC_RIGHT
20
21//KEYPAD
22#define KP_1 KC_KP_1
23#define KP_2 KC_KP_2
24#define KP_3 KC_KP_3
25#define KP_4 KC_KP_4
26#define KP_5 KC_KP_5
27#define KP_6 KC_KP_6
28#define KP_7 KC_KP_7
29#define KP_8 KC_KP_8
30#define KP_9 KC_KP_9
31#define KP_0 KC_KP_0
32#define NMLK KC_NUMLOCK
33#define STAR KC_KP_ASTERISK
34#define KSSH KC_KP_SLASH
35#define KMIN KC_KP_MINUS
36#define PLUS KC_KP_PLUS
37#define KNTR KC_KP_ENTER
38#define KDOT KC_KP_DOT
39
40//Modifiers
41#define CTLL KC_LCTL
42#define LEFTSHFT KC_LSPO
43#define WINL KC_LGUI
44#define ALTL KC_LALT
45#define CTLR KC_RCTL
46#define RIGHT_SHIFT__PAREN KC_RSPC
47#define WINR KC_RGUI
48#define ALTR KC_RALT
49#define APPR KC_APP
50
51
52//Punctuation
53#define CMMA KC_COMM
54#define PRRD KC_DOT
55#define SLSH KC_SLSH
56#define QUOT KC_QUOT
57#define COLN KC_SCLN
58#define LBRC KC_LBRC
59#define RBRC KC_RBRC
60#define EQUL KC_EQL
61#define MNUS KC_MINS
62#define BSLASH KC_BSLS
63
64//Layers
65#define QWRTY TO(QWERTY)
66#define NAVS TO(NAV_CLUSTER)
67#define GAME TO(GAMING)
68
69//Space
70#define ____ KC_TRNS
71#define _____ KC_TRNS
72#define ______ KC_TRNS
73#define _______ KC_TRNS
74#define ________ KC_TRNS
75#define ___________ KC_TRNS
76#define _________________ KC_TRNS
77#define SPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACE KC_SPC
78#define KCNO KC_NO
79
80enum sql_macros {
81 S_LFTJN = SAFE_RANGE, // L
82 S_INRJN, // I
83 S_SLCT, // S
84 S_FROM, // F
85 S_DSNCT, // D
86 S_ORDER, // O
87 S_WHERE, // W
88 S_ALTER, // Esc
89 S_ASTRK, // *
90
91 TD_A,
92 TD_B,
93 TD_C, // Corp, Corporation, Company
94 TD_D, // Distribution, Dist, Distributor
95 TD_E,
96 TD_F,
97 TD_G, // GlobalLookup
98 TD_H,
99 TD_I, // Instance, Item
100 TD_J,
101 TD_K,
102 TD_L,
103 TD_M,
104 TD_N, // NadRate
105 TD_O,
106 TD_P, // Product, Person,
107 TD_Q, // Darden
108 TD_R,
109 TD_S, // Supplier, Step
110 TD_T, // Task, Type
111 TD_U,
112 TD_V,
113 TD_W, // Workflow,
114 TD_X,
115 TD_Y,
116 TD_Z,
117 TD_BSPC,
118 TD_ENT,
119 TD_ESC,
120
121 FN_QT
122};
123
124bool isShifted(void);
diff --git a/keyboards/dz60/keymaps/marianas/keymap.c b/keyboards/dz60/keymaps/marianas/keymap.c
index e40bc6897..f86074b9c 100644
--- a/keyboards/dz60/keymaps/marianas/keymap.c
+++ b/keyboards/dz60/keymaps/marianas/keymap.c
@@ -1,505 +1,10 @@
1#include QMK_KEYBOARD_H 1#include QMK_KEYBOARD_H
2#include "keymap.h" 2#include "keymap.h"
3#include "relativity.h"
4#include "keyDefinitions.h"
5#include "customLogic.h"
3 6
4enum marianas_layers { 7// planned change: store previous table names and abbreviations to allow scrolling for inner joins on table name+id and abbreviation+id.
5 QWERTY,
6/*
7 COLEMAK,
8 DVORAK,
9*/
10 NAV_CLUSTER,
11 GAMING,
12 SQLMACROS,
13 SQLNAMES,
14 FN_LAYER
15};
16
17enum sql_macros {
18 S_LFTJN = SAFE_RANGE, // L
19 S_INRJN, // I
20 S_SLCT, // S
21 S_FROM, // F
22 S_DSNCT, // D
23 S_ORDER, // O
24 S_WHERE, // W
25 S_ALTER, // Esc
26 S_ASTRK, // *
27
28 TD_A,
29 TD_B,
30 TD_C, // Corp, Corporation, Company
31 TD_D, // Distribution, Dist, Distributor
32 TD_E,
33 TD_F,
34 TD_G, // GlobalLookup
35 TD_H,
36 TD_I, // Instance, Item
37 TD_J,
38 TD_K,
39 TD_L,
40 TD_M,
41 TD_N, // NadRate
42 TD_O,
43 TD_P, // Product, Person,
44 TD_Q, // Darden
45 TD_R,
46 TD_S, // Supplier, Step
47 TD_T, // Task, Type
48 TD_U,
49 TD_V,
50 TD_W, // Workflow,
51 TD_X,
52 TD_Y,
53 TD_Z,
54 TD_BSPC,
55 TD_ENT,
56 TD_ESC
57};
58
59uint16_t *macroTaps = 0;
60
61char *tableNameList = 0;
62
63uint8_t *charCount = 0;
64uint8_t countPointer = 0;
65
66bool shifted = false;
67
68bool sendAbbr = false;
69
70
71void initStringData(void)
72{
73 if (macroTaps == 0)
74 {
75 macroTaps = malloc(macroTapsLen*sizeof(uint16_t));
76 for(int i = 0; i < macroTapsLen; i++)
77 {
78 macroTaps[i] = 0;
79 }
80 }
81 if (tableNameList == 0)
82 {
83 tableNameList = malloc(tableNameListLen*sizeof(char));
84 for(int i = 0; i < tableNameListLen; i++)
85 {
86 tableNameList[i] = 0;
87 }
88 }
89 if (charCount == 0)
90 {
91 charCount = malloc(charCountLen*sizeof(uint8_t));
92 for (int i = 0; i < charCountLen; i++)
93 {
94 charCount[i] = 0;
95 }
96 }
97}
98
99
100uint32_t layer_state_set_user(uint32_t state)
101{
102 switch (biton32(state))
103 {
104 case QWERTY:
105 rgblight_mode(9);
106 break;
107 case NAV_CLUSTER:
108 rgblight_mode(29);
109 break;
110 case GAMING:
111 rgblight_mode(26);
112 break;
113 case SQLMACROS:
114 rgblight_mode(1);
115 rgblight_setrgb(0x00, 0xFF, 0x80);
116 break;
117 case SQLNAMES:
118 rgblight_mode(1);
119 rgblight_setrgb(0x80, 0xFF, 0x00);
120 break;
121 case FN_LAYER:
122 rgblight_mode(1);
123 rgblight_setrgb(0x00, 0x80, 0xFF);
124 break;
125 }
126 return state;
127}
128
129bool containsCode(uint16_t kc)
130{
131 for (int i = 0; i < macroTapsLen && macroTaps[i] > 0; i++)
132 {
133 if (macroTaps[i] == kc) return true;
134 }
135 return false;
136}
137
138bool lastCodeIs(uint16_t kc)
139{
140 for (int i = 0; i < macroTapsLen-1 && macroTaps[i] > 0; i++)
141 {
142 if (macroTaps[i] == kc && macroTaps[i+1] == 0) return true;
143 }
144 return false;
145}
146
147bool last2CodeAre(uint16_t kc)
148{
149 for (int i = 0; i < macroTapsLen-2 && macroTaps[i] > 0; i++)
150 {
151 if (macroTaps[i] == kc && macroTaps[i+1] == kc && macroTaps[i+2] == 0) return true;
152 }
153 return false;
154}
155
156bool last2CodesAre(uint16_t kc, uint16_t kc2)
157{
158 for (int i = 0; i < macroTapsLen-2 && macroTaps[i] > 0; i++)
159 {
160 if (macroTaps[i] == kc && macroTaps[i+1] == kc2 && macroTaps[i+2] == 0) return true;
161 }
162 return false;
163}
164
165void addKeyCode(uint16_t kc)
166{
167 int i = 0;
168 while (i < macroTapsLen-2 && macroTaps[i] > 0) i++;
169 if (macroTaps[i] == 0)
170 {
171 macroTaps[i] = kc;
172 macroTaps[i+1] = 0;
173 }
174}
175
176void eraseKeyCodes(void)
177{
178 int i = 0;
179 while (i < macroTapsLen && macroTaps[i] > 0) macroTaps[i++] = 0;
180}
181
182void eraseCharCounts(void)
183{
184 int i = 0;
185 while (i < charCountLen)
186 {
187 charCount[i] = 0;
188 }
189}
190
191void printTableAbbreviation(void)
192{
193 initStringData();
194 if (tableNameList[0] == 0)
195 {
196 return;
197 }
198 send_char(0x20);
199 int i = 0;
200 for (i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
201 {
202 if (tableNameList[i] >= 65 && tableNameList[i] <= 90)
203 {
204 send_char(tableNameList[i]+32);
205 }
206 else
207 {
208 send_char(tableNameList[i]);
209 }
210 }
211 send_char(0x20);
212}
213
214void eraseTableAbbreviation(void)
215{
216 initStringData();
217 for (int i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
218 {
219 tableNameList[i] = '\0';
220 }
221}
222
223void printString(char* str)
224{
225
226 if (str[0] != '\0')
227 {
228 int i = 0;
229 while (true)
230 {
231 if (str[i] == 0)
232 {
233 break;
234 }
235 send_char(str[i++]);
236 charCount[countPointer]++;
237 }
238 }
239}
240
241void printStringAndQueueChar(char* str)
242{
243 initStringData();
244 if (charCount[countPointer] != 0)
245 {
246 countPointer++;
247 }
248 sendAbbr = true;
249 if (str[0] != '\0')
250 {
251 printString(str);
252
253 for (int i = 0; i < tableNameListLen-1; i++)
254 {
255 if (tableNameList[i] == '\0')
256 {
257 tableNameList[i] = str[0];
258 tableNameList[i+1] = '\0';
259 break;
260 }
261 else if (i == tableNameListLen-2)
262 {
263 printTableAbbreviation();
264 break;
265 }
266 }
267 //for (i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
268 //{
269 // send_char(tableNameList[i]);
270 //}
271 //send_string_P("Darden");
272 //send_string_P(&myarray);
273 //send_string_P(str);
274 }
275}
276
277void ReplaceString(char *orig, char *repl)
278{
279 int i = 0;
280 while((orig[i] != 0x0 && repl[i] != 0x0) && orig[i] == repl[i])
281 i++;
282
283 if(orig[i] != 0x0)
284 {
285 int o = i;
286 while (orig[o++] != 0x0) {
287 charCount[countPointer]--;
288 register_code(KC_BSPC);
289 unregister_code(KC_BSPC);
290 }
291 }
292 printString(repl+i);
293}
294
295void deletePrev(void)
296{
297 for (int i = 0; i < charCount[countPointer]; i++)
298 {
299 register_code(KC_BSPC);
300 unregister_code(KC_BSPC);
301 }
302 charCount[countPointer] = 0;
303 countPointer--;
304 int i = 1;
305 for (;i < tableNameListLen-1; i++)
306 {
307 if (tableNameList[i] == 0x0)
308 {
309 break;
310 }
311 }
312 tableNameList[i-1] = 0x0;
313}
314
315void processSmartMacroTap(uint16_t kc)
316{
317 initStringData();
318 switch(kc)
319 {
320 case TD_C:
321 if (containsCode(TD_D))
322 {
323 printString("ribution");
324 printStringAndQueueChar("Center");
325 }
326 else if (last2CodeAre(TD_C))
327 {
328 ReplaceString("Corporation", "Contact");
329 }
330 else if(lastCodeIs(TD_C))
331 {
332 printString("oration");
333 }
334 else
335 {
336 printStringAndQueueChar("Corp");
337 }
338 break;
339 case TD_D:
340 if (last2CodeAre(TD_D))
341 {
342 ReplaceString("Distribution", "Distributor");
343 }
344 else if(lastCodeIs(TD_D))
345 {
346 printString("ribution");
347 }
348 else
349 {
350 printStringAndQueueChar("Dist");
351 }
352 break;
353 case TD_G:
354 printStringAndQueueChar("Global");
355 printStringAndQueueChar("Lookup");
356 break;
357 case TD_I:
358 if (containsCode(TD_W))
359 printStringAndQueueChar("Instance");
360 else
361 printStringAndQueueChar("Item");
362 break;
363 case TD_N:
364 printStringAndQueueChar("NadRate");
365 break;
366 case TD_P:
367 if (last2CodesAre(TD_D, TD_C))
368 {
369 ReplaceString("DistributionCenter", "DistCenter");
370 printStringAndQueueChar("Pricing");
371 }
372 else if (last2CodeAre(TD_P))
373 {
374 }
375 else if(lastCodeIs(TD_P))
376 {
377 ReplaceString("Product", "Person");
378 }
379 else
380 {
381 printStringAndQueueChar("Product");
382 }
383 break;
384 case TD_Q:
385 printStringAndQueueChar("Darden");
386 break;
387 case TD_S:
388 if (containsCode(TD_W))
389 if (containsCode(TD_S) || containsCode(TD_D))
390 printStringAndQueueChar("Step");
391 else
392 printStringAndQueueChar("Session");
393 else
394 printStringAndQueueChar("Supplier");
395 break;
396 case TD_T:
397 if (containsCode(TD_W))
398 printStringAndQueueChar("Task");
399 else
400 printStringAndQueueChar("Type");
401 break;
402 case TD_W:
403 printStringAndQueueChar("Workflow");
404 break;
405 }
406 addKeyCode(kc);
407}
408
409bool process_record_user(uint16_t keycode, keyrecord_t *record)
410{
411 if (record->event.pressed)
412 {
413 switch (keycode)
414 {
415 case KC_LSPO:
416 case KC_RSPC:
417 shifted = true;
418 return true;
419
420 case S_LFTJN: SEND_STRING("LEFT JOIN"); return false;
421 case S_INRJN: SEND_STRING("INNER JOIN "); return false;
422 case S_SLCT: SEND_STRING("SELECT "); return false;
423 case S_FROM: SEND_STRING("FROM "); return false;
424 case S_DSNCT: SEND_STRING("DISTINCT "); return false;
425 case S_ORDER: SEND_STRING("ORDER "); return false;
426 case S_WHERE: SEND_STRING("WHERE "); return false;
427 case S_ALTER: SEND_STRING("ALTER SESSION SET CURRENT_SCHEMA = "); return false;
428 case S_ASTRK: SEND_STRING("* "); return false;
429
430 case KC_BSLS:
431 initStringData();
432 layer_on(SQLNAMES);
433 return false;
434
435 case TD_BSPC:
436 if (!shifted){
437 deletePrev();
438 }
439 else {
440 register_code(KC_BSPC);
441 unregister_code(KC_BSPC);
442 }
443 return false;
444
445 case TD_A:
446 case TD_B:
447 case TD_C:
448 case TD_D:
449 case TD_E:
450 case TD_F:
451 case TD_G:
452 case TD_H:
453 case TD_I:
454 case TD_J:
455 case TD_K:
456 case TD_L:
457 case TD_M:
458 case TD_N:
459 case TD_O:
460 case TD_P:
461 case TD_Q:
462 case TD_R:
463 case TD_S:
464 case TD_T:
465 case TD_U:
466 case TD_V:
467 case TD_W:
468 case TD_X:
469 case TD_Y:
470 case TD_Z:
471 processSmartMacroTap(keycode);
472 return false;
473
474 case TD_ENT:
475 printTableAbbreviation();
476 case TD_ESC:
477 eraseKeyCodes();
478 eraseTableAbbreviation();
479 layer_off(SQLNAMES);
480 return true;
481 }
482 }
483 else
484 {
485 switch (keycode)
486 {
487
488 case KC_BSLS:
489 if (macroTaps[0] == 0)
490 {
491 SEND_STRING("\\");
492 layer_off(SQLNAMES);
493 }
494 return true;
495 case KC_LSPO:
496 case KC_RSPC:
497 shifted = false;
498 return true;
499 }
500 }
501 return true;
502};
503 8
504const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 9const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
505 10
@@ -507,7 +12,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
507 LAYOUT_60_ansi( 12 LAYOUT_60_ansi(
508 ESCAP, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, MNUS, EQUL, BACKSPC, 13 ESCAP, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, MNUS, EQUL, BACKSPC,
509 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, LBRC, RBRC, BSLASH, 14 KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, LBRC, RBRC, BSLASH,
510 MO_FNLR, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, COLN, QUOT, ENTER_OR_SQL, 15 FN_QT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, COLN, QUOT, ENTER_OR_SQL,
511 LEFTSHFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, CMMA, PRRD, SLSH, RIGHT_SHIFT__PAREN, 16 LEFTSHFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, CMMA, PRRD, SLSH, RIGHT_SHIFT__PAREN,
512 CTLL, WINL, ALTL, SPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACE, ALTR, WINR, APPR, CTLR), 17 CTLL, WINL, ALTL, SPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACE, ALTR, WINR, APPR, CTLR),
513 18
@@ -531,23 +36,15 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
531 LAYOUT_60_ansi( 36 LAYOUT_60_ansi(
532 S_ALTER, ____, ____, ____, ____, ____, ____, ____, S_ASTRK, ____, ____, ____, ____, ___________, 37 S_ALTER, ____, ____, ____, ____, ____, ____, ____, S_ASTRK, ____, ____, ____, ____, ___________,
533 ______, ____, S_WHERE, ____, ____, ____, ____, ____, S_INRJN, S_ORDER, ____, ____, ____, ______, 38 ______, ____, S_WHERE, ____, ____, ____, ____, ____, S_INRJN, S_ORDER, ____, ____, ____, ______,
534 _______, KC_LBRC, S_SLCT, KC_PAST,S_FROM, ____, ____, ____, ____, S_LFTJN, ____, RBRC, ___________, 39 _______, KC_LBRC, S_SLCT, S_ASTRK ,S_FROM, ____, ____, ____, ____, S_LFTJN, ____, RBRC, ___________,
535 ________, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, _________________, 40 ________, RGB_VAI, RGB_VAD, ____, ____, ____, ____, ____, ____, ____, ____, _________________,
536 ____, ____, ____, /*------------------*/_____/*------------------*/, ____, ____, ____, ____), 41 ____, ____, ____, /*------------------*/_____/*------------------*/, ____, ____, ____, ____),
537 42
538 [SQLNAMES]=
539 LAYOUT_60_ansi(
540 TD_ESC, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, TD_BSPC,
541 ________, TD_Q, TD_W, TD_E, TD_R, TD_T, TD_Y, TD_U, TD_I, TD_O, TD_P, ____, ____, _____,
542 ___________, TD_A, TD_S, TD_D, TD_F, TD_G, TD_H, TD_J, TD_K, TD_L, ____, ____, TD_ENT,
543 ___________, TD_Z, TD_X, TD_C, TD_V, TD_B, TD_N, TD_M, ____, ____, ____, _________________,
544 ____, ____, ____, /*----------------------*/TD_ENT/*-----------------------*/, ____, ____, ____, RESET),
545
546 [FN_LAYER]= 43 [FN_LAYER]=
547 LAYOUT_60_ansi( 44 LAYOUT_60_ansi(
548 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, 45 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,
549 KC_CAPSLOCK, KC_MPRV, KC_MPLY, KC_MNXT, LWIN(KC_R), ____, KC_CALC, KC_PGUP, KC_UP, KC_PGDN, KC_PSCR, KC_SLCK, KC_BRK, ____, 46 KC_CAPSLOCK, KC_MPRV, KC_MPLY, KC_MNXT, LWIN(KC_R), ____, KC_CALC, KC_PGUP, KC_UP, KC_PGDN, KC_PSCR, KC_SLCK, KC_BRK, ____,
550 ____, KC_VOLD, KC_MUTE, KC_VOLU, ____, ____, KC_HOME, KC_LEFT, KC_DOWN, KC_RIGHT, KC_INS, KC_DEL, ____, 47 ____, KC_VOLD, KC_MUTE, KC_VOLU, ____, ____, KC_HOME, KC_LEFT, KC_DOWN, KC_RIGHT, KC_INS, KC_DEL, ____,
551 ____, ____, ____, ____, ____, ____, KC_END, ____, QWRTY, NAVS, GAME, ____, 48 ____, RGB_HUI, RGB_SAI, RGB_SAD, ____, ____, KC_END, QWRTY, GAME, NAVS, ____, ____,
552 ____, ____, ____, _________________, ____, KC_HYPR, KC_MEH, ____) 49 ____, ____, ____, _________________, ____, KC_HYPR, KC_MEH, RESET)
553}; 50};
diff --git a/keyboards/dz60/keymaps/marianas/keymap.h b/keyboards/dz60/keymaps/marianas/keymap.h
index 00e51cea2..bb1ea68c7 100644
--- a/keyboards/dz60/keymaps/marianas/keymap.h
+++ b/keyboards/dz60/keymaps/marianas/keymap.h
@@ -1,105 +1,15 @@
1#include "quantum.h" 1#include QMK_KEYBOARD_H
2 2
3//Control
4#define MO_FNLR MO(FN_LAYER)
5#define BACKSPC KC_BSPC
6#define ENTER_OR_SQL LT(SQLMACROS,KC_ENT)
7#define ESCAP KC_ESC
8#define PSCR KC_PSCREEN
9#define SCRL KC_SCROLLLOCK
10#define PAUS KC_PAUSE
11#define NSRT KC_INSERT
12#define HOME KC_HOME
13#define PGUP KC_PGUP
14#define PGDN KC_PGDN
15#define END_ KC_END
16#define DELT KC_DELETE
17#define UPUP KC_UP
18#define D_WN KC_DOWN
19#define LEFT KC_LEFT
20#define RGHT KC_RIGHT
21 3
22//KEYPAD 4enum marianas_layers {
23#define KP_1 KC_KP_1 5 QWERTY,
24#define KP_2 KC_KP_2 6/*
25#define KP_3 KC_KP_3 7 COLEMAK,
26#define KP_4 KC_KP_4 8 DVORAK,
27#define KP_5 KC_KP_5 9*/
28#define KP_6 KC_KP_6 10 NAV_CLUSTER,
29#define KP_7 KC_KP_7 11 GAMING,
30#define KP_8 KC_KP_8 12 SQLMACROS,
31#define KP_9 KC_KP_9 13 FN_LAYER
32#define KP_0 KC_KP_0 14};
33#define NMLK KC_NUMLOCK
34#define STAR KC_KP_ASTERISK
35#define KSSH KC_KP_SLASH
36#define KMIN KC_KP_MINUS
37#define PLUS KC_KP_PLUS
38#define KNTR KC_KP_ENTER
39#define KDOT KC_KP_DOT
40 15
41//Modifiers
42#define CTLL KC_LCTL
43#define LEFTSHFT KC_LSPO
44#define WINL KC_LGUI
45#define ALTL KC_LALT
46#define CTLR KC_RCTL
47#define RIGHT_SHIFT__PAREN KC_RSPC
48#define WINR KC_RGUI
49#define ALTR KC_RALT
50#define APPR KC_APP
51
52
53//Punctuation
54#define CMMA KC_COMM
55#define PRRD KC_DOT
56#define SLSH KC_SLSH
57#define QUOT KC_QUOT
58#define COLN KC_SCLN
59#define LBRC KC_LBRC
60#define RBRC KC_RBRC
61#define EQUL KC_EQL
62#define MNUS KC_MINS
63#define BSLASH KC_BSLS
64
65//Layers
66#define QWRTY TO(QWERTY)
67#define NAVS TO(NAV_CLUSTER)
68#define GAME TO(GAMING)
69
70//Space
71#define ____ KC_TRNS
72#define _____ KC_TRNS
73#define ______ KC_TRNS
74#define _______ KC_TRNS
75#define ________ KC_TRNS
76#define ___________ KC_TRNS
77#define _________________ KC_TRNS
78#define SPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACE KC_SPC
79#define KCNO KC_NO
80
81
82
83
84
85#define macroTapsLen 32
86#define tableNameListLen 32
87#define charCountLen 32
88
89void initStringData(void);
90uint32_t layer_state_set_user(uint32_t state);
91bool containsCode(uint16_t kc);
92bool lastCodeIs(uint16_t kc);
93bool last2CodeAre(uint16_t kc);
94bool last2CodesAre(uint16_t kc, uint16_t kc2);
95void addKeyCode(uint16_t kc);
96void eraseKeyCodes(void);
97void eraseCharCounts(void);
98void printTableAbbreviation(void);
99void eraseTableAbbreviation(void);
100void printString(char* str);
101void printStringAndQueueChar(char* str);
102void ReplaceString(char *orig, char *repl);
103void deletePrev(void);
104void processSmartMacroTap(uint16_t kc);
105bool process_record_user(uint16_t keycode, keyrecord_t *record);
diff --git a/keyboards/dz60/keymaps/marianas/relativity.c b/keyboards/dz60/keymaps/marianas/relativity.c
new file mode 100644
index 000000000..96a5eb4e6
--- /dev/null
+++ b/keyboards/dz60/keymaps/marianas/relativity.c
@@ -0,0 +1,510 @@
1#include "relativity.h"
2#include "keymap.h"
3#include "keyDefinitions.h"
4
5
6uint16_t *macroTaps = 0;
7
8char *tableNameList = 0;
9
10uint8_t *charCount = 0;
11uint8_t countPointer = 0;
12
13bool relativityActive = false;
14
15
16bool sendAbbr = false;
17
18
19static int16_t relativityTimer = 0;
20
21
22bool tempOff = false;
23
24
25
26
27void initStringData()
28{
29 if (macroTaps == 0)
30 {
31 macroTaps = malloc(macroTapsLen*sizeof(uint16_t));
32 for(int i = 0; i < macroTapsLen; i++)
33 {
34 macroTaps[i] = 0;
35 }
36 }
37 if (tableNameList == 0)
38 {
39 tableNameList = malloc(tableNameListLen*sizeof(char));
40 for(int i = 0; i < tableNameListLen; i++)
41 {
42 tableNameList[i] = 0;
43 }
44 }
45 if (charCount == 0)
46 {
47 charCount = malloc(charCountLen*sizeof(uint8_t));
48 for (int i = 0; i < charCountLen; i++)
49 {
50 charCount[i] = 0;
51 }
52 }
53}
54
55void activateRelativity(void)
56{
57 initStringData();
58 rgblight_mode(RGBLIGHT_MODE_KNIGHT);
59 relativityTimer = timer_read();
60 relativityActive = true;
61}
62
63bool deactivateRelativity(void)
64{
65 rgblight_mode(9);
66 eraseKeyCodes();
67 eraseTableAbbreviation();
68 eraseCharCounts();
69 relativityActive = false;
70 tempOff = false;
71 return false;
72}
73
74bool containsCode(uint16_t kc)
75{
76 for (int i = 0; i < macroTapsLen && macroTaps[i] > 0; i++)
77 {
78 if (macroTaps[i] == kc) return true;
79 }
80 return false;
81}
82
83bool lastCodeIs(uint16_t kc)
84{
85 for (int i = 0; i < macroTapsLen-1 && macroTaps[i] > 0; i++)
86 {
87 if (macroTaps[i] == kc && macroTaps[i+1] == 0) return true;
88 }
89 return false;
90}
91
92bool last2CodeAre(uint16_t kc)
93{
94 for (int i = 0; i < macroTapsLen-2 && macroTaps[i] > 0; i++)
95 {
96 if (macroTaps[i] == kc && macroTaps[i+1] == kc && macroTaps[i+2] == 0) return true;
97 }
98 return false;
99}
100
101bool last2CodesAre(uint16_t kc, uint16_t kc2)
102{
103 for (int i = 0; i < macroTapsLen-2 && macroTaps[i] > 0; i++)
104 {
105 if (macroTaps[i] == kc && macroTaps[i+1] == kc2 && macroTaps[i+2] == 0) return true;
106 }
107 return false;
108}
109
110void addKeyCode(uint16_t kc)
111{
112 int i = 0;
113 while (i < macroTapsLen-2 && macroTaps[i] > 0) i++;
114 if (macroTaps[i] == 0)
115 {
116 macroTaps[i] = kc;
117 macroTaps[i+1] = 0;
118 }
119}
120
121void eraseKeyCodes(void)
122{
123 int i = 0;
124 while (i < macroTapsLen && macroTaps[i] > 0) macroTaps[i++] = 0;
125}
126
127void eraseCharCounts(void)
128{
129 while (countPointer > 0)
130 {
131 charCount[countPointer] = 0;
132 countPointer--;
133 }
134 charCount[countPointer] = 0;
135}
136
137void printTableAbbreviationLimited(void)
138{
139 if (tableNameList[0] == 0)
140 {
141 return;
142 }
143 int i = 0;
144 for (i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
145 {
146 if (tableNameList[i] >= 65 && tableNameList[i] <= 90)
147 {
148 send_char(tableNameList[i]+32);
149 }
150 else
151 {
152 send_char(tableNameList[i]);
153 }
154 }
155}
156
157void printTableAbbreviation(void)
158{
159 if (tableNameList[0] == 0)
160 {
161 return;
162 }
163 send_char(0x20);
164 int i = 0;
165 for (i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
166 {
167 if (tableNameList[i] >= 65 && tableNameList[i] <= 90)
168 {
169 send_char(tableNameList[i]+32);
170 }
171 else
172 {
173 send_char(tableNameList[i]);
174 }
175 }
176 send_char(0x20);
177}
178
179void eraseTableAbbreviation(void)
180{
181 for (int i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
182 {
183 tableNameList[i] = '\0';
184 }
185}
186
187void printString(char* str)
188{
189
190 if (str[0] != '\0')
191 {
192 int i = 0;
193 while (true)
194 {
195 if (str[i] == 0)
196 {
197 break;
198 }
199 send_char(str[i++]);
200 charCount[countPointer]++;
201 }
202 }
203}
204
205void printStringAndQueueChar(char* str)
206{
207 if (charCount[countPointer] > 0 && countPointer < charCountLen)
208 {
209 countPointer++;
210 }
211 sendAbbr = true;
212 if (str[0] != '\0')
213 {
214 printString(str);
215
216 for (int i = 0; i < tableNameListLen-1; i++)
217 {
218 if (tableNameList[i] == '\0')
219 {
220 tableNameList[i] = str[0];
221 tableNameList[i+1] = '\0';
222 break;
223 }
224 else if (i == tableNameListLen-2)
225 {
226 printTableAbbreviation();
227 break;
228 }
229 }
230 //for (i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
231 //{
232 // send_char(tableNameList[i]);
233 //}
234 //send_string_P("Darden");
235 //send_string_P(&myarray);
236 //send_string_P(str);
237 }
238}
239
240void ReplaceString(char *orig, char *repl)
241{
242 int i = 0;
243 while((orig[i] != 0x0 && repl[i] != 0x0) && orig[i] == repl[i])
244 i++;
245
246 if(orig[i] != 0x0)
247 {
248 int o = i;
249 while (orig[o++] != 0x0) {
250 charCount[countPointer]--;
251 register_code(KC_BSPC);
252 unregister_code(KC_BSPC);
253 }
254 }
255 printString(repl+i);
256}
257
258void deletePrev(void)
259{
260 if (countPointer == 0 && charCount[countPointer] == 0)
261 return;
262 for (int i = 0; i < charCount[countPointer]; i++)
263 {
264 register_code(KC_BSPC);
265 unregister_code(KC_BSPC);
266 }
267 charCount[countPointer] = 0;
268 int i = 1;
269 for (;i < tableNameListLen-1; i++)
270 {
271 if (tableNameList[i] == 0x0)
272 {
273 break;
274 }
275 }
276 tableNameList[i-1] = 0x0;
277 if (countPointer > 0)
278 {
279 countPointer--;
280 }
281}
282
283bool processSmartMacroTap(uint16_t kc)
284{
285 if (relativityTimer > 0 && TIMER_DIFF_16(timer_read(), relativityTimer) >= relTimeout)
286 {
287 deactivateRelativity();
288 return true;
289 }
290 relativityTimer = 0;
291 switch(kc)
292 {
293 case KC_C:
294 if (containsCode(KC_D))
295 {
296 printString("ribution");
297 printStringAndQueueChar("Center");
298 }
299 else if (last2CodeAre(KC_C))
300 {
301 ReplaceString("Corporation", "Contact");
302 }
303 else if(lastCodeIs(KC_C))
304 {
305 printString("oration");
306 }
307 else
308 {
309 printStringAndQueueChar("Corp");
310 }
311 break;
312 case KC_D:
313 if (last2CodeAre(KC_D))
314 {
315 ReplaceString("Distribution", "Distributor");
316 }
317 else if(lastCodeIs(KC_D))
318 {
319 printString("ribution");
320 }
321 else
322 {
323 printStringAndQueueChar("Dist");
324 }
325 break;
326 case KC_G:
327 printStringAndQueueChar("Global");
328 printStringAndQueueChar("Lookup");
329 break;
330 case KC_I:
331 if (containsCode(KC_W))
332 printStringAndQueueChar("Instance");
333 else
334 printStringAndQueueChar("Item");
335 break;
336 case KC_N:
337 printStringAndQueueChar("NadRate");
338 break;
339 case KC_P:
340 if (last2CodesAre(KC_D, KC_C))
341 {
342 ReplaceString("DistributionCenter", "DistCenter");
343 printStringAndQueueChar("Pricing");
344 }
345 else if (last2CodeAre(KC_P))
346 {
347 }
348 else if(lastCodeIs(KC_P))
349 {
350 ReplaceString("Product", "Person");
351 }
352 else
353 {
354 printStringAndQueueChar("Product");
355 }
356 break;
357 case KC_Q:
358 printStringAndQueueChar("Darden");
359 break;
360 case KC_S:
361 if (containsCode(KC_W))
362 if (containsCode(KC_S) || containsCode(KC_D))
363 printStringAndQueueChar("Step");
364 else
365 printStringAndQueueChar("Session");
366 else
367 printStringAndQueueChar("Supplier");
368 break;
369 case KC_T:
370 if (containsCode(KC_W))
371 printStringAndQueueChar("Task");
372 else
373 printStringAndQueueChar("Type");
374 break;
375 case KC_W:
376 printStringAndQueueChar("Workflow");
377 break;
378 }
379 addKeyCode(kc);
380 return false;
381}
382
383
384bool shifted = false;
385bool isShifted()
386{
387 return shifted;
388}
389
390void setShifted(bool val)
391{
392 shifted = val;
393}
394
395
396bool storeShiftState(uint16_t keycode, keyrecord_t *record)
397{
398
399 if (record->event.pressed)
400 {
401 switch (keycode)
402 {
403 case KC_LSPO:
404 case KC_RSPC:
405 shifted = true;
406 }
407 }
408 else
409 {
410 switch (keycode)
411 {
412
413 case KC_LSPO:
414 case KC_RSPC:
415 shifted = false;
416 return true;
417 }
418 }
419 return true;
420}
421
422bool handleSmartMacros(uint16_t keycode, keyrecord_t *record)
423{
424 if (relativityActive != true) return true;
425 if (record->event.pressed)
426 {
427 switch (keycode)
428 {
429 case KC_BSPC:
430 if (!isShifted()){
431 deletePrev();
432 }
433 else {
434 register_code(KC_BSPC);
435 unregister_code(KC_BSPC);
436 }
437 return false;
438 case KC_A:
439 case KC_B:
440 case KC_C:
441 case KC_D:
442 case KC_E:
443 case KC_F:
444 case KC_G:
445 case KC_H:
446 case KC_I:
447 case KC_J:
448 case KC_K:
449 case KC_L:
450 case KC_M:
451 case KC_N:
452 case KC_O:
453 case KC_P:
454 case KC_Q:
455 case KC_R:
456 case KC_S:
457 case KC_T:
458 case KC_U:
459 case KC_V:
460 case KC_W:
461 case KC_X:
462 case KC_Y:
463 case KC_Z:
464 return processSmartMacroTap(keycode);
465
466 case PRRD:
467 if (tempOff)
468 {
469 SEND_STRING("Id = ");
470 printTableAbbreviationLimited();
471 SEND_STRING(".Id");
472 return deactivateRelativity();
473 }
474 else
475 {
476 printTableAbbreviation();
477 SEND_STRING("ON ");
478 printTableAbbreviationLimited();
479 eraseKeyCodes();
480 eraseTableAbbreviation();
481 eraseCharCounts();
482 tempOff = true;
483 return true;
484 }
485
486
487 case KC_SPC:
488 printTableAbbreviation();
489 return deactivateRelativity();
490 case ENTER_OR_SQL:
491 if (tempOff)
492 {
493 SEND_STRING("Id = ");
494 printTableAbbreviationLimited();
495 SEND_STRING(".Id");
496 deactivateRelativity();
497 return true;
498 }
499 else
500 {
501 printTableAbbreviation();
502 deactivateRelativity();
503 return true;
504 }
505 case KC_ESC:
506 return deactivateRelativity();
507 }
508 }
509 return true;
510}
diff --git a/keyboards/dz60/keymaps/marianas/relativity.h b/keyboards/dz60/keymaps/marianas/relativity.h
new file mode 100644
index 000000000..c917b1a4d
--- /dev/null
+++ b/keyboards/dz60/keymaps/marianas/relativity.h
@@ -0,0 +1,32 @@
1#include QMK_KEYBOARD_H
2#define macroTapsLen 32
3#define tableNameListLen 32
4#define charCountLen 32
5
6#define relTimeout 1500
7
8
9void activateRelativity(void);
10bool deactivateRelativity(void);
11void initStringData(void);
12bool containsCode(uint16_t kc);
13bool lastCodeIs(uint16_t kc);
14bool last2CodeAre(uint16_t kc);
15bool last2CodesAre(uint16_t kc, uint16_t kc2);
16void addKeyCode(uint16_t kc);
17void eraseKeyCodes(void);
18void eraseCharCounts(void);
19void printTableAbbreviation(void);
20void eraseTableAbbreviation(void);
21void printString(char* str);
22void printStringAndQueueChar(char* str);
23void ReplaceString(char *orig, char *repl);
24void deletePrev(void);
25bool processSmartMacroTap(uint16_t kc);
26bool isShifted(void);
27void setShifted(bool);
28
29
30
31bool handleSmartMacros(uint16_t keycode, keyrecord_t *record);
32bool storeShiftState(uint16_t keycode, keyrecord_t *record);
diff --git a/keyboards/dz60/keymaps/marianas/rules.mk b/keyboards/dz60/keymaps/marianas/rules.mk
index ab188f3b2..230d194ab 100644
--- a/keyboards/dz60/keymaps/marianas/rules.mk
+++ b/keyboards/dz60/keymaps/marianas/rules.mk
@@ -15,3 +15,7 @@ AUDIO_ENABLE = no
15RGBLIGHT_ENABLE = yes 15RGBLIGHT_ENABLE = yes
16TAP_DANCE_ENABLE = no 16TAP_DANCE_ENABLE = no
17AUTO_SHIFT_ENABLE = no 17AUTO_SHIFT_ENABLE = no
18
19
20SRC += relativity.c
21SRC += customLogic.c