QMK/keyboards/betalupi_ergodox/keymaps/default/keymap.c

160 lines
3.5 KiB
C
Raw Normal View History

2022-12-27 13:22:07 -08:00
#include QMK_KEYBOARD_H
#include "version.h"
#include "keymap_russian.h"
#include "keymap_us_international.h"
// Values that should not be saved to git.
// There should be a`secrets.h` in this directory
// with the following contents:
//
// #define SECRET_EMAIL "value"
// #define SECRET_GMAIL "value"
// #define SECRET_SCHOOL_EMAIL "value"
#include "secrets.h"
// Macro keycodes
enum custom_keycodes {
M_SHUTDOWN = BETA_SAFE_RANGE,
// Macros
M_RESETWM,
M_RU_CTRL,
M_RU_ALT,
2023-12-16 12:27:53 -08:00
M_GUI,
2022-12-27 13:22:07 -08:00
// Special characters.
// M_SPECIAL_TOP and M_SPECIAL_BOTTOM are
// bounds used to parse these. Only special
// characters should be between them.
//
// Сharacters here should be in the same
// order as they are in the host inteface.
M_SPECIAL_TOP,
M_SC_GRAVE,
M_SC_TILD,
M_SC_QUOT,
M_SC_LBR,
M_SC_RBR,
M_SC_LCBR,
M_SC_RCBR,
M_SC_LKVCH,
M_SC_RKVCH,
M_SPECIAL_BOTTOM
};
// Tapdance keycodes
enum tap_dance_codes {
TD_WMLAYOUT,
TD_SCREENSHOT,
TD_OCR
};
// LED colors
#define LC_OFF LC_HSV( 0, 0, 0)
#define LC_GREEN LC_HSV( 85, 203, 158)
#define LC_YELLOW LC_HSV( 32, 176, 255)
#define LC_PINK LC_HSV(243, 222, 234)
#define LC_CYAN LC_HSV(134, 255, 213)
#define LC_ORANGE LC_HSV( 14, 255, 255)
#define LC_WHITE LC_HSV( 0, 0, 150)
2023-12-13 17:46:21 -08:00
#define LC_RED LC_HSV( 0, 255, 145)
2022-12-27 13:22:07 -08:00
#define LC_RU_B LC_HSV( 0, 0, 165)
#define LC_RU_G LC_HSV(153, 255, 153)
#define LC_RU_K LC_HSV( 0, 255, 145)
2022-02-06 12:00:50 -08:00
2022-11-20 20:45:13 -08:00
#ifdef ENABLE_HID_SPELLCHECK
#include "features/hid_spellcheck.h"
2022-07-21 17:49:35 -07:00
#endif
2022-11-20 20:45:36 -08:00
#ifdef ENABLE_AUTOCORRECT
#include "features/autocorrect/autocorrect.h"
#endif
2022-12-27 13:22:07 -08:00
#include "features/beta_rawhid.h"
2022-07-18 10:37:48 -07:00
2022-08-10 09:11:09 -07:00
// Send a special character.
// Returns false if character was caught, true otherwise.
bool send_special_character(uint16_t keycode) {
2022-11-18 23:33:26 -08:00
if ( (keycode > M_SPECIAL_TOP) && (keycode < M_SPECIAL_BOTTOM) ) {
2022-08-10 09:11:09 -07:00
hid_send_special_char(keycode - M_SPECIAL_TOP - 1);
return false;
}
return true;
}
2022-07-18 10:37:48 -07:00
2022-12-27 13:22:07 -08:00
// Include all other parts of configuration
#include "layers/layers.c"
#include "parts/leader.c"
#include "parts/tapdance.c"
// Process macros.
// Return FALSE to halt key processing,
// Return TRUE to allow QMK to handle keypress.
2022-02-06 12:00:50 -08:00
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
2022-07-21 17:49:35 -07:00
2022-11-20 20:45:13 -08:00
#ifdef ENABLE_HID_SPELLCHECK
2022-07-20 21:19:13 -07:00
if (!process_spellcheck(keycode, record)) { return false; }
2022-07-21 17:49:35 -07:00
#endif
2022-11-20 20:45:36 -08:00
#ifdef ENABLE_AUTOCORRECT
if (!process_autocorrection(keycode, record)) { return false; }
#endif
2022-08-10 09:11:09 -07:00
// Handle special chars
if (record->event.pressed) {
if (!send_special_character(keycode)) { return false; }
}
// Handle macros
2022-02-06 12:16:11 -08:00
switch (keycode) {
2022-02-09 13:26:46 -08:00
case M_RESETWM:
2022-02-06 12:16:11 -08:00
if (record->event.pressed) {
SEND_STRING(SS_LCTL(SS_LGUI(SS_LSFT(SS_TAP(X_R)))));
}
return false;
2023-12-16 12:27:53 -08:00
// Workaround for one-shot LGUI key.
// Using just LGUI with LAYER_DESKTOP as OSL
// does not allow you to hold lgui. This does.
case M_GUI:
if (record->event.pressed) {
register_code16(KC_LGUI);
} else {
unregister_code16(KC_LGUI);
}
return false;
2022-02-06 12:16:11 -08:00
2022-02-09 13:26:46 -08:00
case M_SHUTDOWN:
2022-02-06 12:16:11 -08:00
if (record->event.pressed) {
2022-07-20 21:19:20 -07:00
SEND_STRING(SS_LGUI(SS_TAP(X_P)) SS_DELAY(100) SS_TAP(X_Y) SS_DELAY(100) SS_TAP(X_ENTER));
2022-02-06 12:16:11 -08:00
}
return false;
2022-02-06 12:16:11 -08:00
2022-02-09 12:07:34 -08:00
case M_RU_CTRL:
if (record->event.pressed) {
layer_move(LAYER_MAIN);
2022-12-27 13:22:07 -08:00
register_code16(KC_LCTL);
} else {
2022-12-27 13:22:07 -08:00
unregister_code16(KC_LCTL);
layer_move(LAYER_RUSSIAN);
}
return false;
2022-07-18 10:16:03 -07:00
case M_RU_ALT:
if (record->event.pressed) {
layer_move(LAYER_MAIN);
2022-07-18 10:16:03 -07:00
register_code16(KC_LALT);
} else {
unregister_code16(KC_LALT);
layer_move(LAYER_RUSSIAN);
2022-07-18 10:16:03 -07:00
}
return false;
2022-02-06 12:16:11 -08:00
}
2022-02-09 11:14:05 -08:00
return true;
2022-12-27 13:22:07 -08:00
}