separated all my changes into separate files, working on generalizing my relativity macros. (#4368)
* Updating to my local changes. * Added auto-complete for joins. * Added lights to imply current state betterunorthodox
parent
f8d8005835
commit
8f5ac39fb9
@ -0,0 +1,138 @@ |
|||||||
|
#include QMK_KEYBOARD_H |
||||||
|
#include "customLogic.h" |
||||||
|
#include "keymap.h" |
||||||
|
#include "keyDefinitions.h" |
||||||
|
#include "relativity.h" |
||||||
|
#include "timer.h" |
||||||
|
|
||||||
|
static int16_t fnTimer = 0; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
uint32_t layer_state_set_user(uint32_t state) |
||||||
|
{ |
||||||
|
switch (biton32(state)) |
||||||
|
{ |
||||||
|
case QWERTY: |
||||||
|
rgblight_mode(9); |
||||||
|
break; |
||||||
|
case NAV_CLUSTER: |
||||||
|
rgblight_mode(29); |
||||||
|
break; |
||||||
|
case GAMING: |
||||||
|
rgblight_mode(26); |
||||||
|
break; |
||||||
|
case SQLMACROS: |
||||||
|
rgblight_mode(1); |
||||||
|
break; |
||||||
|
case FN_LAYER: |
||||||
|
rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL+5); |
||||||
|
break; |
||||||
|
} |
||||||
|
return state; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool printSqlVerbs(uint16_t keycode, keyrecord_t *record) |
||||||
|
{ |
||||||
|
if (record->event.pressed) |
||||||
|
{ |
||||||
|
switch (keycode) |
||||||
|
{ |
||||||
|
case S_LFTJN:
|
||||||
|
SEND_STRING("LEFT JOIN");
|
||||||
|
activateRelativity(); |
||||||
|
return false; |
||||||
|
case S_INRJN:
|
||||||
|
SEND_STRING("INNER JOIN ");
|
||||||
|
activateRelativity(); |
||||||
|
return false; |
||||||
|
case S_SLCT:
|
||||||
|
SEND_STRING("SELECT "); return
|
||||||
|
false; |
||||||
|
case S_FROM:
|
||||||
|
SEND_STRING("FROM "); return
|
||||||
|
false; |
||||||
|
case S_DSNCT:
|
||||||
|
SEND_STRING("DISTINCT "); return
|
||||||
|
false; |
||||||
|
case S_ORDER:
|
||||||
|
SEND_STRING("ORDER BY "); return
|
||||||
|
false; |
||||||
|
case S_WHERE:
|
||||||
|
SEND_STRING("WHERE "); return
|
||||||
|
false; |
||||||
|
case S_ALTER:
|
||||||
|
SEND_STRING("ALTER SESSION SET CURRENT_SCHEMA = SUPPLY;"); return false; |
||||||
|
case S_ASTRK:
|
||||||
|
SEND_STRING("* "); return false; |
||||||
|
|
||||||
|
} |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
bool isFn = false; |
||||||
|
bool didFn = false; |
||||||
|
|
||||||
|
|
||||||
|
bool updateLayerState(uint16_t keycode, keyrecord_t *record) |
||||||
|
{ |
||||||
|
|
||||||
|
if (record->event.pressed) |
||||||
|
{ |
||||||
|
switch (keycode) |
||||||
|
{ |
||||||
|
case FN_QT: |
||||||
|
fnTimer = timer_read(); |
||||||
|
layer_on(FN_LAYER); |
||||||
|
isFn = true; |
||||||
|
return false; |
||||||
|
} |
||||||
|
if (isFn) |
||||||
|
{ |
||||||
|
didFn = true; |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
switch(keycode) |
||||||
|
{ |
||||||
|
case FN_QT: |
||||||
|
layer_off(FN_LAYER); |
||||||
|
if (!didFn) |
||||||
|
{ |
||||||
|
#if fnTimeout |
||||||
|
if (TIMER_DIFF_16(timer_read(), fnTimer) <= fnTimeout) |
||||||
|
{ |
||||||
|
activateRelativity(); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
deactivateRelativity(); |
||||||
|
} |
||||||
|
#else |
||||||
|
activateRelativity(); |
||||||
|
#endif |
||||||
|
} |
||||||
|
didFn = false; |
||||||
|
isFn = false; |
||||||
|
return false; |
||||||
|
} |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) |
||||||
|
{ |
||||||
|
return |
||||||
|
storeShiftState(keycode, record) && |
||||||
|
printSqlVerbs(keycode, record) && |
||||||
|
updateLayerState(keycode, record) && |
||||||
|
handleSmartMacros(keycode, record); |
||||||
|
} |
@ -0,0 +1,10 @@ |
|||||||
|
#define fnTimeout 500 |
||||||
|
|
||||||
|
|
||||||
|
uint32_t layer_state_set_user(uint32_t state); |
||||||
|
|
||||||
|
bool printSqlVerbs(uint16_t keycode, keyrecord_t *record); |
||||||
|
|
||||||
|
bool updateLayerState(uint16_t keycode, keyrecord_t *record); |
||||||
|
|
||||||
|
bool process_record_user(uint16_t keycode, keyrecord_t *record); |
@ -0,0 +1,124 @@ |
|||||||
|
|
||||||
|
//Control
|
||||||
|
#define MO_FNLR MO(FN_LAYER) |
||||||
|
#define BACKSPC KC_BSPC |
||||||
|
#define ENTER_OR_SQL LT(SQLMACROS,KC_ENT) |
||||||
|
#define ESCAP KC_ESC |
||||||
|
#define PSCR KC_PSCREEN |
||||||
|
#define SCRL KC_SCROLLLOCK |
||||||
|
#define PAUS KC_PAUSE |
||||||
|
#define NSRT KC_INSERT |
||||||
|
#define HOME KC_HOME |
||||||
|
#define PGUP KC_PGUP |
||||||
|
#define PGDN KC_PGDN |
||||||
|
#define END_ KC_END |
||||||
|
#define DELT KC_DELETE |
||||||
|
#define UPUP KC_UP |
||||||
|
#define D_WN KC_DOWN |
||||||
|
#define LEFT KC_LEFT |
||||||
|
#define RGHT KC_RIGHT |
||||||
|
|
||||||
|
//KEYPAD
|
||||||
|
#define KP_1 KC_KP_1 |
||||||
|
#define KP_2 KC_KP_2 |
||||||
|
#define KP_3 KC_KP_3 |
||||||
|
#define KP_4 KC_KP_4 |
||||||
|
#define KP_5 KC_KP_5 |
||||||
|
#define KP_6 KC_KP_6 |
||||||
|
#define KP_7 KC_KP_7 |
||||||
|
#define KP_8 KC_KP_8 |
||||||
|
#define KP_9 KC_KP_9 |
||||||
|
#define KP_0 KC_KP_0 |
||||||
|
#define NMLK KC_NUMLOCK |
||||||
|
#define STAR KC_KP_ASTERISK |
||||||
|
#define KSSH KC_KP_SLASH |
||||||
|
#define KMIN KC_KP_MINUS |
||||||
|
#define PLUS KC_KP_PLUS |
||||||
|
#define KNTR KC_KP_ENTER |
||||||
|
#define KDOT KC_KP_DOT |
||||||
|
|
||||||
|
//Modifiers
|
||||||
|
#define CTLL KC_LCTL |
||||||
|
#define LEFTSHFT KC_LSPO |
||||||
|
#define WINL KC_LGUI |
||||||
|
#define ALTL KC_LALT |
||||||
|
#define CTLR KC_RCTL |
||||||
|
#define RIGHT_SHIFT__PAREN KC_RSPC |
||||||
|
#define WINR KC_RGUI |
||||||
|
#define ALTR KC_RALT |
||||||
|
#define APPR KC_APP |
||||||
|
|
||||||
|
|
||||||
|
//Punctuation
|
||||||
|
#define CMMA KC_COMM |
||||||
|
#define PRRD KC_DOT |
||||||
|
#define SLSH KC_SLSH |
||||||
|
#define QUOT KC_QUOT |
||||||
|
#define COLN KC_SCLN |
||||||
|
#define LBRC KC_LBRC |
||||||
|
#define RBRC KC_RBRC |
||||||
|
#define EQUL KC_EQL |
||||||
|
#define MNUS KC_MINS |
||||||
|
#define BSLASH KC_BSLS |
||||||
|
|
||||||
|
//Layers
|
||||||
|
#define QWRTY TO(QWERTY) |
||||||
|
#define NAVS TO(NAV_CLUSTER) |
||||||
|
#define GAME TO(GAMING) |
||||||
|
|
||||||
|
//Space
|
||||||
|
#define ____ KC_TRNS |
||||||
|
#define _____ KC_TRNS |
||||||
|
#define ______ KC_TRNS |
||||||
|
#define _______ KC_TRNS |
||||||
|
#define ________ KC_TRNS |
||||||
|
#define ___________ KC_TRNS |
||||||
|
#define _________________ KC_TRNS |
||||||
|
#define SPAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACE KC_SPC |
||||||
|
#define KCNO KC_NO |
||||||
|
|
||||||
|
enum sql_macros { |
||||||
|
S_LFTJN = SAFE_RANGE, // L
|
||||||
|
S_INRJN, // I
|
||||||
|
S_SLCT, // S
|
||||||
|
S_FROM, // F
|
||||||
|
S_DSNCT, // D
|
||||||
|
S_ORDER, // O
|
||||||
|
S_WHERE, // W
|
||||||
|
S_ALTER, // Esc
|
||||||
|
S_ASTRK, // *
|
||||||
|
|
||||||
|
TD_A, |
||||||
|
TD_B, |
||||||
|
TD_C, // Corp, Corporation, Company
|
||||||
|
TD_D, // Distribution, Dist, Distributor
|
||||||
|
TD_E, |
||||||
|
TD_F, |
||||||
|
TD_G, // GlobalLookup
|
||||||
|
TD_H, |
||||||
|
TD_I, // Instance, Item
|
||||||
|
TD_J, |
||||||
|
TD_K, |
||||||
|
TD_L, |
||||||
|
TD_M, |
||||||
|
TD_N, // NadRate
|
||||||
|
TD_O, |
||||||
|
TD_P, // Product, Person,
|
||||||
|
TD_Q, // Darden
|
||||||
|
TD_R, |
||||||
|
TD_S, // Supplier, Step
|
||||||
|
TD_T, // Task, Type
|
||||||
|
TD_U, |
||||||
|
TD_V, |
||||||
|
TD_W, // Workflow,
|
||||||
|
TD_X, |
||||||
|
TD_Y, |
||||||
|
TD_Z, |
||||||
|
TD_BSPC, |
||||||
|
TD_ENT, |
||||||
|
TD_ESC, |
||||||
|
|
||||||
|
FN_QT |
||||||
|
}; |
||||||
|
|
||||||
|
bool isShifted(void); |
@ -0,0 +1,510 @@ |
|||||||
|
#include "relativity.h" |
||||||
|
#include "keymap.h" |
||||||
|
#include "keyDefinitions.h" |
||||||
|
|
||||||
|
|
||||||
|
uint16_t *macroTaps = 0; |
||||||
|
|
||||||
|
char *tableNameList = 0; |
||||||
|
|
||||||
|
uint8_t *charCount = 0; |
||||||
|
uint8_t countPointer = 0; |
||||||
|
|
||||||
|
bool relativityActive = false; |
||||||
|
|
||||||
|
|
||||||
|
bool sendAbbr = false; |
||||||
|
|
||||||
|
|
||||||
|
static int16_t relativityTimer = 0; |
||||||
|
|
||||||
|
|
||||||
|
bool tempOff = false; |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void initStringData() |
||||||
|
{ |
||||||
|
if (macroTaps == 0) |
||||||
|
{ |
||||||
|
macroTaps = malloc(macroTapsLen*sizeof(uint16_t)); |
||||||
|
for(int i = 0; i < macroTapsLen; i++) |
||||||
|
{ |
||||||
|
macroTaps[i] = 0; |
||||||
|
} |
||||||
|
} |
||||||
|
if (tableNameList == 0) |
||||||
|
{ |
||||||
|
tableNameList = malloc(tableNameListLen*sizeof(char)); |
||||||
|
for(int i = 0; i < tableNameListLen; i++) |
||||||
|
{ |
||||||
|
tableNameList[i] = 0; |
||||||
|
} |
||||||
|
} |
||||||
|
if (charCount == 0) |
||||||
|
{ |
||||||
|
charCount = malloc(charCountLen*sizeof(uint8_t)); |
||||||
|
for (int i = 0; i < charCountLen; i++) |
||||||
|
{ |
||||||
|
charCount[i] = 0; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void activateRelativity(void) |
||||||
|
{ |
||||||
|
initStringData(); |
||||||
|
rgblight_mode(RGBLIGHT_MODE_KNIGHT); |
||||||
|
relativityTimer = timer_read(); |
||||||
|
relativityActive = true; |
||||||
|
} |
||||||
|
|
||||||
|
bool deactivateRelativity(void) |
||||||
|
{
|
||||||
|
rgblight_mode(9); |
||||||
|
eraseKeyCodes(); |
||||||
|
eraseTableAbbreviation(); |
||||||
|
eraseCharCounts(); |
||||||
|
relativityActive = false; |
||||||
|
tempOff = false; |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
bool containsCode(uint16_t kc) |
||||||
|
{ |
||||||
|
for (int i = 0; i < macroTapsLen && macroTaps[i] > 0; i++) |
||||||
|
{ |
||||||
|
if (macroTaps[i] == kc) return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
bool lastCodeIs(uint16_t kc) |
||||||
|
{ |
||||||
|
for (int i = 0; i < macroTapsLen-1 && macroTaps[i] > 0; i++) |
||||||
|
{ |
||||||
|
if (macroTaps[i] == kc && macroTaps[i+1] == 0) return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
bool last2CodeAre(uint16_t kc) |
||||||
|
{ |
||||||
|
for (int i = 0; i < macroTapsLen-2 && macroTaps[i] > 0; i++) |
||||||
|
{ |
||||||
|
if (macroTaps[i] == kc && macroTaps[i+1] == kc && macroTaps[i+2] == 0) return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
bool last2CodesAre(uint16_t kc, uint16_t kc2) |
||||||
|
{ |
||||||
|
for (int i = 0; i < macroTapsLen-2 && macroTaps[i] > 0; i++) |
||||||
|
{ |
||||||
|
if (macroTaps[i] == kc && macroTaps[i+1] == kc2 && macroTaps[i+2] == 0) return true; |
||||||
|
} |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
void addKeyCode(uint16_t kc) |
||||||
|
{ |
||||||
|
int i = 0; |
||||||
|
while (i < macroTapsLen-2 && macroTaps[i] > 0) i++; |
||||||
|
if (macroTaps[i] == 0) |
||||||
|
{ |
||||||
|
macroTaps[i] = kc; |
||||||
|
macroTaps[i+1] = 0; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void eraseKeyCodes(void) |
||||||
|
{ |
||||||
|
int i = 0; |
||||||
|
while (i < macroTapsLen && macroTaps[i] > 0) macroTaps[i++] = 0; |
||||||
|
} |
||||||
|
|
||||||
|
void eraseCharCounts(void) |
||||||
|
{ |
||||||
|
while (countPointer > 0) |
||||||
|
{ |
||||||
|
charCount[countPointer] = 0; |
||||||
|
countPointer--; |
||||||
|
} |
||||||
|
charCount[countPointer] = 0; |
||||||
|
} |
||||||
|
|
||||||
|
void printTableAbbreviationLimited(void) |
||||||
|
{ |
||||||
|
if (tableNameList[0] == 0) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
int i = 0; |
||||||
|
for (i = 0; i < tableNameListLen && tableNameList[i] > 0; i++) |
||||||
|
{ |
||||||
|
if (tableNameList[i] >= 65 && tableNameList[i] <= 90) |
||||||
|
{ |
||||||
|
send_char(tableNameList[i]+32); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
send_char(tableNameList[i]); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void printTableAbbreviation(void) |
||||||
|
{ |
||||||
|
if (tableNameList[0] == 0) |
||||||
|
{ |
||||||
|
return; |
||||||
|
} |
||||||
|
send_char(0x20); |
||||||
|
int i = 0; |
||||||
|
for (i = 0; i < tableNameListLen && tableNameList[i] > 0; i++) |
||||||
|
{ |
||||||
|
if (tableNameList[i] >= 65 && tableNameList[i] <= 90) |
||||||
|
{ |
||||||
|
send_char(tableNameList[i]+32); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
send_char(tableNameList[i]); |
||||||
|
} |
||||||
|
} |
||||||
|
send_char(0x20); |
||||||
|
} |
||||||
|
|
||||||
|
void eraseTableAbbreviation(void) |
||||||
|
{ |
||||||
|
for (int i = 0; i < tableNameListLen && tableNameList[i] > 0; i++) |
||||||
|
{ |
||||||
|
tableNameList[i] = '\0'; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void printString(char* str) |
||||||
|
{ |
||||||
|
|
||||||
|
if (str[0] != '\0') |
||||||
|
{ |
||||||
|
int i = 0; |
||||||
|
while (true) |
||||||
|
{ |
||||||
|
if (str[i] == 0) |
||||||
|
{ |
||||||
|
break; |
||||||
|
} |
||||||
|
send_char(str[i++]); |
||||||
|
charCount[countPointer]++; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void printStringAndQueueChar(char* str) |
||||||
|
{ |
||||||
|
if (charCount[countPointer] > 0 && countPointer < charCountLen) |
||||||
|
{ |
||||||
|
countPointer++; |
||||||
|
} |
||||||
|
sendAbbr = true; |
||||||
|
if (str[0] != '\0') |
||||||
|
{ |
||||||
|
printString(str); |
||||||
|
|
||||||
|
for (int i = 0; i < tableNameListLen-1; i++) |
||||||
|
{ |
||||||
|
if (tableNameList[i] == '\0') |
||||||
|
{ |
||||||
|
tableNameList[i] = str[0]; |
||||||
|
tableNameList[i+1] = '\0'; |
||||||
|
break; |
||||||
|
} |
||||||
|
else if (i == tableNameListLen-2) |
||||||
|
{ |
||||||
|
printTableAbbreviation(); |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
//for (i = 0; i < tableNameListLen && tableNameList[i] > 0; i++)
|
||||||
|
//{
|
||||||
|
// send_char(tableNameList[i]);
|
||||||
|
//}
|
||||||
|
//send_string_P("Darden");
|
||||||
|
//send_string_P(&myarray);
|
||||||
|
//send_string_P(str);
|
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void ReplaceString(char *orig, char *repl) |
||||||
|
{ |
||||||
|
int i = 0; |
||||||
|
while((orig[i] != 0x0 && repl[i] != 0x0) && orig[i] == repl[i]) |
||||||
|
i++; |
||||||
|
|
||||||
|
if(orig[i] != 0x0) |
||||||
|
{ |
||||||
|
int o = i; |
||||||
|
while (orig[o++] != 0x0) { |
||||||
|
charCount[countPointer]--; |
||||||
|
register_code(KC_BSPC); |
||||||
|
unregister_code(KC_BSPC); |
||||||
|
} |
||||||
|
} |
||||||
|
printString(repl+i); |
||||||
|
} |
||||||
|
|
||||||
|
void deletePrev(void) |
||||||
|
{ |
||||||
|
if (countPointer == 0 && charCount[countPointer] == 0) |
||||||
|
return; |
||||||
|
for (int i = 0; i < charCount[countPointer]; i++) |
||||||
|
{ |
||||||
|
register_code(KC_BSPC); |
||||||
|
unregister_code(KC_BSPC); |
||||||
|
} |
||||||
|
charCount[countPointer] = 0; |
||||||
|
int i = 1; |
||||||
|
for (;i < tableNameListLen-1; i++) |
||||||
|
{ |
||||||
|
if (tableNameList[i] == 0x0) |
||||||
|
{ |
||||||
|
break; |
||||||
|
} |
||||||
|
} |
||||||
|
tableNameList[i-1] = 0x0; |
||||||
|
if (countPointer > 0) |
||||||
|
{ |
||||||
|
countPointer--; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
bool processSmartMacroTap(uint16_t kc) |
||||||
|
{ |
||||||
|
if (relativityTimer > 0 && TIMER_DIFF_16(timer_read(), relativityTimer) >= relTimeout) |
||||||
|
{ |
||||||
|
deactivateRelativity(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
relativityTimer = 0; |
||||||
|
switch(kc) |
||||||
|
{ |
||||||
|
case KC_C: |
||||||
|
if (containsCode(KC_D)) |
||||||
|
{ |
||||||
|
printString("ribution"); |
||||||
|
printStringAndQueueChar("Center"); |
||||||
|
} |
||||||
|
else if (last2CodeAre(KC_C)) |
||||||
|
{ |
||||||
|
ReplaceString("Corporation", "Contact"); |
||||||
|
} |
||||||
|
else if(lastCodeIs(KC_C)) |
||||||
|
{ |
||||||
|
printString("oration"); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
printStringAndQueueChar("Corp"); |
||||||
|
} |
||||||
|
break; |
||||||
|
case KC_D: |
||||||
|
if (last2CodeAre(KC_D)) |
||||||
|
{ |
||||||
|
ReplaceString("Distribution", "Distributor"); |
||||||
|
} |
||||||
|
else if(lastCodeIs(KC_D)) |
||||||
|
{ |
||||||
|
printString("ribution"); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
printStringAndQueueChar("Dist"); |
||||||
|
} |
||||||
|
break; |
||||||
|
case KC_G: |
||||||
|
printStringAndQueueChar("Global"); |
||||||
|
printStringAndQueueChar("Lookup"); |
||||||
|
break; |
||||||
|
case KC_I: |
||||||
|
if (containsCode(KC_W)) |
||||||
|
printStringAndQueueChar("Instance"); |
||||||
|
else |
||||||
|
printStringAndQueueChar("Item"); |
||||||
|
break; |
||||||
|
case KC_N: |
||||||
|
printStringAndQueueChar("NadRate"); |
||||||
|
break; |
||||||
|
case KC_P: |
||||||
|
if (last2CodesAre(KC_D, KC_C)) |
||||||
|
{ |
||||||
|
ReplaceString("DistributionCenter", "DistCenter"); |
||||||
|
printStringAndQueueChar("Pricing"); |
||||||
|
} |
||||||
|
else if (last2CodeAre(KC_P)) |
||||||
|
{ |
||||||
|
} |
||||||
|
else if(lastCodeIs(KC_P)) |
||||||
|
{ |
||||||
|
ReplaceString("Product", "Person"); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
printStringAndQueueChar("Product"); |
||||||
|
} |
||||||
|
break; |
||||||
|
case KC_Q: |
||||||
|
printStringAndQueueChar("Darden"); |
||||||
|
break; |
||||||
|
case KC_S: |
||||||
|
if (containsCode(KC_W)) |
||||||
|
if (containsCode(KC_S) || containsCode(KC_D)) |
||||||
|
printStringAndQueueChar("Step"); |
||||||
|
else |
||||||
|
printStringAndQueueChar("Session"); |
||||||
|
else |
||||||
|
printStringAndQueueChar("Supplier"); |
||||||
|
break; |
||||||
|
case KC_T: |
||||||
|
if (containsCode(KC_W)) |
||||||
|
printStringAndQueueChar("Task"); |
||||||
|
else |
||||||
|
printStringAndQueueChar("Type"); |
||||||
|
break; |
||||||
|
case KC_W: |
||||||
|
printStringAndQueueChar("Workflow"); |
||||||
|
break; |
||||||
|
} |
||||||
|
addKeyCode(kc); |
||||||
|
return false; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
bool shifted = false; |
||||||
|
bool isShifted() |
||||||
|
{ |
||||||
|
return shifted; |
||||||
|
} |
||||||
|
|
||||||
|
void setShifted(bool val) |
||||||
|
{ |
||||||
|
shifted = val; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
bool storeShiftState(uint16_t keycode, keyrecord_t *record) |
||||||
|
{ |
||||||
|
|
||||||
|
if (record->event.pressed) |
||||||
|
{ |
||||||
|
switch (keycode) |
||||||
|
{ |
||||||
|
case KC_LSPO: |
||||||
|
case KC_RSPC: |
||||||
|
shifted = true; |
||||||
|
} |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
switch (keycode) |
||||||
|
{ |
||||||
|
|
||||||
|
case KC_LSPO: |
||||||
|
case KC_RSPC: |
||||||
|
shifted = false; |
||||||
|
return true; |
||||||
|
} |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
bool handleSmartMacros(uint16_t keycode, keyrecord_t *record) |
||||||
|
{ |
||||||
|
if (relativityActive != true) return true; |
||||||
|
if (record->event.pressed) |
||||||
|
{ |
||||||
|
switch (keycode) |
||||||
|
{ |
||||||
|
case KC_BSPC: |
||||||
|
if (!isShifted()){ |
||||||
|
deletePrev(); |
||||||
|
} |
||||||
|
else { |
||||||
|
register_code(KC_BSPC); |
||||||
|
unregister_code(KC_BSPC); |
||||||
|
} |
||||||
|
return false; |
||||||
|
case KC_A: |
||||||
|
case KC_B: |
||||||
|
case KC_C: |
||||||
|
case KC_D: |
||||||
|
case KC_E: |
||||||
|
case KC_F: |
||||||
|
case KC_G: |
||||||
|
case KC_H: |
||||||
|
case KC_I: |
||||||
|
case KC_J: |
||||||
|
case KC_K: |
||||||
|
case KC_L: |
||||||
|
case KC_M: |
||||||
|
case KC_N: |
||||||
|
case KC_O: |
||||||
|
case KC_P: |
||||||
|
case KC_Q: |
||||||
|
case KC_R: |
||||||
|
case KC_S: |
||||||
|
case KC_T: |
||||||
|
case KC_U: |
||||||
|
case KC_V: |
||||||
|
case KC_W: |
||||||
|
case KC_X: |
||||||
|
case KC_Y: |
||||||
|
case KC_Z: |
||||||
|
return processSmartMacroTap(keycode); |
||||||
|
|
||||||
|
case PRRD: |
||||||
|
if (tempOff) |
||||||
|
{ |
||||||
|
SEND_STRING("Id = "); |
||||||
|
printTableAbbreviationLimited(); |
||||||
|
SEND_STRING(".Id"); |
||||||
|
return deactivateRelativity(); |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
printTableAbbreviation(); |
||||||
|
SEND_STRING("ON "); |
||||||
|
printTableAbbreviationLimited(); |
||||||
|
eraseKeyCodes(); |
||||||
|
eraseTableAbbreviation(); |
||||||
|
eraseCharCounts(); |
||||||
|
tempOff = true; |
||||||
|
return true; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
case KC_SPC: |
||||||
|
printTableAbbreviation(); |
||||||
|
return deactivateRelativity(); |
||||||
|
case ENTER_OR_SQL: |
||||||
|
if (tempOff) |
||||||
|
{ |
||||||
|
SEND_STRING("Id = "); |
||||||
|
printTableAbbreviationLimited(); |
||||||
|
SEND_STRING(".Id"); |
||||||
|
deactivateRelativity(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
else |
||||||
|
{ |
||||||
|
printTableAbbreviation(); |
||||||
|
deactivateRelativity(); |
||||||
|
return true; |
||||||
|
} |
||||||
|
case KC_ESC: |
||||||
|
return deactivateRelativity(); |
||||||
|
} |
||||||
|
} |
||||||
|
return true; |
||||||
|
} |
@ -0,0 +1,32 @@ |
|||||||
|
#include QMK_KEYBOARD_H |
||||||
|
#define macroTapsLen 32 |
||||||
|
#define tableNameListLen 32 |
||||||
|
#define charCountLen 32 |
||||||
|
|
||||||
|
#define relTimeout 1500 |
||||||
|
|
||||||
|
|
||||||
|
void activateRelativity(void); |
||||||
|
bool deactivateRelativity(void); |
||||||
|
void initStringData(void); |
||||||
|
bool containsCode(uint16_t kc); |
||||||
|
bool lastCodeIs(uint16_t kc); |
||||||
|
bool last2CodeAre(uint16_t kc); |
||||||
|
bool last2CodesAre(uint16_t kc, uint16_t kc2); |
||||||
|
void addKeyCode(uint16_t kc); |
||||||
|
void eraseKeyCodes(void); |
||||||
|
void eraseCharCounts(void); |
||||||
|
void printTableAbbreviation(void); |
||||||
|
void eraseTableAbbreviation(void); |
||||||
|
void printString(char* str); |
||||||
|
void printStringAndQueueChar(char* str); |
||||||
|
void ReplaceString(char *orig, char *repl); |
||||||
|
void deletePrev(void); |
||||||
|
bool processSmartMacroTap(uint16_t kc); |
||||||
|
bool isShifted(void); |
||||||
|
void setShifted(bool); |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
bool handleSmartMacros(uint16_t keycode, keyrecord_t *record); |
||||||
|
bool storeShiftState(uint16_t keycode, keyrecord_t *record); |
Loading…
Reference in new issue