1 #include QMK_KEYBOARD_H
18 S_LFTJN = SAFE_RANGE, // L
30 TD_C, // Corp, Corporation, Company
31 TD_D, // Distribution, Dist, Distributor
36 TD_I, // Instance, Item
43 TD_P, // Product, Person,
46 TD_S, // Supplier, Step
59 uint16_t *macroTaps = 0;
61 char *tableNameList = 0;
63 uint8_t *charCount = 0;
64 uint8_t countPointer = 0;
68 bool sendAbbr = false;
71 void initStringData(void)
75 macroTaps = malloc(macroTapsLen*sizeof(uint16_t));
76 for(int i = 0; i < macroTapsLen; i++)
81 if (tableNameList == 0)
83 tableNameList = malloc(tableNameListLen*sizeof(char));
84 for(int i = 0; i < tableNameListLen; i++)
91 charCount = malloc(charCountLen*sizeof(uint8_t));
92 for (int i = 0; i < charCountLen; i++)
100 uint32_t layer_state_set_user(uint32_t state)
102 switch (biton32(state))
115 rgblight_setrgb(0x00, 0xFF, 0x80);
119 rgblight_setrgb(0x80, 0xFF, 0x00);
123 rgblight_setrgb(0x00, 0x80, 0xFF);
129 bool containsCode(uint16_t kc)
131 for (int i = 0; i < macroTapsLen && macroTaps[i] > 0; i++)
133 if (macroTaps[i] == kc) return true;
138 bool lastCodeIs(uint16_t kc)
140 for (int i = 0; i < macroTapsLen-1 && macroTaps[i] > 0; i++)
142 if (macroTaps[i] == kc && macroTaps[i+1] == 0) return true;
147 bool last2CodeAre(uint16_t kc)
149 for (int i = 0; i < macroTapsLen-2 && macroTaps[i] > 0; i++)
151 if (macroTaps[i] == kc && macroTaps[i+1] == kc && macroTaps[i+2] == 0) return true;
156 bool last2CodesAre(uint16_t kc, uint16_t kc2)
158 for (int i = 0; i < macroTapsLen-2 && macroTaps[i] > 0; i++)
160 if (macroTaps[i] == kc && macroTaps[i+1] == kc2 && macroTaps[i+2] == 0) return true;
165 void addKeyCode(uint16_t kc)
168 while (i < macroTapsLen-2 && macroTaps[i] > 0) i++;
169 if (macroTaps[i] == 0)
176 void eraseKeyCodes(void)
179 while (i < macroTapsLen && macroTaps[i] > 0) macroTaps[i++] = 0;
182 void eraseCharCounts(void)
185 while (i < charCountLen)
191 void printTableAbbreviation(void)
194 if (tableNameList[0] == 0)
200 for (i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
202 if (tableNameList[i] >= 65 && tableNameList[i] <= 90)
204 send_char(tableNameList[i]+32);
208 send_char(tableNameList[i]);
214 void eraseTableAbbreviation(void)
217 for (int i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
219 tableNameList[i] = '\0';
223 void printString(char* str)
236 charCount[countPointer]++;
241 void printStringAndQueueChar(char* str)
244 if (charCount[countPointer] != 0)
253 for (int i = 0; i < tableNameListLen-1; i++)
255 if (tableNameList[i] == '\0')
257 tableNameList[i] = str[0];
258 tableNameList[i+1] = '\0';
261 else if (i == tableNameListLen-2)
263 printTableAbbreviation();
267 //for (i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
269 // send_char(tableNameList[i]);
271 //send_string_P("Darden");
272 //send_string_P(&myarray);
273 //send_string_P(str);
277 void ReplaceString(char *orig, char *repl)
280 while((orig[i] != 0x0 && repl[i] != 0x0) && orig[i] == repl[i])
286 while (orig[o++] != 0x0) {
287 charCount[countPointer]--;
288 register_code(KC_BSPC);
289 unregister_code(KC_BSPC);
295 void deletePrev(void)
297 for (int i = 0; i < charCount[countPointer]; i++)
299 register_code(KC_BSPC);
300 unregister_code(KC_BSPC);
302 charCount[countPointer] = 0;
305 for (;i < tableNameListLen-1; i++)
307 if (tableNameList[i] == 0x0)
312 tableNameList[i-1] = 0x0;
315 void processSmartMacroTap(uint16_t kc)
321 if (containsCode(TD_D))
323 printString("ribution");
324 printStringAndQueueChar("Center");
326 else if (last2CodeAre(TD_C))
328 ReplaceString("Corporation", "Contact");
330 else if(lastCodeIs(TD_C))
332 printString("oration");
336 printStringAndQueueChar("Corp");
340 if (last2CodeAre(TD_D))
342 ReplaceString("Distribution", "Distributor");
344 else if(lastCodeIs(TD_D))
346 printString("ribution");
350 printStringAndQueueChar("Dist");
354 printStringAndQueueChar("Global");
355 printStringAndQueueChar("Lookup");
358 if (containsCode(TD_W))
359 printStringAndQueueChar("Instance");
361 printStringAndQueueChar("Item");
364 printStringAndQueueChar("NadRate");
367 if (last2CodesAre(TD_D, TD_C))
369 ReplaceString("DistributionCenter", "DistCenter");
370 printStringAndQueueChar("Pricing");
372 else if (last2CodeAre(TD_P))
375 else if(lastCodeIs(TD_P))
377 ReplaceString("Product", "Person");
381 printStringAndQueueChar("Product");
385 printStringAndQueueChar("Darden");
388 if (containsCode(TD_W))
389 if (containsCode(TD_S) || containsCode(TD_D))
390 printStringAndQueueChar("Step");
392 printStringAndQueueChar("Session");
394 printStringAndQueueChar("Supplier");
397 if (containsCode(TD_W))
398 printStringAndQueueChar("Task");
400 printStringAndQueueChar("Type");
403 printStringAndQueueChar("Workflow");
409 bool process_record_user(uint16_t keycode, keyrecord_t *record)
411 if (record->event.pressed)
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;
440 register_code(KC_BSPC);
441 unregister_code(KC_BSPC);
471 processSmartMacroTap(keycode);
475 printTableAbbreviation();
478 eraseTableAbbreviation();
489 if (macroTaps[0] == 0)
504 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
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,
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,
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,
511 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),
516 _____, PSCR, SCRL, PAUS, NSRT, HOME, PGUP, NMLK, KSSH, STAR, KMIN, ____, ____, ______,
517 ______, ____, ____, ____, DELT, END_, PGDN, KP_7, KP_8, KP_9, PLUS, ____, ____, _____,
518 _______, ____, ____, ____, ____, UPUP, UPUP, KP_4, KP_5, KP_6, PLUS, ____, ___________,
519 ________, ____, ____, ____, LEFT, D_WN, RGHT, KP_1, KP_2, KP_3, KNTR, _________________,
520 ____, ____, ____, /*-----------------*/KC_KP_0/*-----------------*/, KDOT, KNTR, ____, ____),
524 _____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ______,
525 ______, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, _____,
526 KCNO, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, ___________,
527 ________, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, _________________,
528 ____, KCNO, ____, /*------------------*/_____/*------------------*/, ____, KCNO, ____, QWRTY),
532 S_ALTER, ____, ____, ____, ____, ____, ____, ____, S_ASTRK, ____, ____, ____, ____, ___________,
533 ______, ____, S_WHERE, ____, ____, ____, ____, ____, S_INRJN, S_ORDER, ____, ____, ____, ______,
534 _______, KC_LBRC, S_SLCT, KC_PAST,S_FROM, ____, ____, ____, ____, S_LFTJN, ____, RBRC, ___________,
535 ________, ____, ____, ____, ____, ____, ____, ____, ____, ____, ____, _________________,
536 ____, ____, ____, /*------------------*/_____/*------------------*/, ____, ____, ____, ____),
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),
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,
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, ____,
550 ____, KC_VOLD, KC_MUTE, KC_VOLU, ____, ____, KC_HOME, KC_LEFT, KC_DOWN, KC_RIGHT, KC_INS, KC_DEL, ____,
551 ____, ____, ____, ____, ____, ____, KC_END, ____, QWRTY, NAVS, GAME, ____,
552 ____, ____, ____, _________________, ____, KC_HYPR, KC_MEH, ____)