Working on Morse Code Macros

master
Ante Laurijssen 2017-06-07 22:01:28 -04:00
parent 1b8ed53f21
commit 8f80f35186
1 changed files with 24 additions and 9 deletions

View File

@ -407,22 +407,37 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
}; };
// Macros // Custom Function - Check if shift is pressed
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) { bool check_shift(void);
switch(id) {
// Morse Code Macros bool check_shift() {
if (keyboard_report->mods & (MOD_BIT(KC_LSHIFT))) {
case 0: //Number 0-) return KC_LSHIFT;
if (record->event.pressed) { }
if (keyboard_report->mods & (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT))) { if (keyboard_report->mods & (MOD_BIT(KC_RSHIFT))) {
clear_mods(); return KC_RSHIFT;
return MACRO(T(MINS), T(DOT), T(MINS), T(MINS), T(DOT), T(MINS), T(SPACE), END); //-.--.-
} }
else { else {
return false;
}
}
// Morse Code Macros
const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt) {
uint16_t is_shift = check_shift();
switch(id) {
case 0: //Number 0-)
if (record->event.pressed) {
if (is_shift == false) {
return MACRO(T(MINS), T(MINS), T(MINS), T(MINS), T(MINS), T(SPACE), END); //----- return MACRO(T(MINS), T(MINS), T(MINS), T(MINS), T(MINS), T(SPACE), END); //-----
} }
else {
unregister_mods(MOD_BIT(is_shift));
return MACRO(T(MINS), T(DOT), T(MINS), T(MINS), T(DOT), T(MINS), T(SPACE), END); //-.--.-
register_code(is_shift);
}
} }
break; break;
case 1: //Number 1-! case 1: //Number 1-!