2018-11-06 21:01:18 +01:00
|
|
|
#include QMK_KEYBOARD_H
|
|
|
|
#include "customLogic.h"
|
|
|
|
#include "keymap.h"
|
|
|
|
#include "keyDefinitions.h"
|
|
|
|
#include "relativity.h"
|
|
|
|
#include "timer.h"
|
|
|
|
|
|
|
|
static int16_t fnTimer = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
2021-07-19 18:50:55 +02:00
|
|
|
layer_state_t layer_state_set_user(layer_state_t state)
|
2018-11-06 21:01:18 +01:00
|
|
|
{
|
2022-06-18 23:37:51 +02:00
|
|
|
switch (get_highest_layer(state))
|
2018-11-06 21:01:18 +01:00
|
|
|
{
|
|
|
|
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)
|
|
|
|
{
|
2021-07-19 18:50:55 +02:00
|
|
|
case S_LFTJN:
|
|
|
|
SEND_STRING("LEFT JOIN");
|
2018-11-06 21:01:18 +01:00
|
|
|
activateRelativity();
|
|
|
|
return false;
|
2021-07-19 18:50:55 +02:00
|
|
|
case S_INRJN:
|
|
|
|
SEND_STRING("INNER JOIN ");
|
2018-11-06 21:01:18 +01:00
|
|
|
activateRelativity();
|
|
|
|
return false;
|
2021-07-19 18:50:55 +02:00
|
|
|
case S_SLCT:
|
|
|
|
SEND_STRING("SELECT "); return
|
2018-11-06 21:01:18 +01:00
|
|
|
false;
|
2021-07-19 18:50:55 +02:00
|
|
|
case S_FROM:
|
|
|
|
SEND_STRING("FROM "); return
|
2018-11-06 21:01:18 +01:00
|
|
|
false;
|
2021-07-19 18:50:55 +02:00
|
|
|
case S_DSNCT:
|
|
|
|
SEND_STRING("DISTINCT "); return
|
2018-11-06 21:01:18 +01:00
|
|
|
false;
|
2021-07-19 18:50:55 +02:00
|
|
|
case S_ORDER:
|
|
|
|
SEND_STRING("ORDER BY "); return
|
2018-11-06 21:01:18 +01:00
|
|
|
false;
|
2021-07-19 18:50:55 +02:00
|
|
|
case S_WHERE:
|
|
|
|
SEND_STRING("WHERE "); return
|
2018-11-06 21:01:18 +01:00
|
|
|
false;
|
2021-07-19 18:50:55 +02:00
|
|
|
case S_ALTER:
|
2018-11-06 21:01:18 +01:00
|
|
|
SEND_STRING("ALTER SESSION SET CURRENT_SCHEMA = SUPPLY;"); return false;
|
2021-07-19 18:50:55 +02:00
|
|
|
case S_ASTRK:
|
2018-11-06 21:01:18 +01:00
|
|
|
SEND_STRING("* "); return false;
|
2021-07-19 18:50:55 +02:00
|
|
|
|
2018-11-06 21:01:18 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
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);
|
|
|
|
}
|