From 00281df07412625d7f39eb8fb6001bc9e1a8035f Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Mon, 10 Sep 2018 11:49:55 -0600 Subject: [PATCH 01/21] deleting arkag branch, forcibly moving changes over to master --- keyboards/mechmini/v2/keymaps/arkag/config.h | 8 + keyboards/mechmini/v2/keymaps/arkag/keymap.c | 588 +++++++++++++++++++ keyboards/mechmini/v2/keymaps/arkag/rules.mk | 13 + 3 files changed, 609 insertions(+) create mode 100644 keyboards/mechmini/v2/keymaps/arkag/config.h create mode 100644 keyboards/mechmini/v2/keymaps/arkag/keymap.c create mode 100644 keyboards/mechmini/v2/keymaps/arkag/rules.mk diff --git a/keyboards/mechmini/v2/keymaps/arkag/config.h b/keyboards/mechmini/v2/keymaps/arkag/config.h new file mode 100644 index 000000000000..926abb13255e --- /dev/null +++ b/keyboards/mechmini/v2/keymaps/arkag/config.h @@ -0,0 +1,8 @@ +#pragma once + +#define CONFIG_USER_H + +#define TAPPING_TERM 200 + +#define ONESHOT_TIMEOUT 1000 +#define ONESHOT_TAP_TOGGLE 4 diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c new file mode 100644 index 000000000000..5926bea29306 --- /dev/null +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -0,0 +1,588 @@ +#include QMK_KEYBOARD_H + +// Start: Written by konstantin: vomindoraan +#include +#include +#include + +void send_unicode_hex_string(const char *str) { + if (!str) { return; } // Saftey net + while (*str) { + // Find the next code point (token) in the string + for (; *str == ' '; str++); + size_t n = strcspn(str, " "); // Length of the current token + char code_point[n+1]; + strncpy(code_point, str, n); + code_point[n] = '\0'; // Make sure it's null-terminated + + // Normalize the code point: make all hex digits lowercase + for (char *p = code_point; *p; p++) { + *p = tolower(*p); + } + + // Send the code point as a Unicode input string + unicode_input_start(); + send_string(code_point); + unicode_input_finish(); + str += n; // Move to the first ' ' (or '\0') after the current token + } +} +// End: Written by konstantin: vomindoraan + +#define _BASE 0 +#define _RAISE 1 +#define _LOWER 2 +#define _KEEB 3 +#define _MEDIA 4 + +#define MOD_CTL_MASK (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) +#define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) + +#define LED_FLASH_DELAY 100 + +#define EECONFIG_USERSPACE (uint8_t *)20 + +#define LRALT TD(TD_LALT_RALT) +#define QUOTE TD(TD_SING_DOUB) +#define GRAVE TD(TD_GRV_3GRV) +#define OPENBRACK TD(TD_BRCK_PARN_O) +#define CLOSEBRACK TD(TD_BRCK_PARN_C) +#define THREE TD(TD_3_GRV_ACT) +#define HYPHEN TD(TD_HYPH_UNDR) +#define CEDILLA TD(TD_C_CED) +#define HTTPS TD(TD_SLSH_HTTP) +#define SPECIAL TD(TD_SPECIAL) +#define KEEB MO(3) +#define LOWER MO(2) +#define RAISE MO(1) +#define MEDIA MO(4) + +typedef enum { + OS_MAC, // Don't assign values + OS_WIN, + OS_NIX, + _OS_COUNT, +} OS; + +typedef struct { + uint16_t h; + uint8_t s; + uint8_t v; +} Color; + +uint8_t current_os; +uint8_t mod_primary_mask; +uint16_t flash_start_timer = 0; +bool flash = false, flash_on_started, flash_off_started, paste_ready = false; +Color underglow; + +enum custom_keycodes { + M_PMOD = SAFE_RANGE, + M_SMOD, + M_P_B, + M_C_A_D, + M_CALC, + M_SSHOT, + M_OS, + M_TF, + M_TM, + M_GGT, + M_LOD, + M_SNIPENT, + M_REPO, + M_SHRUG, + M_UF, +}; + +enum tapdances { + TD_3_GRV_ACT = 0, + TD_C_CED, + TD_GRV_3GRV, + TD_SLSH_HTTP, + TD_SING_DOUB, + TD_HYPH_UNDR, + TD_SPECIAL, + TD_BRCK_PARN_O, + TD_BRCK_PARN_C, + TD_LALT_RALT, +}; + +Color mod_color(Color current_color, bool should_add, uint16_t change_amount) { + uint16_t addlim = 359 - change_amount; + uint16_t sublim = change_amount; + uint16_t leftovers; + if (should_add) { + if (current_color.h <= addlim) { + current_color.h += change_amount; + } else { + leftovers = (359 + change_amount) % 359; + current_color.h = 0 + leftovers; + } + } else { + if (current_color.h >= sublim) { + current_color.h -= change_amount; + } else { + leftovers = change_amount - current_color.h; + current_color.h = 359 - leftovers; + } + } + return current_color; +} + +void set_color(Color new, bool update) { + rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); +} + +void set_os (uint8_t os, bool update) { + current_os = os; + if (update) { + eeprom_update_byte(EECONFIG_USERSPACE, current_os); + } + switch (os) { + case OS_MAC: + set_unicode_input_mode(UC_OSX); + underglow = (Color){ 300, 255, 255 }; + mod_primary_mask = MOD_GUI_MASK; + break; + case OS_WIN: + set_unicode_input_mode(UC_WINC); + underglow = (Color){ 180, 255, 255 }; + mod_primary_mask = MOD_CTL_MASK; + break; + case OS_NIX: + set_unicode_input_mode(UC_LNX); + underglow = (Color){ 60, 255, 255 }; + mod_primary_mask = MOD_CTL_MASK; + break; + default: + underglow = (Color){ 0, 0, 255 }; + mod_primary_mask = MOD_CTL_MASK; + } + flash = true; +} + +void tap_key(uint8_t keycode) { + register_code(keycode); + unregister_code(keycode); +} + +// register GUI if Mac or Ctrl if other +void pri_mod(bool press) { + if (press) { + if (current_os == OS_MAC) { + register_code(KC_LGUI); + } else { + register_code(KC_LCTL); + } + } else { + if (current_os == OS_MAC) { + unregister_code(KC_LGUI); + } else { + unregister_code(KC_LCTL); + } + } +} + +// register Ctrl if Mac or GUI if other +void sec_mod(bool press) { + if (press) { + if (current_os == OS_MAC) { + register_code(KC_LCTL); + } else { + register_code(KC_LGUI); + } + } else { + if (current_os == OS_MAC) { + unregister_code(KC_LCTL); + } else { + unregister_code(KC_LGUI); + } + } +} + +void code_snippet(void) { + SEND_STRING("``````" SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT)); +} + +void short_snippet(void) { + SEND_STRING("``" SS_TAP(X_LEFT)); +} + +void single_quot(void) { + SEND_STRING("\'\'"); +} + +void dance_grv (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + tap_key(KC_GRV); + } else if (state->count == 2) { + short_snippet(); + } else { + code_snippet(); + } +} + +void dance_quot (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + tap_key(KC_QUOT); + } else if (state->count == 2) { + single_quot(); + tap_key(KC_LSFT); + tap_key(KC_LEFT); + } +} + +void send_https(void) { + SEND_STRING("https://"); +} + +void send_http(void) { + SEND_STRING("http://"); +} + +void dance_http (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + tap_key(KC_SLSH); + } else if (state->count == 2) { + send_https(); + } else { + send_http(); + } +} + +void send_copy_paste (void) { + pri_mod(true); + if (!paste_ready) {SEND_STRING(SS_TAP(X_C));} + else {SEND_STRING(SS_TAP(X_V));} + pri_mod(false); + paste_ready = !paste_ready; +} + +void send_cut_paste (void) { + pri_mod(true); + if (!paste_ready) {SEND_STRING(SS_TAP(X_X));} + else {SEND_STRING(SS_TAP(X_V));} + pri_mod(false); + paste_ready = !paste_ready; +} + +void send_lod(void) { + send_unicode_hex_string("0CA0 005F 005F 0CA0"); +} + +void dance_special (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + } else if (state->count == 2) { + send_copy_paste(); + } else if (state->count == 3) { + send_cut_paste(); + } else { + send_lod(); + } +} + +void dance_3 (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code (KC_3); + } else if (state->count == 2) { + send_unicode_hex_string("00E8"); + } else if (state->count == 3) { + send_unicode_hex_string("00E9"); + } +} + +void dance_c (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + register_code (KC_C); + } else if (state->count == 2) { + send_unicode_hex_string("00E7"); + } +} + +//Tap Dance Definitions +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_3_GRV_ACT] = ACTION_TAP_DANCE_FN (dance_3), + [TD_C_CED] = ACTION_TAP_DANCE_FN (dance_c), + [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), + [TD_SLSH_HTTP] = ACTION_TAP_DANCE_FN (dance_http), + [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), + [TD_SPECIAL] = ACTION_TAP_DANCE_FN (dance_special), + [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), + [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), + [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, LSFT(KC_0)), + [TD_LALT_RALT] = ACTION_TAP_DANCE_DOUBLE (KC_LALT, KC_RALT), +}; + +void matrix_init_user(void) { + current_os = eeprom_read_byte(EECONFIG_USERSPACE); + set_os(current_os, false); + // steno_set_mode(STENO_MODE_GEMINI); +} + +void matrix_scan_user(void) { + if (flash && !flash_on_started && !flash_off_started) { + flash_start_timer = timer_read(); + flash_on_started = true; + set_color(underglow, false); + } else if (flash && flash_on_started && !flash_off_started) { + uint16_t flash_timer = timer_read(); + uint16_t elapsed = flash_timer - flash_start_timer; + if (elapsed >= LED_FLASH_DELAY) { + flash_on_started = false; + flash_off_started = true; + rgblight_sethsv_eeprom_helper(0, 255, 0, false); + flash_start_timer = timer_read(); + } + } else if (flash && flash_off_started && !flash_on_started) { + uint16_t flash_timer = timer_read(); + uint16_t elapsed = flash_timer - flash_start_timer; + if (elapsed >= LED_FLASH_DELAY) { + flash_off_started = false; + flash = false; + set_color(underglow, true); + } + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case M_PMOD: + if (record->event.pressed) { + pri_mod(true); + } else { + pri_mod(false); + } + return false; + + case M_SMOD: + if (record->event.pressed) { + sec_mod(true); + } else { + sec_mod(false); + } + return false; + + case M_P_B: + if (record->event.pressed) { + if (current_os == OS_WIN) { + SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_PAUSE) SS_UP(X_LGUI)); + } else { + } + } + return false; + + case M_C_A_D: + if (record->event.pressed) { + if (current_os == OS_WIN) { + SEND_STRING(SS_DOWN(X_LCTRL) SS_DOWN(X_LALT) SS_TAP(X_DELETE) SS_UP(X_LALT) SS_UP(X_LCTRL)); + } else { + } + } + return false; + + case M_CALC: + if (record->event.pressed) { + if (current_os == OS_WIN) { + SEND_STRING(SS_TAP(X_CALCULATOR)); + // SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_R) SS_UP(X_LGUI) "calc.exe" SS_TAP(X_ENTER)); + } else if (current_os == OS_MAC) { + SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_SPACE) SS_UP(X_LGUI) "calculator" SS_TAP(X_ENTER)); + } + } + return false; + + case M_SSHOT: + if (record->event.pressed) { + if (current_os == OS_WIN) { + SEND_STRING(SS_DOWN(X_LGUI) SS_DOWN(X_LSHIFT) SS_TAP(X_S) SS_UP(X_LSHIFT) SS_UP(X_LGUI)); + } else if (current_os == OS_MAC) { + SEND_STRING(SS_DOWN(X_LGUI) SS_DOWN(X_LSHIFT) SS_TAP(X_4) SS_UP(X_LSHIFT) SS_UP(X_LGUI)); + } else { + return true; + } + paste_ready = true; + } + return false; + + case M_OS: + if (record->event.pressed) { + set_os((current_os+1) % _OS_COUNT, true); + } + return false; + + case M_LOD: + if (record->event.pressed) { + send_lod(); + } + return false; + + case M_TF: + if (record->event.pressed) { + send_unicode_hex_string("0028 256F 2035 0414 2032 0029 256F 5F61 253B 2501 253B"); + } + return false; + + case M_UF: + if (record->event.pressed) { + send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 0020 30CE 0029"); + } + return false; + + case M_SHRUG: + if (record->event.pressed) { + send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF"); + } + return false; + + case M_TM: + if (record->event.pressed) { + send_unicode_hex_string("2122"); + } + return false; + + case M_REPO: + if (record->event.pressed) { + SEND_STRING("https://github.com/arkag/qmk_firmware/tree/arkag/keyboards/mechmini/v2/keymaps/ark"); + } + return false; + + case M_GGT: + if (record->event.pressed) { + SEND_STRING("@GrahamGoldenTech.com"); + } + return false; + + case M_SNIPENT: + if (record->event.pressed) { + code_snippet(); + pri_mod(true); + register_code(KC_V); + unregister_code(KC_V); + pri_mod(false); + SEND_STRING(SS_TAP(X_RIGHT) SS_TAP(X_RIGHT) SS_TAP(X_RIGHT) SS_TAP(X_ENTER)); + paste_ready = false; + } + return false; + + case KC_LSFT: + if (record->event.pressed) { + Color shift_color = underglow; + shift_color = mod_color(shift_color, true, 25); + set_color(shift_color, false); + SEND_STRING(SS_DOWN(X_LSHIFT)); + } else { + set_color(underglow, false); + SEND_STRING(SS_UP(X_LSHIFT)); + } + return false; + + case KC_C: + if (record->event.pressed) { + if(get_mods() & mod_primary_mask) { + paste_ready = true; + } + } + return true; + + case KC_X: + if (record->event.pressed) { + if(get_mods() & mod_primary_mask) { + paste_ready = true; + } + } + return true; + + case KC_V: + if (record->event.pressed) { + if(get_mods() & mod_primary_mask) { + paste_ready = false; + } + } + return true; + + case KEEB: + case RAISE: + case LOWER: + return true; + break; + + case KC_BSPC: + // reverse color on backspace, no reset + if (record->event.pressed) { + underglow = mod_color(underglow, false, 10); + set_color(underglow, false); + SEND_STRING(SS_DOWN(X_BSPACE)); + } else { + SEND_STRING(SS_UP(X_BSPACE)); + } + return false; + + default: + // add to hue by default, no reset + if (record->event.pressed) { + underglow = mod_color(underglow, true, 10); + set_color(underglow, false); + } + return true; + } +} + +uint32_t layer_state_set_user(uint32_t state) { + Color layer = underglow; + + switch (biton32(state)) { + case _MEDIA: + layer = mod_color(layer, true, 150); + set_color(layer, false); + break; + case _KEEB: + layer = mod_color(layer, false, 150); + set_color(layer, false); + break; + case _LOWER: + layer = mod_color(layer, false, 100 ); + set_color(layer, false); + break; + case _RAISE: + layer = mod_color(layer, true, 100); + set_color(layer, false); + break; + default: + set_color(underglow, false); + break; + } + return state; +} + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + + [_BASE] = LAYOUT_2u_space_ortho( + KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, + KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, QUOTE, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, + M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, SPECIAL, KC_LEFT, KC_DOWN, KC_RGHT), + + [_RAISE] = LAYOUT_2u_space_ortho( + GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, + _______, OPENBRACK, CLOSEBRACK, KC_BSLS, HYPHEN, KC_EQL, _______, KC_4, KC_5, KC_6, _______, KC_NLCK, + _______, _______, _______, CEDILLA, _______, KC_COMM, KC_PDOT, KC_1, KC_2, KC_3, KC_PPLS, KC_PENT, + _______, _______, _______, KEEB, _______, _______, HTTPS, M_OS, KC_PSLS, KC_PMNS, KC_PAST), + + [_LOWER] = LAYOUT_2u_space_ortho( + _______, _______, _______, _______, _______, M_TM, _______, _______, _______, _______, M_P_B, M_C_A_D, + _______, _______, M_SSHOT, _______, _______, M_GGT, _______, M_UF, M_REPO, M_SNIPENT, _______, _______, + _______, KC_DEL, _______, _______, _______, _______, _______, M_TF, M_SHRUG, M_LOD, KC_PGUP, _______, + _______, _______, _______, _______, _______, MEDIA, _______, M_CALC, KC_HOME, KC_PGDOWN, KC_END), + + [_KEEB] = LAYOUT_2u_space_ortho( + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, + _______, BL_TOGG, BL_STEP, BL_INC, BL_DEC, BL_BRTG, _______, _______, _______, _______, _______, _______, + _______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_VAD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, _______, _______, _______, + RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), + + [_MEDIA] = LAYOUT_2u_space_ortho( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_VOLU, KC_MUTE, + _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT), +}; diff --git a/keyboards/mechmini/v2/keymaps/arkag/rules.mk b/keyboards/mechmini/v2/keymaps/arkag/rules.mk new file mode 100644 index 000000000000..b93dba064a6d --- /dev/null +++ b/keyboards/mechmini/v2/keymaps/arkag/rules.mk @@ -0,0 +1,13 @@ +BOOTMAGIC_ENABLE = no +MOUSEKEY_ENABLE = no +STENO_ENABLE = no +EXTRAKEY_ENABLE = yes +CONSOLE_ENABLE = no +COMMAND_ENABLE = no +SLEEP_LED_ENABLE = yes +NKRO_ENABLE = yes +BACKLIGHT_ENABLE = yes +AUDIO_ENABLE = no +RGBLIGHT_ENABLE = yes +TAP_DANCE_ENABLE = yes +UNICODE_ENABLE = yes From 27f84001eca7ec24e5e483a7982a76be8d9ee7bd Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Mon, 10 Sep 2018 17:31:30 -0600 Subject: [PATCH 02/21] fade_color function added, not tested --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 25 ++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 5926bea29306..13032e0140b3 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -133,6 +133,28 @@ void set_color(Color new, bool update) { rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); } +void fade_color(Color current_color, Color new_color) { + bool fade_by_adding = current_color.h < new_color.h; + uint16_t difference = 0, temp_hue = current_color.h; + if (fade_by_adding) { + difference = new_color.h - current_color.h; + for (int i = 0; i <= difference; i++) { + temp_hue = (temp_hue + 1)%359; + rgblight_sethsv_eeprom_helper(temp_hue, 255, 255, false); + } + } else { + difference = current_color.h - new_color.h; + for (int i = 0; i <= difference; i++) { + if (temp_hue == 0){ + temp_hue = 359; + } else { + temp_hue = (temp_hue - 1); + } + rgblight_sethsv_eeprom_helper(temp_hue, 255, 255, false); + } + } +} + void set_os (uint8_t os, bool update) { current_os = os; if (update) { @@ -316,7 +338,6 @@ qk_tap_dance_action_t tap_dance_actions[] = { void matrix_init_user(void) { current_os = eeprom_read_byte(EECONFIG_USERSPACE); set_os(current_os, false); - // steno_set_mode(STENO_MODE_GEMINI); } void matrix_scan_user(void) { @@ -442,7 +463,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case M_REPO: if (record->event.pressed) { - SEND_STRING("https://github.com/arkag/qmk_firmware/tree/arkag/keyboards/mechmini/v2/keymaps/ark"); + SEND_STRING("https://github.com/arkag/qmk_firmware/tree/master/keyboards/mechmini/v2/keymaps/arkag"); } return false; From dad868dc436b4fb13c643218878084b800c1d6f2 Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Mon, 10 Sep 2018 20:20:01 -0600 Subject: [PATCH 03/21] added half functions some stuff --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 34 +++++++++++++++++--- 1 file changed, 30 insertions(+), 4 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 13032e0140b3..633aa028d527 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -101,6 +101,10 @@ enum tapdances { TD_SLSH_HTTP, TD_SING_DOUB, TD_HYPH_UNDR, + TD_NOOP_BOLD, + TD_NOOP_ITAL, + TD_NOOP_UNDR, + TD_NOOP_STRK, TD_SPECIAL, TD_BRCK_PARN_O, TD_BRCK_PARN_C, @@ -230,10 +234,6 @@ void short_snippet(void) { SEND_STRING("``" SS_TAP(X_LEFT)); } -void single_quot(void) { - SEND_STRING("\'\'"); -} - void dance_grv (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { tap_key(KC_GRV); @@ -244,6 +244,30 @@ void dance_grv (qk_tap_dance_state_t *state, void *user_data) { } } +// void surround_type(uint8_t num_of_char, uint8_t keycode) { +// char str[2*(num_of_char + (num_of_char / 2))]; +// for (int i = 0; i < num_of_char; i++) { +// +// } +// for (int i = 0; i < (num_of_char/2); i++) { +// SEND_STRING(X_LEFT); +// } +// } +// +// void dance_grv (qk_tap_dance_state_t *state, void *user_data) { +// if (state->count == 1) { +// tap_key(KC_GRV); +// } else if (state->count == 2) { +// surround_type(1, "``"); +// } else { +// surround_type(3, "``````"); +// } +// } + +void single_quot(void) { + SEND_STRING("\'\'"); +} + void dance_quot (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { tap_key(KC_QUOT); @@ -475,6 +499,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case M_SNIPENT: if (record->event.pressed) { + // surround_type(3, "``````"); code_snippet(); pri_mod(true); register_code(KC_V); @@ -489,6 +514,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { Color shift_color = underglow; shift_color = mod_color(shift_color, true, 25); + // fade_color(underglow, shift_color); set_color(shift_color, false); SEND_STRING(SS_DOWN(X_LSHIFT)); } else { From 915d66c78478b566ef6a3a0abc70efb6c21ae716 Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Mon, 10 Sep 2018 21:46:35 -0600 Subject: [PATCH 04/21] surround_type function implemented and working. --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 47 ++++++-------------- 1 file changed, 14 insertions(+), 33 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 633aa028d527..f9f2c1be93fd 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -226,44 +226,25 @@ void sec_mod(bool press) { } } -void code_snippet(void) { - SEND_STRING("``````" SS_TAP(X_LEFT) SS_TAP(X_LEFT) SS_TAP(X_LEFT)); -} - -void short_snippet(void) { - SEND_STRING("``" SS_TAP(X_LEFT)); +void surround_type(uint8_t num_of_char, uint8_t keycode) { + for (int i = 0; i < num_of_char; i++) { + tap_key(keycode); + } + for (int i = 0; i < (num_of_char/2); i++) { + tap_key(KC_LEFT); + } } void dance_grv (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { tap_key(KC_GRV); } else if (state->count == 2) { - short_snippet(); + surround_type(2, KC_GRAVE); } else { - code_snippet(); + surround_type(6, KC_GRAVE); } } -// void surround_type(uint8_t num_of_char, uint8_t keycode) { -// char str[2*(num_of_char + (num_of_char / 2))]; -// for (int i = 0; i < num_of_char; i++) { -// -// } -// for (int i = 0; i < (num_of_char/2); i++) { -// SEND_STRING(X_LEFT); -// } -// } -// -// void dance_grv (qk_tap_dance_state_t *state, void *user_data) { -// if (state->count == 1) { -// tap_key(KC_GRV); -// } else if (state->count == 2) { -// surround_type(1, "``"); -// } else { -// surround_type(3, "``````"); -// } -// } - void single_quot(void) { SEND_STRING("\'\'"); } @@ -272,9 +253,9 @@ void dance_quot (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { tap_key(KC_QUOT); } else if (state->count == 2) { - single_quot(); - tap_key(KC_LSFT); - tap_key(KC_LEFT); + surround_type(2, KC_QUOTE); + } else if (state->count == 3) { + surround_type(2, KC_DOUBLE_QUOTE); } } @@ -499,8 +480,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case M_SNIPENT: if (record->event.pressed) { - // surround_type(3, "``````"); - code_snippet(); + surround_type(6, KC_GRAVE); + // code_snippet(); pri_mod(true); register_code(KC_V); unregister_code(KC_V); From d45ae602adcc644673c20b42647dd176daf2dc16 Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Tue, 11 Sep 2018 14:03:07 -0600 Subject: [PATCH 05/21] added flashing function and removed fading, flashing supports infinite flashing along with controlled number flashes --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 263 ++++++++++--------- 1 file changed, 146 insertions(+), 117 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index f9f2c1be93fd..bef0f3720ae1 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -37,8 +37,9 @@ void send_unicode_hex_string(const char *str) { #define MOD_CTL_MASK (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) #define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) +#define MOD_SFT_MASK (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) -#define LED_FLASH_DELAY 100 +#define LED_FLASH_DELAY 150 #define EECONFIG_USERSPACE (uint8_t *)20 @@ -48,6 +49,7 @@ void send_unicode_hex_string(const char *str) { #define OPENBRACK TD(TD_BRCK_PARN_O) #define CLOSEBRACK TD(TD_BRCK_PARN_C) #define THREE TD(TD_3_GRV_ACT) +#define STRIKE TD(TD_STRK_SHOT) #define HYPHEN TD(TD_HYPH_UNDR) #define CEDILLA TD(TD_C_CED) #define HTTPS TD(TD_SLSH_HTTP) @@ -70,11 +72,19 @@ typedef struct { uint8_t v; } Color; -uint8_t current_os; -uint8_t mod_primary_mask; -uint16_t flash_start_timer = 0; -bool flash = false, flash_on_started, flash_off_started, paste_ready = false; -Color underglow; +typedef enum { + always_on = 0, + flash_begin, + flash_off, + flash_on, + reset_underglow, +} RGBState; + +uint8_t current_os, mod_primary_mask, num_extra_flashes_off = 0; +uint16_t timer_one, timer_two, elapsed; +bool loop = false, paste_ready = false; +Color underglow, hsv_none = {0,0,0}, hsv_white = {0,0,127}, flash_color; +RGBState current_state = always_on; enum custom_keycodes { M_PMOD = SAFE_RANGE, @@ -82,12 +92,14 @@ enum custom_keycodes { M_P_B, M_C_A_D, M_CALC, - M_SSHOT, M_OS, M_TF, M_TM, M_GGT, M_LOD, + M_BOLD, + M_ITAL, + M_ULIN, M_SNIPENT, M_REPO, M_SHRUG, @@ -101,10 +113,7 @@ enum tapdances { TD_SLSH_HTTP, TD_SING_DOUB, TD_HYPH_UNDR, - TD_NOOP_BOLD, - TD_NOOP_ITAL, - TD_NOOP_UNDR, - TD_NOOP_STRK, + TD_STRK_SHOT, TD_SPECIAL, TD_BRCK_PARN_O, TD_BRCK_PARN_C, @@ -133,29 +142,50 @@ Color mod_color(Color current_color, bool should_add, uint16_t change_amount) { return current_color; } -void set_color(Color new, bool update) { +void set_color (Color new, bool update) { rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); } -void fade_color(Color current_color, Color new_color) { - bool fade_by_adding = current_color.h < new_color.h; - uint16_t difference = 0, temp_hue = current_color.h; - if (fade_by_adding) { - difference = new_color.h - current_color.h; - for (int i = 0; i <= difference; i++) { - temp_hue = (temp_hue + 1)%359; - rgblight_sethsv_eeprom_helper(temp_hue, 255, 255, false); +void flash_rgb (void) { + switch(current_state) { + case always_on: + return; + + case flash_begin: + timer_one = timer_read(); + current_state = flash_off; + + case flash_off: + timer_two = timer_read(); + elapsed = timer_two - timer_one; + if (elapsed >= LED_FLASH_DELAY) { + set_color(hsv_none, false); + timer_one = timer_read(); + current_state = flash_on; } - } else { - difference = current_color.h - new_color.h; - for (int i = 0; i <= difference; i++) { - if (temp_hue == 0){ - temp_hue = 359; + return; + + case flash_on: + timer_two = timer_read(); + elapsed = timer_two - timer_one; + if (elapsed >= LED_FLASH_DELAY) { + set_color(flash_color, false); + timer_one = timer_read(); + if (loop) { + current_state = flash_off; + } else if (num_extra_flashes_off > 0) { + current_state = flash_off; + num_extra_flashes_off--; } else { - temp_hue = (temp_hue - 1); + current_state = reset_underglow; } - rgblight_sethsv_eeprom_helper(temp_hue, 255, 255, false); } + return; + + case reset_underglow: + set_color(underglow, false); + current_state = always_on; + return; } } @@ -184,7 +214,18 @@ void set_os (uint8_t os, bool update) { underglow = (Color){ 0, 0, 255 }; mod_primary_mask = MOD_CTL_MASK; } - flash = true; + set_color(underglow, update); + flash_color = underglow; + current_state = flash_begin; + num_extra_flashes_off = 0; +} + +void set_paste_ready(void) { + paste_ready = true; + set_color(hsv_white, false); + flash_color = hsv_white; + current_state = flash_begin; + num_extra_flashes_off = 2; } void tap_key(uint8_t keycode) { @@ -226,36 +267,60 @@ void sec_mod(bool press) { } } -void surround_type(uint8_t num_of_char, uint8_t keycode) { - for (int i = 0; i < num_of_char; i++) { +void surround_type(uint8_t num_of_chars, uint16_t keycode, bool use_shift) { + if (use_shift) { + register_code(KC_LSFT); + } + for (int i = 0; i < num_of_chars; i++) { tap_key(keycode); } - for (int i = 0; i < (num_of_char/2); i++) { + if (use_shift) { + unregister_code(KC_LSFT); + } + for (int i = 0; i < (num_of_chars/2); i++) { tap_key(KC_LEFT); } } +void long_keystroke(size_t num_of_keys, uint16_t keys[]) { + for (int i = 0; i < num_of_keys-1; i++) { + register_code(keys[i]); + } + tap_key(keys[num_of_keys-1]); + for (int i = 0; i < num_of_keys-1; i++) { + unregister_code(keys[i]); + } +} + void dance_grv (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { tap_key(KC_GRV); } else if (state->count == 2) { - surround_type(2, KC_GRAVE); + surround_type(2, KC_GRAVE, false); } else { - surround_type(6, KC_GRAVE); + surround_type(6, KC_GRAVE, false); } } -void single_quot(void) { - SEND_STRING("\'\'"); -} - void dance_quot (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { tap_key(KC_QUOT); } else if (state->count == 2) { - surround_type(2, KC_QUOTE); + surround_type(2, KC_QUOTE, false); } else if (state->count == 3) { - surround_type(2, KC_DOUBLE_QUOTE); + surround_type(2, KC_QUOTE, true); + } +} + +void dance_strk (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + surround_type(4, KC_TILDE, true); + } else if (state->count == 2) { + if (current_os == OS_MAC) { + long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_4}); + } else if (current_os == OS_WIN) { + long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_S}); + } } } @@ -279,18 +344,32 @@ void dance_http (qk_tap_dance_state_t *state, void *user_data) { void send_copy_paste (void) { pri_mod(true); - if (!paste_ready) {SEND_STRING(SS_TAP(X_C));} - else {SEND_STRING(SS_TAP(X_V));} + if (!paste_ready) { + SEND_STRING(SS_TAP(X_C)); + set_paste_ready(); + loop = true; + } + else { + SEND_STRING(SS_TAP(X_V)); + paste_ready = false; + loop = false; + } pri_mod(false); - paste_ready = !paste_ready; } void send_cut_paste (void) { pri_mod(true); - if (!paste_ready) {SEND_STRING(SS_TAP(X_X));} - else {SEND_STRING(SS_TAP(X_V));} + if (!paste_ready) { + SEND_STRING(SS_TAP(X_X)); + set_paste_ready(); + loop = true; + } + else { + SEND_STRING(SS_TAP(X_V)); + paste_ready = false; + loop = false; + } pri_mod(false); - paste_ready = !paste_ready; } void send_lod(void) { @@ -333,6 +412,7 @@ qk_tap_dance_action_t tap_dance_actions[] = { [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), [TD_SLSH_HTTP] = ACTION_TAP_DANCE_FN (dance_http), [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), + [TD_STRK_SHOT] = ACTION_TAP_DANCE_FN (dance_strk), [TD_SPECIAL] = ACTION_TAP_DANCE_FN (dance_special), [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), @@ -346,28 +426,7 @@ void matrix_init_user(void) { } void matrix_scan_user(void) { - if (flash && !flash_on_started && !flash_off_started) { - flash_start_timer = timer_read(); - flash_on_started = true; - set_color(underglow, false); - } else if (flash && flash_on_started && !flash_off_started) { - uint16_t flash_timer = timer_read(); - uint16_t elapsed = flash_timer - flash_start_timer; - if (elapsed >= LED_FLASH_DELAY) { - flash_on_started = false; - flash_off_started = true; - rgblight_sethsv_eeprom_helper(0, 255, 0, false); - flash_start_timer = timer_read(); - } - } else if (flash && flash_off_started && !flash_on_started) { - uint16_t flash_timer = timer_read(); - uint16_t elapsed = flash_timer - flash_start_timer; - if (elapsed >= LED_FLASH_DELAY) { - flash_off_started = false; - flash = false; - set_color(underglow, true); - } - } + flash_rgb(); } bool process_record_user(uint16_t keycode, keyrecord_t *record) { @@ -417,19 +476,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return false; - case M_SSHOT: - if (record->event.pressed) { - if (current_os == OS_WIN) { - SEND_STRING(SS_DOWN(X_LGUI) SS_DOWN(X_LSHIFT) SS_TAP(X_S) SS_UP(X_LSHIFT) SS_UP(X_LGUI)); - } else if (current_os == OS_MAC) { - SEND_STRING(SS_DOWN(X_LGUI) SS_DOWN(X_LSHIFT) SS_TAP(X_4) SS_UP(X_LSHIFT) SS_UP(X_LGUI)); - } else { - return true; - } - paste_ready = true; - } - return false; - case M_OS: if (record->event.pressed) { set_os((current_os+1) % _OS_COUNT, true); @@ -480,8 +526,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case M_SNIPENT: if (record->event.pressed) { - surround_type(6, KC_GRAVE); - // code_snippet(); + surround_type(6, KC_GRAVE, false); pri_mod(true); register_code(KC_V); unregister_code(KC_V); @@ -491,42 +536,33 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return false; - case KC_LSFT: + case M_BOLD: if (record->event.pressed) { - Color shift_color = underglow; - shift_color = mod_color(shift_color, true, 25); - // fade_color(underglow, shift_color); - set_color(shift_color, false); - SEND_STRING(SS_DOWN(X_LSHIFT)); - } else { - set_color(underglow, false); - SEND_STRING(SS_UP(X_LSHIFT)); + surround_type(4, KC_8, true); } return false; - case KC_C: + case M_ITAL: if (record->event.pressed) { - if(get_mods() & mod_primary_mask) { - paste_ready = true; - } + surround_type(2, KC_8, true); } - return true; + return false; - case KC_X: + case M_ULIN: if (record->event.pressed) { - if(get_mods() & mod_primary_mask) { - paste_ready = true; - } + surround_type(4, KC_MINS, true); } - return true; + return false; - case KC_V: + case KC_LSFT: if (record->event.pressed) { - if(get_mods() & mod_primary_mask) { - paste_ready = false; - } + set_color(mod_color(underglow, true, 50), false); + SEND_STRING(SS_DOWN(X_LSHIFT)); + } else { + set_color(underglow, false); + SEND_STRING(SS_UP(X_LSHIFT)); } - return true; + return false; case KEEB: case RAISE: @@ -535,7 +571,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { break; case KC_BSPC: - // reverse color on backspace, no reset if (record->event.pressed) { underglow = mod_color(underglow, false, 10); set_color(underglow, false); @@ -546,7 +581,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return false; default: - // add to hue by default, no reset if (record->event.pressed) { underglow = mod_color(underglow, true, 10); set_color(underglow, false); @@ -557,28 +591,23 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { uint32_t layer_state_set_user(uint32_t state) { Color layer = underglow; - switch (biton32(state)) { case _MEDIA: layer = mod_color(layer, true, 150); - set_color(layer, false); break; case _KEEB: layer = mod_color(layer, false, 150); - set_color(layer, false); break; case _LOWER: layer = mod_color(layer, false, 100 ); - set_color(layer, false); break; case _RAISE: layer = mod_color(layer, true, 100); - set_color(layer, false); break; default: - set_color(underglow, false); break; } + set_color(layer, false); return state; } @@ -597,9 +626,9 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, KEEB, _______, _______, HTTPS, M_OS, KC_PSLS, KC_PMNS, KC_PAST), [_LOWER] = LAYOUT_2u_space_ortho( - _______, _______, _______, _______, _______, M_TM, _______, _______, _______, _______, M_P_B, M_C_A_D, - _______, _______, M_SSHOT, _______, _______, M_GGT, _______, M_UF, M_REPO, M_SNIPENT, _______, _______, - _______, KC_DEL, _______, _______, _______, _______, _______, M_TF, M_SHRUG, M_LOD, KC_PGUP, _______, + _______, _______, _______, _______, _______, M_TM, _______, M_ULIN, M_ITAL, _______, M_P_B, M_C_A_D, + _______, _______, STRIKE, _______, _______, M_GGT, _______, M_UF, M_REPO, M_SNIPENT, _______, _______, + _______, KC_DEL, _______, _______, _______, M_BOLD, _______, M_TF, M_SHRUG, M_LOD, KC_PGUP, _______, _______, _______, _______, _______, _______, MEDIA, _______, M_CALC, KC_HOME, KC_PGDOWN, KC_END), [_KEEB] = LAYOUT_2u_space_ortho( From ecfd9b64311855a114844945d5d6f9b64c65f483 Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Tue, 11 Sep 2018 17:31:10 -0600 Subject: [PATCH 06/21] added a fade state machine and functionality --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 112 +++++++++++++------ 1 file changed, 75 insertions(+), 37 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index bef0f3720ae1..55245a35001e 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -39,7 +39,8 @@ void send_unicode_hex_string(const char *str) { #define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) #define MOD_SFT_MASK (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) -#define LED_FLASH_DELAY 150 +#define LED_FLASH_DELAY 150 +#define LED_FADE_DELAY 10 #define EECONFIG_USERSPACE (uint8_t *)20 @@ -78,13 +79,21 @@ typedef enum { flash_off, flash_on, reset_underglow, -} RGBState; +} flashState; + +typedef enum { + start = 0, + fade, + stop, +} fadeState; + +uint8_t current_os, mod_primary_mask, num_extra_flashes_off = 0; +uint16_t flash_timer_one, flash_timer_two, fade_timer_one, fade_timer_two, elapsed, fade_buffer = 0; +bool loop = false, paste_ready = false; +Color underglow, hsv_none = {0,0,0}, hsv_white = {0,0,127}, flash_color; +flashState flash_state = always_on; +fadeState fade_state = stop; -uint8_t current_os, mod_primary_mask, num_extra_flashes_off = 0; -uint16_t timer_one, timer_two, elapsed; -bool loop = false, paste_ready = false; -Color underglow, hsv_none = {0,0,0}, hsv_white = {0,0,127}, flash_color; -RGBState current_state = always_on; enum custom_keycodes { M_PMOD = SAFE_RANGE, @@ -146,45 +155,76 @@ void set_color (Color new, bool update) { rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); } +void fade_rgb (void) { + if (flash_state != always_on) {return;} + switch(fade_state){ + case start: + fade_timer_one = timer_read(); + fade_state = fade; + + case fade: + fade_timer_two = timer_read(); + elapsed = fade_timer_two - fade_timer_one; + if (elapsed < LED_FADE_DELAY) {return;} + if (fade_buffer > 0) { + underglow.h = (underglow.h + 1)%359; + set_color(underglow, false); + fade_timer_one = fade_timer_two; + fade_buffer--; + } else { + fade_state = stop; + } + return; + + case stop: + return; + } + +} + void flash_rgb (void) { - switch(current_state) { + switch(flash_state) { case always_on: return; case flash_begin: - timer_one = timer_read(); - current_state = flash_off; + flash_timer_one = timer_read(); + flash_state = flash_off; + if (fade_state != stop) { + fade_state = stop; + } + return; case flash_off: - timer_two = timer_read(); - elapsed = timer_two - timer_one; + flash_timer_two = timer_read(); + elapsed = flash_timer_two - flash_timer_one; if (elapsed >= LED_FLASH_DELAY) { set_color(hsv_none, false); - timer_one = timer_read(); - current_state = flash_on; + flash_timer_one = timer_read(); + flash_state = flash_on; } return; case flash_on: - timer_two = timer_read(); - elapsed = timer_two - timer_one; + flash_timer_two = timer_read(); + elapsed = flash_timer_two - flash_timer_one; if (elapsed >= LED_FLASH_DELAY) { set_color(flash_color, false); - timer_one = timer_read(); + flash_timer_one = timer_read(); if (loop) { - current_state = flash_off; + flash_state = flash_off; } else if (num_extra_flashes_off > 0) { - current_state = flash_off; + flash_state = flash_off; num_extra_flashes_off--; } else { - current_state = reset_underglow; + flash_state = reset_underglow; } } return; case reset_underglow: set_color(underglow, false); - current_state = always_on; + flash_state = always_on; return; } } @@ -216,7 +256,7 @@ void set_os (uint8_t os, bool update) { } set_color(underglow, update); flash_color = underglow; - current_state = flash_begin; + flash_state = flash_begin; num_extra_flashes_off = 0; } @@ -224,8 +264,8 @@ void set_paste_ready(void) { paste_ready = true; set_color(hsv_white, false); flash_color = hsv_white; - current_state = flash_begin; - num_extra_flashes_off = 2; + flash_state = flash_begin; + loop = true; } void tap_key(uint8_t keycode) { @@ -320,7 +360,10 @@ void dance_strk (qk_tap_dance_state_t *state, void *user_data) { long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_4}); } else if (current_os == OS_WIN) { long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_S}); + } else { + return; } + set_paste_ready(); } } @@ -347,7 +390,6 @@ void send_copy_paste (void) { if (!paste_ready) { SEND_STRING(SS_TAP(X_C)); set_paste_ready(); - loop = true; } else { SEND_STRING(SS_TAP(X_V)); @@ -378,6 +420,8 @@ void send_lod(void) { void dance_special (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { + paste_ready = false; + loop = false; } else if (state->count == 2) { send_copy_paste(); } else if (state->count == 3) { @@ -427,6 +471,7 @@ void matrix_init_user(void) { void matrix_scan_user(void) { flash_rgb(); + fade_rgb(); } bool process_record_user(uint16_t keycode, keyrecord_t *record) { @@ -570,20 +615,13 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; break; - case KC_BSPC: - if (record->event.pressed) { - underglow = mod_color(underglow, false, 10); - set_color(underglow, false); - SEND_STRING(SS_DOWN(X_BSPACE)); - } else { - SEND_STRING(SS_UP(X_BSPACE)); - } - return false; - default: if (record->event.pressed) { - underglow = mod_color(underglow, true, 10); - set_color(underglow, false); + fade_buffer+=50; + if (fade_buffer >= 100){fade_buffer = 100;} + if (fade_state == stop) { + fade_state = start; + } } return true; } From 84e5428d95d7273cbfca441669738ad3d818ee75 Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Wed, 12 Sep 2018 16:24:46 -0600 Subject: [PATCH 07/21] build optimizations, changed fade to bounce between bounds rather than roll over, added a HALMAK layout --- keyboards/mechmini/v2/keymaps/arkag/config.h | 9 +- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 133 +++++++++++++------ keyboards/mechmini/v2/keymaps/arkag/rules.mk | 5 +- 3 files changed, 104 insertions(+), 43 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/config.h b/keyboards/mechmini/v2/keymaps/arkag/config.h index 926abb13255e..8c56fd2248b6 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/config.h +++ b/keyboards/mechmini/v2/keymaps/arkag/config.h @@ -1,8 +1,9 @@ #pragma once -#define CONFIG_USER_H - #define TAPPING_TERM 200 -#define ONESHOT_TIMEOUT 1000 -#define ONESHOT_TAP_TOGGLE 4 +// save me space! +#define NO_ACTION_MACRO +#define NO_ACTION_FUNCTION +#define DISABLE_LEADER +#define NO_MUSIC_MODE diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 55245a35001e..fd9036681e5c 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -29,11 +29,29 @@ void send_unicode_hex_string(const char *str) { } // End: Written by konstantin: vomindoraan +// Start: Written by drashna + +extern rgblight_config_t rgblight_config; +uint8_t last_rgb_mode; + +void suspend_power_down_user(void) { + last_rgb_mode = rgblight_config.mode; + rgblight_enable_noeeprom(); + rgblight_timer_enable(); + rgblight_mode_noeeprom(3); +} + +void suspend_wakeup_init_user(void) { + rgblight_mode_noeeprom(1); +} +// End: Written by drashna + #define _BASE 0 #define _RAISE 1 #define _LOWER 2 #define _KEEB 3 #define _MEDIA 4 +#define _HALMAK 5 #define MOD_CTL_MASK (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) #define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) @@ -59,6 +77,7 @@ void send_unicode_hex_string(const char *str) { #define LOWER MO(2) #define RAISE MO(1) #define MEDIA MO(4) +#define HALMAK TG(4) typedef enum { OS_MAC, // Don't assign values @@ -74,7 +93,7 @@ typedef struct { } Color; typedef enum { - always_on = 0, + no_flash = 0, flash_begin, flash_off, flash_on, @@ -82,17 +101,25 @@ typedef enum { } flashState; typedef enum { - start = 0, - fade, - stop, + fade = 0, + add_fade, + sub_fade, } fadeState; -uint8_t current_os, mod_primary_mask, num_extra_flashes_off = 0; -uint16_t flash_timer_one, flash_timer_two, fade_timer_one, fade_timer_two, elapsed, fade_buffer = 0; -bool loop = false, paste_ready = false; -Color underglow, hsv_none = {0,0,0}, hsv_white = {0,0,127}, flash_color; -flashState flash_state = always_on; -fadeState fade_state = stop; +uint8_t current_os, mod_primary_mask; +uint16_t flash_timer_one, flash_timer_two, fade_timer_one, fade_timer_two, elapsed, + fade_buffer = 0, + real_fade_delay = LED_FADE_DELAY, + num_extra_flashes_off = 0; +int16_t ug_fade_buffer = 0; +bool loop = false, + paste_ready = false; +Color underglow, + flash_color, + hsv_none = {0,0,0}, + hsv_white = {0,0,127}; +flashState flash_state = no_flash; +fadeState fade_state = fade; enum custom_keycodes { @@ -130,9 +157,9 @@ enum tapdances { }; Color mod_color(Color current_color, bool should_add, uint16_t change_amount) { - uint16_t addlim = 359 - change_amount; - uint16_t sublim = change_amount; - uint16_t leftovers; + int addlim = 359 - change_amount; + int sublim = change_amount; + int leftovers; if (should_add) { if (current_color.h <= addlim) { current_color.h += change_amount; @@ -156,43 +183,63 @@ void set_color (Color new, bool update) { } void fade_rgb (void) { - if (flash_state != always_on) {return;} + if (flash_state != no_flash) {return;} + if (fade_buffer >= 50) {fade_buffer = 50;} switch(fade_state){ - case start: + case fade: + if (fade_buffer <= 0) {return;} + if (flash_state != no_flash) {return;} + real_fade_delay = LED_FADE_DELAY; fade_timer_one = timer_read(); - fade_state = fade; + fade_state = add_fade; + return; - case fade: + case add_fade: fade_timer_two = timer_read(); elapsed = fade_timer_two - fade_timer_one; - if (elapsed < LED_FADE_DELAY) {return;} + if (elapsed < real_fade_delay) {return;} if (fade_buffer > 0) { - underglow.h = (underglow.h + 1)%359; + if (underglow.h == 359) { + fade_state = sub_fade; + return; + } + underglow.h = underglow.h + 1; set_color(underglow, false); fade_timer_one = fade_timer_two; fade_buffer--; } else { - fade_state = stop; + fade_state = fade; } return; - case stop: + case sub_fade: + fade_timer_two = timer_read(); + elapsed = fade_timer_two - fade_timer_one; + if (elapsed < real_fade_delay) {return;} + if (fade_buffer > 0) { + if (underglow.h == 0) { + fade_state = add_fade; + return; + } + underglow.h = underglow.h - 1; + set_color(underglow, false); + fade_timer_one = fade_timer_two; + fade_buffer--; + } else { + fade_state = fade; + } return; } - } void flash_rgb (void) { switch(flash_state) { - case always_on: + case no_flash: return; case flash_begin: flash_timer_one = timer_read(); flash_state = flash_off; - if (fade_state != stop) { - fade_state = stop; - } return; case flash_off: @@ -224,7 +271,7 @@ void flash_rgb (void) { case reset_underglow: set_color(underglow, false); - flash_state = always_on; + flash_state = no_flash; return; } } @@ -615,37 +662,41 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; break; + case HALMAK: + flash_color = underglow; + flash_state = flash_begin; + num_extra_flashes_off = 5; + return true; + break; + default: if (record->event.pressed) { fade_buffer+=50; - if (fade_buffer >= 100){fade_buffer = 100;} - if (fade_state == stop) { - fade_state = start; - } } return true; } } uint32_t layer_state_set_user(uint32_t state) { - Color layer = underglow; switch (biton32(state)) { case _MEDIA: - layer = mod_color(layer, true, 150); + set_color(mod_color(underglow, true, 150), false); break; case _KEEB: - layer = mod_color(layer, false, 150); + set_color(mod_color(underglow, false, 150), false); break; case _LOWER: - layer = mod_color(layer, false, 100 ); + set_color(mod_color(underglow, false, 100), false); break; case _RAISE: - layer = mod_color(layer, true, 100); + set_color(mod_color(underglow, true, 100), false); break; + case _HALMAK: + default: + set_color(underglow, false); break; } - set_color(layer, false); return state; } @@ -657,6 +708,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, SPECIAL, KC_LEFT, KC_DOWN, KC_RGHT), + [_HALMAK] = LAYOUT_2u_space_ortho( + KC_ESC, KC_W, KC_L, KC_R, KC_B, KC_Z, KC_SCLN, KC_Q, KC_U, KC_D, KC_J, KC_BSPC, + KC_TAB, KC_S, KC_H, KC_N, KC_T, KC_COMM, KC_DOT, KC_A, KC_E, KC_O, KC_I, QUOTE, + KC_LSFT, KC_F, KC_M, KC_V, KC_C, KC_SLSH, KC_G, KC_P, KC_X, KC_K, KC_Y, KC_ENT, + M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, SPECIAL, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT), + [_RAISE] = LAYOUT_2u_space_ortho( GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, _______, OPENBRACK, CLOSEBRACK, KC_BSLS, HYPHEN, KC_EQL, _______, KC_4, KC_5, KC_6, _______, KC_NLCK, @@ -679,5 +736,5 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_VOLU, KC_MUTE, - _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT), + HALMAK, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT), }; diff --git a/keyboards/mechmini/v2/keymaps/arkag/rules.mk b/keyboards/mechmini/v2/keymaps/arkag/rules.mk index b93dba064a6d..d6c210e9e867 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/rules.mk +++ b/keyboards/mechmini/v2/keymaps/arkag/rules.mk @@ -4,10 +4,13 @@ STENO_ENABLE = no EXTRAKEY_ENABLE = yes CONSOLE_ENABLE = no COMMAND_ENABLE = no -SLEEP_LED_ENABLE = yes +SLEEP_LED_ENABLE = no NKRO_ENABLE = yes BACKLIGHT_ENABLE = yes AUDIO_ENABLE = no RGBLIGHT_ENABLE = yes TAP_DANCE_ENABLE = yes UNICODE_ENABLE = yes + +# save me space! +EXTRAFLAGS += -flto From 11b9e19e67980b222a91f4f108d568aedd8310cd Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Wed, 12 Sep 2018 17:23:05 -0600 Subject: [PATCH 08/21] changes to sleep breath function, changed how I will switch to HALMAK --- keyboards/mechmini/v2/keymaps/arkag/config.h | 2 + keyboards/mechmini/v2/keymaps/arkag/keymap.c | 81 ++++++++++---------- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/config.h b/keyboards/mechmini/v2/keymaps/arkag/config.h index 8c56fd2248b6..3ad52a9e7238 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/config.h +++ b/keyboards/mechmini/v2/keymaps/arkag/config.h @@ -2,6 +2,8 @@ #define TAPPING_TERM 200 +#define NO_SUSPEND_POWER_DOWN + // save me space! #define NO_ACTION_MACRO #define NO_ACTION_FUNCTION diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index fd9036681e5c..ccedd961e588 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -29,29 +29,12 @@ void send_unicode_hex_string(const char *str) { } // End: Written by konstantin: vomindoraan -// Start: Written by drashna - -extern rgblight_config_t rgblight_config; -uint8_t last_rgb_mode; - -void suspend_power_down_user(void) { - last_rgb_mode = rgblight_config.mode; - rgblight_enable_noeeprom(); - rgblight_timer_enable(); - rgblight_mode_noeeprom(3); -} - -void suspend_wakeup_init_user(void) { - rgblight_mode_noeeprom(1); -} -// End: Written by drashna - -#define _BASE 0 +//#define _HALMAK 0 +#define _QWERTY 0 #define _RAISE 1 #define _LOWER 2 #define _KEEB 3 #define _MEDIA 4 -#define _HALMAK 5 #define MOD_CTL_MASK (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) #define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) @@ -60,6 +43,8 @@ void suspend_wakeup_init_user(void) { #define LED_FLASH_DELAY 150 #define LED_FADE_DELAY 10 +#define DEF_RGB_MODE 1 // static + #define EECONFIG_USERSPACE (uint8_t *)20 #define LRALT TD(TD_LALT_RALT) @@ -73,11 +58,11 @@ void suspend_wakeup_init_user(void) { #define CEDILLA TD(TD_C_CED) #define HTTPS TD(TD_SLSH_HTTP) #define SPECIAL TD(TD_SPECIAL) -#define KEEB MO(3) -#define LOWER MO(2) + #define RAISE MO(1) +#define LOWER MO(2) +#define KEEB MO(3) #define MEDIA MO(4) -#define HALMAK TG(4) typedef enum { OS_MAC, // Don't assign values @@ -156,6 +141,27 @@ enum tapdances { TD_LALT_RALT, }; +// Start: Written by drashna +uint8_t last_rgb_mode; + +void suspend_power_down_user(void) { + last_rgb_mode = rgblight_get_mode(); + rgblight_enable_noeeprom(); + rgblight_timer_enable(); + rgblight_mode_noeeprom(4); +} + +void suspend_wakeup_init_user(void) { + static bool ran_once; + if (!ran_once) { + ran_once = true; + rgblight_mode_noeeprom(DEF_RGB_MODE); + return; + } + rgblight_mode_noeeprom(last_rgb_mode); +} +// End: Written by drashna + Color mod_color(Color current_color, bool should_add, uint16_t change_amount) { int addlim = 359 - change_amount; int sublim = change_amount; @@ -187,8 +193,8 @@ void fade_rgb (void) { if (fade_buffer >= 50) {fade_buffer = 50;} switch(fade_state){ case fade: - if (fade_buffer <= 0) {return;} - if (flash_state != no_flash) {return;} + if (fade_buffer <= 0) {return;} + if (flash_state != no_flash) {return;} real_fade_delay = LED_FADE_DELAY; fade_timer_one = timer_read(); fade_state = add_fade; @@ -514,6 +520,7 @@ qk_tap_dance_action_t tap_dance_actions[] = { void matrix_init_user(void) { current_os = eeprom_read_byte(EECONFIG_USERSPACE); set_os(current_os, false); + last_rgb_mode = rgblight_get_mode(); } void matrix_scan_user(void) { @@ -660,14 +667,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case RAISE: case LOWER: return true; - break; - - case HALMAK: - flash_color = underglow; - flash_state = flash_begin; - num_extra_flashes_off = 5; - return true; - break; default: if (record->event.pressed) { @@ -691,8 +690,6 @@ uint32_t layer_state_set_user(uint32_t state) { case _RAISE: set_color(mod_color(underglow, true, 100), false); break; - case _HALMAK: - default: set_color(underglow, false); break; @@ -702,17 +699,17 @@ uint32_t layer_state_set_user(uint32_t state) { const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_BASE] = LAYOUT_2u_space_ortho( + [_QWERTY] = LAYOUT_2u_space_ortho( KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, QUOTE, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, SPECIAL, KC_LEFT, KC_DOWN, KC_RGHT), - [_HALMAK] = LAYOUT_2u_space_ortho( - KC_ESC, KC_W, KC_L, KC_R, KC_B, KC_Z, KC_SCLN, KC_Q, KC_U, KC_D, KC_J, KC_BSPC, - KC_TAB, KC_S, KC_H, KC_N, KC_T, KC_COMM, KC_DOT, KC_A, KC_E, KC_O, KC_I, QUOTE, - KC_LSFT, KC_F, KC_M, KC_V, KC_C, KC_SLSH, KC_G, KC_P, KC_X, KC_K, KC_Y, KC_ENT, - M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, SPECIAL, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT), + // [_HALMAK] = LAYOUT_2u_space_ortho( + // KC_ESC, KC_W, KC_L, KC_R, KC_B, KC_Z, KC_SCLN, KC_Q, KC_U, KC_D, KC_J, KC_BSPC, + // KC_TAB, KC_S, KC_H, KC_N, KC_T, KC_COMM, KC_DOT, KC_A, KC_E, KC_O, KC_I, QUOTE, + // KC_LSFT, KC_F, KC_M, KC_V, KC_C, KC_SLSH, KC_G, KC_P, KC_X, KC_K, KC_Y, KC_ENT, + // M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, SPECIAL, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT), [_RAISE] = LAYOUT_2u_space_ortho( GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, @@ -729,12 +726,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_KEEB] = LAYOUT_2u_space_ortho( KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, BL_TOGG, BL_STEP, BL_INC, BL_DEC, BL_BRTG, _______, _______, _______, _______, _______, _______, - _______, RGB_TOG, RGB_MOD, RGB_VAI, RGB_VAD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, _______, _______, _______, + RGB_M_P, RGB_TOG, RGB_MOD, RGB_VAI, RGB_VAD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, _______, _______, _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), [_MEDIA] = LAYOUT_2u_space_ortho( _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_VOLU, KC_MUTE, - HALMAK, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT), + _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT), }; From 957a7f693df505ac39429f638c0c7059ae97dac0 Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Wed, 12 Sep 2018 19:52:00 -0600 Subject: [PATCH 09/21] support for halmak added --- keyboards/mechmini/v2/keymaps/arkag/config.h | 2 + keyboards/mechmini/v2/keymaps/arkag/keymap.c | 47 ++++++++++++++++---- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/config.h b/keyboards/mechmini/v2/keymaps/arkag/config.h index 3ad52a9e7238..d219c1c46eb8 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/config.h +++ b/keyboards/mechmini/v2/keymaps/arkag/config.h @@ -4,6 +4,8 @@ #define NO_SUSPEND_POWER_DOWN +#define HALMAK_LAYOUT + // save me space! #define NO_ACTION_MACRO #define NO_ACTION_FUNCTION diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index ccedd961e588..3fbc201a9b6c 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -28,9 +28,12 @@ void send_unicode_hex_string(const char *str) { } } // End: Written by konstantin: vomindoraan - -//#define _HALMAK 0 +#ifdef HALMAK_LAYOUT +#define _HALMAK 0 +#endif +#ifdef QWERTY_LAYOUT #define _QWERTY 0 +#endif #define _RAISE 1 #define _LOWER 2 #define _KEEB 3 @@ -697,20 +700,47 @@ uint32_t layer_state_set_user(uint32_t state) { return state; } +#ifdef HALMAK_LAYOUT const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_HALMAK] = LAYOUT_2u_space_ortho( + KC_ESC, KC_W, KC_L, KC_R, KC_B, KC_Z, KC_SCLN, KC_Q, KC_U, KC_D, KC_J, KC_BSPC, + KC_TAB, KC_S, KC_H, KC_N, KC_T, KC_COMM, KC_DOT, KC_A, KC_E, KC_O, KC_I, QUOTE, + KC_LSFT, KC_F, KC_M, KC_V, KC_C, KC_SLSH, KC_G, KC_P, KC_X, KC_K, KC_Y, KC_ENT, + M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, SPECIAL, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT), + + [_RAISE] = LAYOUT_2u_space_ortho( + GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, + _______, OPENBRACK, CLOSEBRACK, KC_EQL, HYPHEN, _______, _______, KC_4, KC_5, KC_6, _______, KC_NLCK, + _______, _______, _______, _______, CEDILLA, KC_BSLS, _______, KC_1, KC_2, KC_3, _______, KC_PENT, + _______, _______, _______, KEEB, _______, _______, M_OS, KC_PSLS, KC_PMNS, KC_PPLS, KC_PAST), + + [_LOWER] = LAYOUT_2u_space_ortho( + _______, _______, _______, _______, _______, M_BOLD, _______, _______, M_ULIN, _______, M_P_B, M_C_A_D, + _______, STRIKE, _______, _______, M_TM, _______, _______, M_UF, M_REPO, M_SNIPENT, M_ITAL, _______, + _______, KC_DEL, _______, _______, _______, _______, M_GGT, M_TF, M_SHRUG, M_LOD, _______, _______, + _______, _______, _______, _______, _______, MEDIA, M_CALC, KC_HOME, KC_PGDOWN, KC_PGUP, KC_END), + [_KEEB] = LAYOUT_2u_space_ortho( + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, + _______, BL_TOGG, BL_STEP, BL_INC, BL_DEC, BL_BRTG, _______, _______, _______, _______, _______, _______, + RGB_M_P, RGB_TOG, RGB_MOD, RGB_VAI, RGB_VAD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, _______, _______, _______, + RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), + + [_MEDIA] = LAYOUT_2u_space_ortho( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, _______, _______, KC_MPLY, + _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_VOLU, KC_MNXT), +}; +#endif +#ifdef QWERTY_LAYOUT +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_QWERTY] = LAYOUT_2u_space_ortho( KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, QUOTE, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, SPECIAL, KC_LEFT, KC_DOWN, KC_RGHT), - // [_HALMAK] = LAYOUT_2u_space_ortho( - // KC_ESC, KC_W, KC_L, KC_R, KC_B, KC_Z, KC_SCLN, KC_Q, KC_U, KC_D, KC_J, KC_BSPC, - // KC_TAB, KC_S, KC_H, KC_N, KC_T, KC_COMM, KC_DOT, KC_A, KC_E, KC_O, KC_I, QUOTE, - // KC_LSFT, KC_F, KC_M, KC_V, KC_C, KC_SLSH, KC_G, KC_P, KC_X, KC_K, KC_Y, KC_ENT, - // M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, SPECIAL, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT), - [_RAISE] = LAYOUT_2u_space_ortho( GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, _______, OPENBRACK, CLOSEBRACK, KC_BSLS, HYPHEN, KC_EQL, _______, KC_4, KC_5, KC_6, _______, KC_NLCK, @@ -735,3 +765,4 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_VOLU, KC_MUTE, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT), }; +#endif From a391f6375c7a0896a0c906b1e8ad30908344c2ea Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Thu, 13 Sep 2018 16:47:01 -0600 Subject: [PATCH 10/21] support for activity detection added, condensed fading and flashing state machines, removed support for HALMAK and COLEMAK because arkag is stupid --- keyboards/mechmini/v2/keymaps/arkag/config.h | 4 - keyboards/mechmini/v2/keymaps/arkag/keymap.c | 377 +++++++------------ 2 files changed, 137 insertions(+), 244 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/config.h b/keyboards/mechmini/v2/keymaps/arkag/config.h index d219c1c46eb8..8c56fd2248b6 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/config.h +++ b/keyboards/mechmini/v2/keymaps/arkag/config.h @@ -2,10 +2,6 @@ #define TAPPING_TERM 200 -#define NO_SUSPEND_POWER_DOWN - -#define HALMAK_LAYOUT - // save me space! #define NO_ACTION_MACRO #define NO_ACTION_FUNCTION diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 3fbc201a9b6c..cab5a64324ea 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -28,16 +28,12 @@ void send_unicode_hex_string(const char *str) { } } // End: Written by konstantin: vomindoraan -#ifdef HALMAK_LAYOUT -#define _HALMAK 0 -#endif -#ifdef QWERTY_LAYOUT #define _QWERTY 0 -#endif #define _RAISE 1 #define _LOWER 2 #define _KEEB 3 #define _MEDIA 4 +#define _LAZY 5 #define MOD_CTL_MASK (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) #define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) @@ -46,6 +42,9 @@ void send_unicode_hex_string(const char *str) { #define LED_FLASH_DELAY 150 #define LED_FADE_DELAY 10 +#define INACTIVE_DELAY 200 +#define SLEEP_DELAY 60000 + #define DEF_RGB_MODE 1 // static #define EECONFIG_USERSPACE (uint8_t *)20 @@ -53,19 +52,18 @@ void send_unicode_hex_string(const char *str) { #define LRALT TD(TD_LALT_RALT) #define QUOTE TD(TD_SING_DOUB) #define GRAVE TD(TD_GRV_3GRV) -#define OPENBRACK TD(TD_BRCK_PARN_O) -#define CLOSEBRACK TD(TD_BRCK_PARN_C) +#define OBRACK TD(TD_BRCK_PARN_O) +#define CBRACK TD(TD_BRCK_PARN_C) #define THREE TD(TD_3_GRV_ACT) #define STRIKE TD(TD_STRK_SHOT) #define HYPHEN TD(TD_HYPH_UNDR) #define CEDILLA TD(TD_C_CED) -#define HTTPS TD(TD_SLSH_HTTP) -#define SPECIAL TD(TD_SPECIAL) #define RAISE MO(1) #define LOWER MO(2) #define KEEB MO(3) #define MEDIA MO(4) +#define LAZY MO(5) typedef enum { OS_MAC, // Don't assign values @@ -82,33 +80,34 @@ typedef struct { typedef enum { no_flash = 0, - flash_begin, flash_off, flash_on, - reset_underglow, } flashState; typedef enum { - fade = 0, - add_fade, + add_fade = 0, sub_fade, } fadeState; -uint8_t current_os, mod_primary_mask; -uint16_t flash_timer_one, flash_timer_two, fade_timer_one, fade_timer_two, elapsed, - fade_buffer = 0, - real_fade_delay = LED_FADE_DELAY, - num_extra_flashes_off = 0; -int16_t ug_fade_buffer = 0; -bool loop = false, - paste_ready = false; -Color underglow, - flash_color, - hsv_none = {0,0,0}, - hsv_white = {0,0,127}; -flashState flash_state = no_flash; -fadeState fade_state = fade; - +typedef enum { + active = 0, + inactive, + sleeping, +} activityState; + +uint8_t current_os, mod_primary_mask; +uint16_t flash_timer_one, flash_timer_two, + fade_timer_one, fade_timer_two, + active_timer_one, active_timer_two, + elapsed = 0, + num_extra_flashes_off = 0; +Color underglow, + flash_color, + hsv_none = {0,0,0}, + hsv_white = {0,0,127}; +flashState flash_state = no_flash; +fadeState fade_state = add_fade; +activityState state = inactive; enum custom_keycodes { M_PMOD = SAFE_RANGE, @@ -121,10 +120,11 @@ enum custom_keycodes { M_TM, M_GGT, M_LOD, + M_LENNY, M_BOLD, M_ITAL, M_ULIN, - M_SNIPENT, + M_SNIPT, M_REPO, M_SHRUG, M_UF, @@ -144,27 +144,6 @@ enum tapdances { TD_LALT_RALT, }; -// Start: Written by drashna -uint8_t last_rgb_mode; - -void suspend_power_down_user(void) { - last_rgb_mode = rgblight_get_mode(); - rgblight_enable_noeeprom(); - rgblight_timer_enable(); - rgblight_mode_noeeprom(4); -} - -void suspend_wakeup_init_user(void) { - static bool ran_once; - if (!ran_once) { - ran_once = true; - rgblight_mode_noeeprom(DEF_RGB_MODE); - return; - } - rgblight_mode_noeeprom(last_rgb_mode); -} -// End: Written by drashna - Color mod_color(Color current_color, bool should_add, uint16_t change_amount) { int addlim = 359 - change_amount; int sublim = change_amount; @@ -191,67 +170,81 @@ void set_color (Color new, bool update) { rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); } -void fade_rgb (void) { - if (flash_state != no_flash) {return;} - if (fade_buffer >= 50) {fade_buffer = 50;} - switch(fade_state){ - case fade: - if (fade_buffer <= 0) {return;} - if (flash_state != no_flash) {return;} - real_fade_delay = LED_FADE_DELAY; - fade_timer_one = timer_read(); - fade_state = add_fade; +void check_state (void) { + switch (state) { + case active: + rgblight_mode_noeeprom(DEF_RGB_MODE); + active_timer_two = timer_read(); + elapsed = active_timer_two - active_timer_one; + if (elapsed < INACTIVE_DELAY) {state = active; return;} + state = inactive; return; + case inactive: + active_timer_two = timer_read(); + elapsed = active_timer_two - active_timer_one; + if (elapsed < SLEEP_DELAY) {return;} + state = sleeping; + return; + + case sleeping: + rgblight_mode_noeeprom(3); + return; + } + +} + +void fade_rgb (void) { + static bool ran_once; + if (flash_state != no_flash) {return;} + if (state != active) {ran_once = false; return;} + switch (fade_state) { case add_fade: + if (!ran_once) { + fade_timer_one = timer_read(); + ran_once = true; + } fade_timer_two = timer_read(); elapsed = fade_timer_two - fade_timer_one; - if (elapsed < real_fade_delay) {return;} - if (fade_buffer > 0) { - if (underglow.h == 359) { - fade_state = sub_fade; - return; - } - underglow.h = underglow.h + 1; - set_color(underglow, false); - fade_timer_one = fade_timer_two; - fade_buffer--; - } else { - fade_state = fade; + if (elapsed < LED_FADE_DELAY) {return;} + if (underglow.h == 359) { + fade_state = sub_fade; + return; } + underglow.h = underglow.h + 1; + set_color(underglow, false); + fade_timer_one = fade_timer_two; return; case sub_fade: fade_timer_two = timer_read(); elapsed = fade_timer_two - fade_timer_one; - if (elapsed < real_fade_delay) {return;} - if (fade_buffer > 0) { - if (underglow.h == 0) { - fade_state = add_fade; - return; - } - underglow.h = underglow.h - 1; - set_color(underglow, false); - fade_timer_one = fade_timer_two; - fade_buffer--; - } else { - fade_state = fade; + if (elapsed < LED_FADE_DELAY) {return;} + if (underglow.h == 0) { + fade_state = add_fade; + return; } + underglow.h = underglow.h - 1; + set_color(underglow, false); + fade_timer_one = fade_timer_two; return; } } void flash_rgb (void) { + static bool ran_once; switch(flash_state) { case no_flash: return; - case flash_begin: - flash_timer_one = timer_read(); - flash_state = flash_off; - return; - case flash_off: + if (!ran_once) { + set_color(hsv_none, false); + flash_timer_one = timer_read(); + ran_once = true; + flash_state = flash_on; + return; + } flash_timer_two = timer_read(); elapsed = flash_timer_two - flash_timer_one; if (elapsed >= LED_FLASH_DELAY) { @@ -267,21 +260,16 @@ void flash_rgb (void) { if (elapsed >= LED_FLASH_DELAY) { set_color(flash_color, false); flash_timer_one = timer_read(); - if (loop) { - flash_state = flash_off; - } else if (num_extra_flashes_off > 0) { + if (num_extra_flashes_off > 0) { flash_state = flash_off; num_extra_flashes_off--; } else { - flash_state = reset_underglow; + set_color(underglow, false); + flash_state = no_flash; + ran_once = false; } } return; - - case reset_underglow: - set_color(underglow, false); - flash_state = no_flash; - return; } } @@ -312,16 +300,8 @@ void set_os (uint8_t os, bool update) { } set_color(underglow, update); flash_color = underglow; - flash_state = flash_begin; - num_extra_flashes_off = 0; -} - -void set_paste_ready(void) { - paste_ready = true; - set_color(hsv_white, false); - flash_color = hsv_white; - flash_state = flash_begin; - loop = true; + flash_state = flash_off; + num_extra_flashes_off = 1; } void tap_key(uint8_t keycode) { @@ -419,71 +399,6 @@ void dance_strk (qk_tap_dance_state_t *state, void *user_data) { } else { return; } - set_paste_ready(); - } -} - -void send_https(void) { - SEND_STRING("https://"); -} - -void send_http(void) { - SEND_STRING("http://"); -} - -void dance_http (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - tap_key(KC_SLSH); - } else if (state->count == 2) { - send_https(); - } else { - send_http(); - } -} - -void send_copy_paste (void) { - pri_mod(true); - if (!paste_ready) { - SEND_STRING(SS_TAP(X_C)); - set_paste_ready(); - } - else { - SEND_STRING(SS_TAP(X_V)); - paste_ready = false; - loop = false; - } - pri_mod(false); -} - -void send_cut_paste (void) { - pri_mod(true); - if (!paste_ready) { - SEND_STRING(SS_TAP(X_X)); - set_paste_ready(); - loop = true; - } - else { - SEND_STRING(SS_TAP(X_V)); - paste_ready = false; - loop = false; - } - pri_mod(false); -} - -void send_lod(void) { - send_unicode_hex_string("0CA0 005F 005F 0CA0"); -} - -void dance_special (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - paste_ready = false; - loop = false; - } else if (state->count == 2) { - send_copy_paste(); - } else if (state->count == 3) { - send_cut_paste(); - } else { - send_lod(); } } @@ -510,10 +425,8 @@ qk_tap_dance_action_t tap_dance_actions[] = { [TD_3_GRV_ACT] = ACTION_TAP_DANCE_FN (dance_3), [TD_C_CED] = ACTION_TAP_DANCE_FN (dance_c), [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), - [TD_SLSH_HTTP] = ACTION_TAP_DANCE_FN (dance_http), [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), [TD_STRK_SHOT] = ACTION_TAP_DANCE_FN (dance_strk), - [TD_SPECIAL] = ACTION_TAP_DANCE_FN (dance_special), [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, LSFT(KC_0)), @@ -523,15 +436,19 @@ qk_tap_dance_action_t tap_dance_actions[] = { void matrix_init_user(void) { current_os = eeprom_read_byte(EECONFIG_USERSPACE); set_os(current_os, false); - last_rgb_mode = rgblight_get_mode(); } void matrix_scan_user(void) { + check_state(); flash_rgb(); fade_rgb(); } bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + active_timer_one = timer_read(); + state = active; + } switch (keycode) { case M_PMOD: if (record->event.pressed) { @@ -586,10 +503,17 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { case M_LOD: if (record->event.pressed) { - send_lod(); + send_unicode_hex_string("0CA0 005F 005F 0CA0"); } return false; + case M_LENNY: + if (record->event.pressed) { + send_unicode_hex_string("0028 0020 0361 00B0 0020 035C 0296 0020 0361 00B0 0029"); + } + return false; + + case M_TF: if (record->event.pressed) { send_unicode_hex_string("0028 256F 2035 0414 2032 0029 256F 5F61 253B 2501 253B"); @@ -626,15 +550,16 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return false; - case M_SNIPENT: + case M_SNIPT: if (record->event.pressed) { surround_type(6, KC_GRAVE, false); pri_mod(true); - register_code(KC_V); - unregister_code(KC_V); + tap_key(KC_V); pri_mod(false); - SEND_STRING(SS_TAP(X_RIGHT) SS_TAP(X_RIGHT) SS_TAP(X_RIGHT) SS_TAP(X_ENTER)); - paste_ready = false; + tap_key(KC_RGHT); + tap_key(KC_RGHT); + tap_key(KC_RGHT); + tap_key(KC_ENTER); } return false; @@ -672,15 +597,15 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { return true; default: - if (record->event.pressed) { - fade_buffer+=50; - } return true; } } uint32_t layer_state_set_user(uint32_t state) { switch (biton32(state)) { + case _LAZY: + rgblight_mode_noeeprom(14); + break; case _MEDIA: set_color(mod_color(underglow, true, 150), false); break; @@ -695,74 +620,46 @@ uint32_t layer_state_set_user(uint32_t state) { break; default: set_color(underglow, false); + rgblight_mode_noeeprom(DEF_RGB_MODE); break; } return state; } -#ifdef HALMAK_LAYOUT -const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_HALMAK] = LAYOUT_2u_space_ortho( - KC_ESC, KC_W, KC_L, KC_R, KC_B, KC_Z, KC_SCLN, KC_Q, KC_U, KC_D, KC_J, KC_BSPC, - KC_TAB, KC_S, KC_H, KC_N, KC_T, KC_COMM, KC_DOT, KC_A, KC_E, KC_O, KC_I, QUOTE, - KC_LSFT, KC_F, KC_M, KC_V, KC_C, KC_SLSH, KC_G, KC_P, KC_X, KC_K, KC_Y, KC_ENT, - M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, SPECIAL, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT), - - [_RAISE] = LAYOUT_2u_space_ortho( - GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, - _______, OPENBRACK, CLOSEBRACK, KC_EQL, HYPHEN, _______, _______, KC_4, KC_5, KC_6, _______, KC_NLCK, - _______, _______, _______, _______, CEDILLA, KC_BSLS, _______, KC_1, KC_2, KC_3, _______, KC_PENT, - _______, _______, _______, KEEB, _______, _______, M_OS, KC_PSLS, KC_PMNS, KC_PPLS, KC_PAST), - - [_LOWER] = LAYOUT_2u_space_ortho( - _______, _______, _______, _______, _______, M_BOLD, _______, _______, M_ULIN, _______, M_P_B, M_C_A_D, - _______, STRIKE, _______, _______, M_TM, _______, _______, M_UF, M_REPO, M_SNIPENT, M_ITAL, _______, - _______, KC_DEL, _______, _______, _______, _______, M_GGT, M_TF, M_SHRUG, M_LOD, _______, _______, - _______, _______, _______, _______, _______, MEDIA, M_CALC, KC_HOME, KC_PGDOWN, KC_PGUP, KC_END), - - [_KEEB] = LAYOUT_2u_space_ortho( - KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, - _______, BL_TOGG, BL_STEP, BL_INC, BL_DEC, BL_BRTG, _______, _______, _______, _______, _______, _______, - RGB_M_P, RGB_TOG, RGB_MOD, RGB_VAI, RGB_VAD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, _______, _______, _______, - RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), - - [_MEDIA] = LAYOUT_2u_space_ortho( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, KC_MUTE, _______, _______, KC_MPLY, - _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_VOLU, KC_MNXT), -}; -#endif -#ifdef QWERTY_LAYOUT const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_QWERTY] = LAYOUT_2u_space_ortho( - KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, - KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, QUOTE, - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, - M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, SPECIAL, KC_LEFT, KC_DOWN, KC_RGHT), + KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, + KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, QUOTE, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, + M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, LAZY, KC_LEFT, KC_DOWN, KC_RGHT), [_RAISE] = LAYOUT_2u_space_ortho( - GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, - _______, OPENBRACK, CLOSEBRACK, KC_BSLS, HYPHEN, KC_EQL, _______, KC_4, KC_5, KC_6, _______, KC_NLCK, - _______, _______, _______, CEDILLA, _______, KC_COMM, KC_PDOT, KC_1, KC_2, KC_3, KC_PPLS, KC_PENT, - _______, _______, _______, KEEB, _______, _______, HTTPS, M_OS, KC_PSLS, KC_PMNS, KC_PAST), + GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, + _______, OBRACK, CBRACK, KC_EQL, HYPHEN, _______, _______, KC_4, KC_5, KC_6, _______, KC_NLCK, + _______, _______, _______, CEDILLA, _______, KC_COMM, KC_PDOT, KC_1, KC_2, KC_3, KC_PPLS, KC_PENT, + _______, _______, _______, KEEB, _______, _______, KC_BSLS, M_OS, KC_PSLS, KC_PMNS, KC_PAST), [_LOWER] = LAYOUT_2u_space_ortho( - _______, _______, _______, _______, _______, M_TM, _______, M_ULIN, M_ITAL, _______, M_P_B, M_C_A_D, - _______, _______, STRIKE, _______, _______, M_GGT, _______, M_UF, M_REPO, M_SNIPENT, _______, _______, - _______, KC_DEL, _______, _______, _______, M_BOLD, _______, M_TF, M_SHRUG, M_LOD, KC_PGUP, _______, - _______, _______, _______, _______, _______, MEDIA, _______, M_CALC, KC_HOME, KC_PGDOWN, KC_END), + _______, _______, _______, _______, _______, _______, _______, M_ULIN, M_ITAL, _______, M_P_B, M_C_A_D, + _______, _______, STRIKE, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, KC_DEL, _______, _______, _______, M_BOLD, _______, _______, _______, _______, KC_PGUP, _______, + _______, _______, _______, _______, _______, MEDIA, _______, M_CALC, KC_HOME, KC_PGDN, KC_END), [_KEEB] = LAYOUT_2u_space_ortho( - KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, - _______, BL_TOGG, BL_STEP, BL_INC, BL_DEC, BL_BRTG, _______, _______, _______, _______, _______, _______, - RGB_M_P, RGB_TOG, RGB_MOD, RGB_VAI, RGB_VAD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, _______, _______, _______, - RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, + _______, BL_TOGG, BL_STEP, BL_INC, BL_DEC, BL_BRTG, _______, _______, _______, _______, _______, _______, + RGB_M_P, RGB_TOG, RGB_MOD, RGB_VAI, RGB_VAD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, _______, _______, _______, + RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), [_MEDIA] = LAYOUT_2u_space_ortho( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_VOLU, KC_MUTE, - _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT), + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_VOLU, KC_MUTE, + _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT), + + [_LAZY] = LAYOUT_2u_space_ortho( + _______, _______, _______, _______, _______, M_TM, _______, M_SNIPT, M_SHRUG, _______, _______, _______, + _______, _______, _______, _______, _______, M_GGT, _______, M_UF, M_LOD, M_REPO, _______, _______, + _______, _______, _______, _______, _______, _______, _______, M_TF, M_LENNY, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), }; -#endif From b93b83d50aaf047b763afa63178fffaf73ecdfc2 Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Fri, 14 Sep 2018 16:49:27 -0600 Subject: [PATCH 11/21] changed sleep and inactive behaviors, now the color shifting reverses on state change, yay! save_color and reset_color are made to enable layer color changing to look cooler. --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 84 ++++++++++++++------ 1 file changed, 59 insertions(+), 25 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index cab5a64324ea..3792f5dea0ef 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -45,8 +45,6 @@ void send_unicode_hex_string(const char *str) { #define INACTIVE_DELAY 200 #define SLEEP_DELAY 60000 -#define DEF_RGB_MODE 1 // static - #define EECONFIG_USERSPACE (uint8_t *)20 #define LRALT TD(TD_LALT_RALT) @@ -95,7 +93,7 @@ typedef enum { sleeping, } activityState; -uint8_t current_os, mod_primary_mask; +uint8_t current_os, mod_primary_mask, fade_delay; uint16_t flash_timer_one, flash_timer_two, fade_timer_one, fade_timer_two, active_timer_one, active_timer_two, @@ -103,6 +101,7 @@ uint16_t flash_timer_one, flash_timer_two, num_extra_flashes_off = 0; Color underglow, flash_color, + saved_color, hsv_none = {0,0,0}, hsv_white = {0,0,127}; flashState flash_state = no_flash; @@ -144,7 +143,24 @@ enum tapdances { TD_LALT_RALT, }; -Color mod_color(Color current_color, bool should_add, uint16_t change_amount) { +void set_color (Color new, bool update) { + rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); +} + +void set_color_at (Color new, uint8_t led) { + rgblight_sethsv_at(new.h, new.s, new.v, led); +} + +void save_color(Color to_save){ + saved_color = to_save; +} + +void reset_color(void){ + underglow = saved_color; +} + +Color mod_color(Color current_color, bool should_add, uint8_t change_amount) { + save_color(underglow); int addlim = 359 - change_amount; int sublim = change_amount; int leftovers; @@ -166,21 +182,30 @@ Color mod_color(Color current_color, bool should_add, uint16_t change_amount) { return current_color; } -void set_color (Color new, bool update) { - rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); +void reverse_fade (void) { + if (fade_state == add_fade){ + fade_state = sub_fade; + } else { + fade_state = add_fade; + } } void check_state (void) { + static bool activated, deactivated, slept; switch (state) { case active: - rgblight_mode_noeeprom(DEF_RGB_MODE); + fade_delay = LED_FADE_DELAY; + if (!activated) {reverse_fade(); activated = true; deactivated = false;} active_timer_two = timer_read(); elapsed = active_timer_two - active_timer_one; - if (elapsed < INACTIVE_DELAY) {state = active; return;} + if (elapsed < INACTIVE_DELAY) {return;} state = inactive; return; case inactive: + fade_delay = LED_FADE_DELAY * 2; + if (!deactivated) {reverse_fade(); deactivated = true; slept = false; activated = false;} + activated = false; active_timer_two = timer_read(); elapsed = active_timer_two - active_timer_one; if (elapsed < SLEEP_DELAY) {return;} @@ -188,7 +213,8 @@ void check_state (void) { return; case sleeping: - rgblight_mode_noeeprom(3); + fade_delay = LED_FADE_DELAY * 6; + if (!slept) {reverse_fade(); slept = true; deactivated = false; activated = false;} return; } @@ -197,7 +223,6 @@ void check_state (void) { void fade_rgb (void) { static bool ran_once; if (flash_state != no_flash) {return;} - if (state != active) {ran_once = false; return;} switch (fade_state) { case add_fade: if (!ran_once) { @@ -206,26 +231,28 @@ void fade_rgb (void) { } fade_timer_two = timer_read(); elapsed = fade_timer_two - fade_timer_one; - if (elapsed < LED_FADE_DELAY) {return;} + if (elapsed < fade_delay) {return;} if (underglow.h == 359) { fade_state = sub_fade; return; } underglow.h = underglow.h + 1; set_color(underglow, false); + // set_color_at(underglow, 0); fade_timer_one = fade_timer_two; return; case sub_fade: fade_timer_two = timer_read(); elapsed = fade_timer_two - fade_timer_one; - if (elapsed < LED_FADE_DELAY) {return;} + if (elapsed < fade_delay) {return;} if (underglow.h == 0) { fade_state = add_fade; return; } underglow.h = underglow.h - 1; set_color(underglow, false); + // set_color_at(underglow, 0); fade_timer_one = fade_timer_two; return; } @@ -404,7 +431,7 @@ void dance_strk (qk_tap_dance_state_t *state, void *user_data) { void dance_3 (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { - register_code (KC_3); + tap_key(KC_3); } else if (state->count == 2) { send_unicode_hex_string("00E8"); } else if (state->count == 3) { @@ -414,7 +441,7 @@ void dance_3 (qk_tap_dance_state_t *state, void *user_data) { void dance_c (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { - register_code (KC_C); + tap_key(KC_C); } else if (state->count == 2) { send_unicode_hex_string("00E7"); } @@ -445,10 +472,6 @@ void matrix_scan_user(void) { } bool process_record_user(uint16_t keycode, keyrecord_t *record) { - if (record->event.pressed) { - active_timer_one = timer_read(); - state = active; - } switch (keycode) { case M_PMOD: if (record->event.pressed) { @@ -591,12 +614,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return false; + case MEDIA: + case LAZY: case KEEB: case RAISE: case LOWER: return true; default: + if (record->event.pressed) { + active_timer_one = timer_read(); + state = active; + } return true; } } @@ -604,25 +633,30 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { uint32_t layer_state_set_user(uint32_t state) { switch (biton32(state)) { case _LAZY: - rgblight_mode_noeeprom(14); + save_color(underglow); + underglow = mod_color(underglow, true, 50); break; case _MEDIA: - set_color(mod_color(underglow, true, 150), false); + save_color(underglow); + underglow = mod_color(underglow, true, 150); break; case _KEEB: - set_color(mod_color(underglow, false, 150), false); + save_color(underglow); + underglow = mod_color(underglow, false, 150); break; case _LOWER: - set_color(mod_color(underglow, false, 100), false); + save_color(underglow); + underglow = mod_color(underglow, false, 100); break; case _RAISE: - set_color(mod_color(underglow, true, 100), false); + save_color(underglow); + underglow = mod_color(underglow, true, 100); break; default: - set_color(underglow, false); - rgblight_mode_noeeprom(DEF_RGB_MODE); + reset_color(); break; } + set_color(underglow, false); return state; } From f67d3bffde8a91674d6a3734cee50f3abf2f99e1 Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Sun, 16 Sep 2018 19:38:21 -0600 Subject: [PATCH 12/21] reformatted some if statements in state detection --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 27 +++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 3792f5dea0ef..c2ce343c2c72 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -194,8 +194,12 @@ void check_state (void) { static bool activated, deactivated, slept; switch (state) { case active: - fade_delay = LED_FADE_DELAY; - if (!activated) {reverse_fade(); activated = true; deactivated = false;} + if (!activated) { + fade_delay = LED_FADE_DELAY; + reverse_fade(); + activated = true; + deactivated = false; + } active_timer_two = timer_read(); elapsed = active_timer_two - active_timer_one; if (elapsed < INACTIVE_DELAY) {return;} @@ -203,9 +207,13 @@ void check_state (void) { return; case inactive: - fade_delay = LED_FADE_DELAY * 2; - if (!deactivated) {reverse_fade(); deactivated = true; slept = false; activated = false;} - activated = false; + if (!deactivated) { + fade_delay = LED_FADE_DELAY * 2; + reverse_fade(); + deactivated = true; + slept = false; + activated = false; + } active_timer_two = timer_read(); elapsed = active_timer_two - active_timer_one; if (elapsed < SLEEP_DELAY) {return;} @@ -213,8 +221,13 @@ void check_state (void) { return; case sleeping: - fade_delay = LED_FADE_DELAY * 6; - if (!slept) {reverse_fade(); slept = true; deactivated = false; activated = false;} + if (!slept) { + fade_delay = LED_FADE_DELAY * 6; + reverse_fade(); + slept = true; + deactivated = false; + activated = false; + } return; } From 109d788a253b7dac3ce24584007b02b8f365ce3e Mon Sep 17 00:00:00 2001 From: Alex K Date: Mon, 17 Sep 2018 22:35:57 +0000 Subject: [PATCH 13/21] changes to force fade to pause on boot, or plug in. --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index c2ce343c2c72..9c01a9420f5f 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -91,6 +91,7 @@ typedef enum { active = 0, inactive, sleeping, + boot, } activityState; uint8_t current_os, mod_primary_mask, fade_delay; @@ -106,7 +107,7 @@ Color underglow, hsv_white = {0,0,127}; flashState flash_state = no_flash; fadeState fade_state = add_fade; -activityState state = inactive; +activityState state = boot; enum custom_keycodes { M_PMOD = SAFE_RANGE, @@ -229,6 +230,10 @@ void check_state (void) { activated = false; } return; + + case boot: + return; + } } @@ -236,6 +241,7 @@ void check_state (void) { void fade_rgb (void) { static bool ran_once; if (flash_state != no_flash) {return;} + if (state == boot) {return;} switch (fade_state) { case add_fade: if (!ran_once) { From 2a3b7ae00242312e3a04ba929450435db9a219d9 Mon Sep 17 00:00:00 2001 From: Alex K Date: Thu, 20 Sep 2018 13:42:22 -0600 Subject: [PATCH 14/21] Attempting to move over to userspace, pushing to repository for help --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 680 +------------------ users/arkag/arkag.c | 551 +++++++++++++++ users/arkag/arkag.h | 167 +++++ users/arkag/config.h | 9 + users/arkag/readme.md | 14 + users/arkag/rules.mk | 1 + 6 files changed, 743 insertions(+), 679 deletions(-) create mode 100644 users/arkag/arkag.c create mode 100644 users/arkag/arkag.h create mode 100644 users/arkag/config.h create mode 100644 users/arkag/readme.md create mode 100644 users/arkag/rules.mk diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 9c01a9420f5f..36836379c1ff 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -1,683 +1,5 @@ #include QMK_KEYBOARD_H - -// Start: Written by konstantin: vomindoraan -#include -#include -#include - -void send_unicode_hex_string(const char *str) { - if (!str) { return; } // Saftey net - while (*str) { - // Find the next code point (token) in the string - for (; *str == ' '; str++); - size_t n = strcspn(str, " "); // Length of the current token - char code_point[n+1]; - strncpy(code_point, str, n); - code_point[n] = '\0'; // Make sure it's null-terminated - - // Normalize the code point: make all hex digits lowercase - for (char *p = code_point; *p; p++) { - *p = tolower(*p); - } - - // Send the code point as a Unicode input string - unicode_input_start(); - send_string(code_point); - unicode_input_finish(); - str += n; // Move to the first ' ' (or '\0') after the current token - } -} -// End: Written by konstantin: vomindoraan -#define _QWERTY 0 -#define _RAISE 1 -#define _LOWER 2 -#define _KEEB 3 -#define _MEDIA 4 -#define _LAZY 5 - -#define MOD_CTL_MASK (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) -#define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) -#define MOD_SFT_MASK (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) - -#define LED_FLASH_DELAY 150 -#define LED_FADE_DELAY 10 - -#define INACTIVE_DELAY 200 -#define SLEEP_DELAY 60000 - -#define EECONFIG_USERSPACE (uint8_t *)20 - -#define LRALT TD(TD_LALT_RALT) -#define QUOTE TD(TD_SING_DOUB) -#define GRAVE TD(TD_GRV_3GRV) -#define OBRACK TD(TD_BRCK_PARN_O) -#define CBRACK TD(TD_BRCK_PARN_C) -#define THREE TD(TD_3_GRV_ACT) -#define STRIKE TD(TD_STRK_SHOT) -#define HYPHEN TD(TD_HYPH_UNDR) -#define CEDILLA TD(TD_C_CED) - -#define RAISE MO(1) -#define LOWER MO(2) -#define KEEB MO(3) -#define MEDIA MO(4) -#define LAZY MO(5) - -typedef enum { - OS_MAC, // Don't assign values - OS_WIN, - OS_NIX, - _OS_COUNT, -} OS; - -typedef struct { - uint16_t h; - uint8_t s; - uint8_t v; -} Color; - -typedef enum { - no_flash = 0, - flash_off, - flash_on, -} flashState; - -typedef enum { - add_fade = 0, - sub_fade, -} fadeState; - -typedef enum { - active = 0, - inactive, - sleeping, - boot, -} activityState; - -uint8_t current_os, mod_primary_mask, fade_delay; -uint16_t flash_timer_one, flash_timer_two, - fade_timer_one, fade_timer_two, - active_timer_one, active_timer_two, - elapsed = 0, - num_extra_flashes_off = 0; -Color underglow, - flash_color, - saved_color, - hsv_none = {0,0,0}, - hsv_white = {0,0,127}; -flashState flash_state = no_flash; -fadeState fade_state = add_fade; -activityState state = boot; - -enum custom_keycodes { - M_PMOD = SAFE_RANGE, - M_SMOD, - M_P_B, - M_C_A_D, - M_CALC, - M_OS, - M_TF, - M_TM, - M_GGT, - M_LOD, - M_LENNY, - M_BOLD, - M_ITAL, - M_ULIN, - M_SNIPT, - M_REPO, - M_SHRUG, - M_UF, -}; - -enum tapdances { - TD_3_GRV_ACT = 0, - TD_C_CED, - TD_GRV_3GRV, - TD_SLSH_HTTP, - TD_SING_DOUB, - TD_HYPH_UNDR, - TD_STRK_SHOT, - TD_SPECIAL, - TD_BRCK_PARN_O, - TD_BRCK_PARN_C, - TD_LALT_RALT, -}; - -void set_color (Color new, bool update) { - rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); -} - -void set_color_at (Color new, uint8_t led) { - rgblight_sethsv_at(new.h, new.s, new.v, led); -} - -void save_color(Color to_save){ - saved_color = to_save; -} - -void reset_color(void){ - underglow = saved_color; -} - -Color mod_color(Color current_color, bool should_add, uint8_t change_amount) { - save_color(underglow); - int addlim = 359 - change_amount; - int sublim = change_amount; - int leftovers; - if (should_add) { - if (current_color.h <= addlim) { - current_color.h += change_amount; - } else { - leftovers = (359 + change_amount) % 359; - current_color.h = 0 + leftovers; - } - } else { - if (current_color.h >= sublim) { - current_color.h -= change_amount; - } else { - leftovers = change_amount - current_color.h; - current_color.h = 359 - leftovers; - } - } - return current_color; -} - -void reverse_fade (void) { - if (fade_state == add_fade){ - fade_state = sub_fade; - } else { - fade_state = add_fade; - } -} - -void check_state (void) { - static bool activated, deactivated, slept; - switch (state) { - case active: - if (!activated) { - fade_delay = LED_FADE_DELAY; - reverse_fade(); - activated = true; - deactivated = false; - } - active_timer_two = timer_read(); - elapsed = active_timer_two - active_timer_one; - if (elapsed < INACTIVE_DELAY) {return;} - state = inactive; - return; - - case inactive: - if (!deactivated) { - fade_delay = LED_FADE_DELAY * 2; - reverse_fade(); - deactivated = true; - slept = false; - activated = false; - } - active_timer_two = timer_read(); - elapsed = active_timer_two - active_timer_one; - if (elapsed < SLEEP_DELAY) {return;} - state = sleeping; - return; - - case sleeping: - if (!slept) { - fade_delay = LED_FADE_DELAY * 6; - reverse_fade(); - slept = true; - deactivated = false; - activated = false; - } - return; - - case boot: - return; - - } - -} - -void fade_rgb (void) { - static bool ran_once; - if (flash_state != no_flash) {return;} - if (state == boot) {return;} - switch (fade_state) { - case add_fade: - if (!ran_once) { - fade_timer_one = timer_read(); - ran_once = true; - } - fade_timer_two = timer_read(); - elapsed = fade_timer_two - fade_timer_one; - if (elapsed < fade_delay) {return;} - if (underglow.h == 359) { - fade_state = sub_fade; - return; - } - underglow.h = underglow.h + 1; - set_color(underglow, false); - // set_color_at(underglow, 0); - fade_timer_one = fade_timer_two; - return; - - case sub_fade: - fade_timer_two = timer_read(); - elapsed = fade_timer_two - fade_timer_one; - if (elapsed < fade_delay) {return;} - if (underglow.h == 0) { - fade_state = add_fade; - return; - } - underglow.h = underglow.h - 1; - set_color(underglow, false); - // set_color_at(underglow, 0); - fade_timer_one = fade_timer_two; - return; - } -} - -void flash_rgb (void) { - static bool ran_once; - switch(flash_state) { - case no_flash: - return; - - case flash_off: - if (!ran_once) { - set_color(hsv_none, false); - flash_timer_one = timer_read(); - ran_once = true; - flash_state = flash_on; - return; - } - flash_timer_two = timer_read(); - elapsed = flash_timer_two - flash_timer_one; - if (elapsed >= LED_FLASH_DELAY) { - set_color(hsv_none, false); - flash_timer_one = timer_read(); - flash_state = flash_on; - } - return; - - case flash_on: - flash_timer_two = timer_read(); - elapsed = flash_timer_two - flash_timer_one; - if (elapsed >= LED_FLASH_DELAY) { - set_color(flash_color, false); - flash_timer_one = timer_read(); - if (num_extra_flashes_off > 0) { - flash_state = flash_off; - num_extra_flashes_off--; - } else { - set_color(underglow, false); - flash_state = no_flash; - ran_once = false; - } - } - return; - } -} - -void set_os (uint8_t os, bool update) { - current_os = os; - if (update) { - eeprom_update_byte(EECONFIG_USERSPACE, current_os); - } - switch (os) { - case OS_MAC: - set_unicode_input_mode(UC_OSX); - underglow = (Color){ 300, 255, 255 }; - mod_primary_mask = MOD_GUI_MASK; - break; - case OS_WIN: - set_unicode_input_mode(UC_WINC); - underglow = (Color){ 180, 255, 255 }; - mod_primary_mask = MOD_CTL_MASK; - break; - case OS_NIX: - set_unicode_input_mode(UC_LNX); - underglow = (Color){ 60, 255, 255 }; - mod_primary_mask = MOD_CTL_MASK; - break; - default: - underglow = (Color){ 0, 0, 255 }; - mod_primary_mask = MOD_CTL_MASK; - } - set_color(underglow, update); - flash_color = underglow; - flash_state = flash_off; - num_extra_flashes_off = 1; -} - -void tap_key(uint8_t keycode) { - register_code(keycode); - unregister_code(keycode); -} - -// register GUI if Mac or Ctrl if other -void pri_mod(bool press) { - if (press) { - if (current_os == OS_MAC) { - register_code(KC_LGUI); - } else { - register_code(KC_LCTL); - } - } else { - if (current_os == OS_MAC) { - unregister_code(KC_LGUI); - } else { - unregister_code(KC_LCTL); - } - } -} - -// register Ctrl if Mac or GUI if other -void sec_mod(bool press) { - if (press) { - if (current_os == OS_MAC) { - register_code(KC_LCTL); - } else { - register_code(KC_LGUI); - } - } else { - if (current_os == OS_MAC) { - unregister_code(KC_LCTL); - } else { - unregister_code(KC_LGUI); - } - } -} - -void surround_type(uint8_t num_of_chars, uint16_t keycode, bool use_shift) { - if (use_shift) { - register_code(KC_LSFT); - } - for (int i = 0; i < num_of_chars; i++) { - tap_key(keycode); - } - if (use_shift) { - unregister_code(KC_LSFT); - } - for (int i = 0; i < (num_of_chars/2); i++) { - tap_key(KC_LEFT); - } -} - -void long_keystroke(size_t num_of_keys, uint16_t keys[]) { - for (int i = 0; i < num_of_keys-1; i++) { - register_code(keys[i]); - } - tap_key(keys[num_of_keys-1]); - for (int i = 0; i < num_of_keys-1; i++) { - unregister_code(keys[i]); - } -} - -void dance_grv (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - tap_key(KC_GRV); - } else if (state->count == 2) { - surround_type(2, KC_GRAVE, false); - } else { - surround_type(6, KC_GRAVE, false); - } -} - -void dance_quot (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - tap_key(KC_QUOT); - } else if (state->count == 2) { - surround_type(2, KC_QUOTE, false); - } else if (state->count == 3) { - surround_type(2, KC_QUOTE, true); - } -} - -void dance_strk (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - surround_type(4, KC_TILDE, true); - } else if (state->count == 2) { - if (current_os == OS_MAC) { - long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_4}); - } else if (current_os == OS_WIN) { - long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_S}); - } else { - return; - } - } -} - -void dance_3 (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - tap_key(KC_3); - } else if (state->count == 2) { - send_unicode_hex_string("00E8"); - } else if (state->count == 3) { - send_unicode_hex_string("00E9"); - } -} - -void dance_c (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - tap_key(KC_C); - } else if (state->count == 2) { - send_unicode_hex_string("00E7"); - } -} - -//Tap Dance Definitions -qk_tap_dance_action_t tap_dance_actions[] = { - [TD_3_GRV_ACT] = ACTION_TAP_DANCE_FN (dance_3), - [TD_C_CED] = ACTION_TAP_DANCE_FN (dance_c), - [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), - [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), - [TD_STRK_SHOT] = ACTION_TAP_DANCE_FN (dance_strk), - [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), - [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), - [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, LSFT(KC_0)), - [TD_LALT_RALT] = ACTION_TAP_DANCE_DOUBLE (KC_LALT, KC_RALT), -}; - -void matrix_init_user(void) { - current_os = eeprom_read_byte(EECONFIG_USERSPACE); - set_os(current_os, false); -} - -void matrix_scan_user(void) { - check_state(); - flash_rgb(); - fade_rgb(); -} - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case M_PMOD: - if (record->event.pressed) { - pri_mod(true); - } else { - pri_mod(false); - } - return false; - - case M_SMOD: - if (record->event.pressed) { - sec_mod(true); - } else { - sec_mod(false); - } - return false; - - case M_P_B: - if (record->event.pressed) { - if (current_os == OS_WIN) { - SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_PAUSE) SS_UP(X_LGUI)); - } else { - } - } - return false; - - case M_C_A_D: - if (record->event.pressed) { - if (current_os == OS_WIN) { - SEND_STRING(SS_DOWN(X_LCTRL) SS_DOWN(X_LALT) SS_TAP(X_DELETE) SS_UP(X_LALT) SS_UP(X_LCTRL)); - } else { - } - } - return false; - - case M_CALC: - if (record->event.pressed) { - if (current_os == OS_WIN) { - SEND_STRING(SS_TAP(X_CALCULATOR)); - // SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_R) SS_UP(X_LGUI) "calc.exe" SS_TAP(X_ENTER)); - } else if (current_os == OS_MAC) { - SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_SPACE) SS_UP(X_LGUI) "calculator" SS_TAP(X_ENTER)); - } - } - return false; - - case M_OS: - if (record->event.pressed) { - set_os((current_os+1) % _OS_COUNT, true); - } - return false; - - case M_LOD: - if (record->event.pressed) { - send_unicode_hex_string("0CA0 005F 005F 0CA0"); - } - return false; - - case M_LENNY: - if (record->event.pressed) { - send_unicode_hex_string("0028 0020 0361 00B0 0020 035C 0296 0020 0361 00B0 0029"); - } - return false; - - - case M_TF: - if (record->event.pressed) { - send_unicode_hex_string("0028 256F 2035 0414 2032 0029 256F 5F61 253B 2501 253B"); - } - return false; - - case M_UF: - if (record->event.pressed) { - send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 0020 30CE 0029"); - } - return false; - - case M_SHRUG: - if (record->event.pressed) { - send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF"); - } - return false; - - case M_TM: - if (record->event.pressed) { - send_unicode_hex_string("2122"); - } - return false; - - case M_REPO: - if (record->event.pressed) { - SEND_STRING("https://github.com/arkag/qmk_firmware/tree/master/keyboards/mechmini/v2/keymaps/arkag"); - } - return false; - - case M_GGT: - if (record->event.pressed) { - SEND_STRING("@GrahamGoldenTech.com"); - } - return false; - - case M_SNIPT: - if (record->event.pressed) { - surround_type(6, KC_GRAVE, false); - pri_mod(true); - tap_key(KC_V); - pri_mod(false); - tap_key(KC_RGHT); - tap_key(KC_RGHT); - tap_key(KC_RGHT); - tap_key(KC_ENTER); - } - return false; - - case M_BOLD: - if (record->event.pressed) { - surround_type(4, KC_8, true); - } - return false; - - case M_ITAL: - if (record->event.pressed) { - surround_type(2, KC_8, true); - } - return false; - - case M_ULIN: - if (record->event.pressed) { - surround_type(4, KC_MINS, true); - } - return false; - - case KC_LSFT: - if (record->event.pressed) { - set_color(mod_color(underglow, true, 50), false); - SEND_STRING(SS_DOWN(X_LSHIFT)); - } else { - set_color(underglow, false); - SEND_STRING(SS_UP(X_LSHIFT)); - } - return false; - - case MEDIA: - case LAZY: - case KEEB: - case RAISE: - case LOWER: - return true; - - default: - if (record->event.pressed) { - active_timer_one = timer_read(); - state = active; - } - return true; - } -} - -uint32_t layer_state_set_user(uint32_t state) { - switch (biton32(state)) { - case _LAZY: - save_color(underglow); - underglow = mod_color(underglow, true, 50); - break; - case _MEDIA: - save_color(underglow); - underglow = mod_color(underglow, true, 150); - break; - case _KEEB: - save_color(underglow); - underglow = mod_color(underglow, false, 150); - break; - case _LOWER: - save_color(underglow); - underglow = mod_color(underglow, false, 100); - break; - case _RAISE: - save_color(underglow); - underglow = mod_color(underglow, true, 100); - break; - default: - reset_color(); - break; - } - set_color(underglow, false); - return state; -} +#include "arkag.h" const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_QWERTY] = LAYOUT_2u_space_ortho( diff --git a/users/arkag/arkag.c b/users/arkag/arkag.c new file mode 100644 index 000000000000..029f7b1a9825 --- /dev/null +++ b/users/arkag/arkag.c @@ -0,0 +1,551 @@ +#include "arkag.h" +#include "quantum.h" +#include "action.h" +#include "process_keycode/process_tap_dance.h" + +// Start: Written by konstantin: vomindoraan +#include +#include +#include + +void send_unicode_hex_string(const char *str) { + if (!str) { return; } // Saftey net + while (*str) { + // Find the next code point (token) in the string + for (; *str == ' '; str++); + size_t n = strcspn(str, " "); // Length of the current token + char code_point[n+1]; + strncpy(code_point, str, n); + code_point[n] = '\0'; // Make sure it's null-terminated + + // Normalize the code point: make all hex digits lowercase + for (char *p = code_point; *p; p++) { + *p = tolower(*p); + } + + // Send the code point as a Unicode input string + unicode_input_start(); + send_string(code_point); + unicode_input_finish(); + str += n; // Move to the first ' ' (or '\0') after the current token + } +} +// End: Written by konstantin: vomindoraan + +void set_color (Color new, bool update) { + rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); +} + +void save_color(Color to_save) { + saved_color = to_save; +} + +void reset_color(void) { + underglow = saved_color; +} + +Color mod_color(Color current_color, bool should_add, uint8_t change_amount) { + save_color(underglow); + int addlim = 359 - change_amount; + int sublim = change_amount; + int leftovers; + if (should_add) { + if (current_color.h <= addlim) { + current_color.h += change_amount; + } else { + leftovers = (359 + change_amount) % 359; + current_color.h = 0 + leftovers; + } + } else { + if (current_color.h >= sublim) { + current_color.h -= change_amount; + } else { + leftovers = change_amount - current_color.h; + current_color.h = 359 - leftovers; + } + } + return current_color; +} + +void reverse_fade (void) { + if (fade_state == add_fade){ + fade_state = sub_fade; + } else { + fade_state = add_fade; + } +} + +void check_state (void) { + static bool activated, deactivated, slept; + switch (state) { + case active: + if (!activated) { + fade_delay = LED_FADE_DELAY; + reverse_fade(); + activated = true; + deactivated = false; + } + active_timer_two = timer_read(); + elapsed = active_timer_two - active_timer_one; + if (elapsed < INACTIVE_DELAY) {return;} + state = inactive; + return; + + case inactive: + if (!deactivated) { + fade_delay = LED_FADE_DELAY * 2; + reverse_fade(); + deactivated = true; + slept = false; + activated = false; + } + active_timer_two = timer_read(); + elapsed = active_timer_two - active_timer_one; + if (elapsed < SLEEP_DELAY) {return;} + state = sleeping; + return; + + case sleeping: + if (!slept) { + fade_delay = LED_FADE_DELAY * 6; + reverse_fade(); + slept = true; + deactivated = false; + activated = false; + } + return; + + case boot: + return; + + } + +} + +void fade_rgb (void) { + static bool ran_once; + if (flash_state != no_flash) {return;} + if (state == boot) {return;} + switch (fade_state) { + case add_fade: + if (!ran_once) { + fade_timer_one = timer_read(); + ran_once = true; + } + fade_timer_two = timer_read(); + elapsed = fade_timer_two - fade_timer_one; + if (elapsed < fade_delay) {return;} + if (underglow.h == 359) { + fade_state = sub_fade; + return; + } + underglow.h = underglow.h + 1; + set_color(underglow, false); + // set_color_at(underglow, 0); + fade_timer_one = fade_timer_two; + return; + + case sub_fade: + fade_timer_two = timer_read(); + elapsed = fade_timer_two - fade_timer_one; + if (elapsed < fade_delay) {return;} + if (underglow.h == 0) { + fade_state = add_fade; + return; + } + underglow.h = underglow.h - 1; + set_color(underglow, false); + // set_color_at(underglow, 0); + fade_timer_one = fade_timer_two; + return; + } +} + +void flash_rgb (void) { + static bool ran_once; + switch(flash_state) { + case no_flash: + return; + + case flash_off: + if (!ran_once) { + set_color(hsv_none, false); + flash_timer_one = timer_read(); + ran_once = true; + flash_state = flash_on; + return; + } + flash_timer_two = timer_read(); + elapsed = flash_timer_two - flash_timer_one; + if (elapsed >= LED_FLASH_DELAY) { + set_color(hsv_none, false); + flash_timer_one = timer_read(); + flash_state = flash_on; + } + return; + + case flash_on: + flash_timer_two = timer_read(); + elapsed = flash_timer_two - flash_timer_one; + if (elapsed >= LED_FLASH_DELAY) { + set_color(flash_color, false); + flash_timer_one = timer_read(); + if (num_extra_flashes_off > 0) { + flash_state = flash_off; + num_extra_flashes_off--; + } else { + set_color(underglow, false); + flash_state = no_flash; + ran_once = false; + } + } + return; + } +} + +void set_os (uint8_t os, bool update) { + current_os = os; + if (update) { + eeprom_update_byte(EECONFIG_USERSPACE, current_os); + } + switch (os) { + case OS_MAC: + set_unicode_input_mode(UC_OSX); + underglow = (Color){ 300, 255, 255 }; + mod_primary_mask = MOD_GUI_MASK; + break; + case OS_WIN: + set_unicode_input_mode(UC_WINC); + underglow = (Color){ 180, 255, 255 }; + mod_primary_mask = MOD_CTL_MASK; + break; + case OS_NIX: + set_unicode_input_mode(UC_LNX); + underglow = (Color){ 60, 255, 255 }; + mod_primary_mask = MOD_CTL_MASK; + break; + default: + underglow = (Color){ 0, 0, 255 }; + mod_primary_mask = MOD_CTL_MASK; + } + set_color(underglow, update); + flash_color = underglow; + flash_state = flash_off; + num_extra_flashes_off = 1; +} + +void tap_key(uint8_t keycode) { + register_code(keycode); + unregister_code(keycode); +} + +// register GUI if Mac or Ctrl if other +void pri_mod(bool press) { + if (press) { + if (current_os == OS_MAC) { + register_code(KC_LGUI); + } else { + register_code(KC_LCTL); + } + } else { + if (current_os == OS_MAC) { + unregister_code(KC_LGUI); + } else { + unregister_code(KC_LCTL); + } + } +} + +// register Ctrl if Mac or GUI if other +void sec_mod(bool press) { + if (press) { + if (current_os == OS_MAC) { + register_code(KC_LCTL); + } else { + register_code(KC_LGUI); + } + } else { + if (current_os == OS_MAC) { + unregister_code(KC_LCTL); + } else { + unregister_code(KC_LGUI); + } + } +} + +void surround_type(uint8_t num_of_chars, uint16_t keycode, bool use_shift) { + if (use_shift) { + register_code(KC_LSFT); + } + for (int i = 0; i < num_of_chars; i++) { + tap_key(keycode); + } + if (use_shift) { + unregister_code(KC_LSFT); + } + for (int i = 0; i < (num_of_chars/2); i++) { + tap_key(KC_LEFT); + } +} + +void long_keystroke(size_t num_of_keys, uint16_t keys[]) { + for (int i = 0; i < num_of_keys-1; i++) { + register_code(keys[i]); + } + tap_key(keys[num_of_keys-1]); + for (int i = 0; i < num_of_keys-1; i++) { + unregister_code(keys[i]); + } +} + +void dance_grv (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + tap_key(KC_GRV); + } else if (state->count == 2) { + surround_type(2, KC_GRAVE, false); + } else { + surround_type(6, KC_GRAVE, false); + } +} + +void dance_quot (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + tap_key(KC_QUOT); + } else if (state->count == 2) { + surround_type(2, KC_QUOTE, false); + } else if (state->count == 3) { + surround_type(2, KC_QUOTE, true); + } +} + +void dance_strk (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + surround_type(4, KC_TILDE, true); + } else if (state->count == 2) { + if (current_os == OS_MAC) { + long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_4}); + } else if (current_os == OS_WIN) { + long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_S}); + } else { + return; + } + } +} + +void dance_3 (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + tap_key(KC_3); + } else if (state->count == 2) { + send_unicode_hex_string("00E8"); + } else if (state->count == 3) { + send_unicode_hex_string("00E9"); + } +} + +void dance_c (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + tap_key(KC_C); + } else if (state->count == 2) { + send_unicode_hex_string("00E7"); + } +} + +void matrix_init_keymap(void) { + current_os = eeprom_read_byte(EECONFIG_USERSPACE); + set_os(current_os, false); +} + +void matrix_scan_keymap(void) { + check_state(); + flash_rgb(); + fade_rgb(); +} + +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case M_PMOD: + if (record->event.pressed) { + pri_mod(true); + } else { + pri_mod(false); + } + return false; + + case M_SMOD: + if (record->event.pressed) { + sec_mod(true); + } else { + sec_mod(false); + } + return false; + + case M_P_B: + if (record->event.pressed) { + if (current_os == OS_WIN) { + SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_PAUSE) SS_UP(X_LGUI)); + } else { + } + } + return false; + + case M_C_A_D: + if (record->event.pressed) { + if (current_os == OS_WIN) { + SEND_STRING(SS_DOWN(X_LCTRL) SS_DOWN(X_LALT) SS_TAP(X_DELETE) SS_UP(X_LALT) SS_UP(X_LCTRL)); + } else { + } + } + return false; + + case M_CALC: + if (record->event.pressed) { + if (current_os == OS_WIN) { + SEND_STRING(SS_TAP(X_CALCULATOR)); + // SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_R) SS_UP(X_LGUI) "calc.exe" SS_TAP(X_ENTER)); + } else if (current_os == OS_MAC) { + SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_SPACE) SS_UP(X_LGUI) "calculator" SS_TAP(X_ENTER)); + } + } + return false; + + case M_OS: + if (record->event.pressed) { + set_os((current_os+1) % _OS_COUNT, true); + } + return false; + + case M_LOD: + if (record->event.pressed) { + send_unicode_hex_string("0CA0 005F 005F 0CA0"); + } + return false; + + case M_LENNY: + if (record->event.pressed) { + send_unicode_hex_string("0028 0020 0361 00B0 0020 035C 0296 0020 0361 00B0 0029"); + } + return false; + + + case M_TF: + if (record->event.pressed) { + send_unicode_hex_string("0028 256F 2035 0414 2032 0029 256F 5F61 253B 2501 253B"); + } + return false; + + case M_UF: + if (record->event.pressed) { + send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 0020 30CE 0029"); + } + return false; + + case M_SHRUG: + if (record->event.pressed) { + send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF"); + } + return false; + + case M_TM: + if (record->event.pressed) { + send_unicode_hex_string("2122"); + } + return false; + + case M_REPO: + if (record->event.pressed) { + SEND_STRING("https://github.com/arkag/qmk_firmware/tree/master/keyboards/mechmini/v2/keymaps/arkag"); + } + return false; + + case M_GGT: + if (record->event.pressed) { + SEND_STRING("@GrahamGoldenTech.com"); + } + return false; + + case M_SNIPT: + if (record->event.pressed) { + surround_type(6, KC_GRAVE, false); + pri_mod(true); + tap_key(KC_V); + pri_mod(false); + tap_key(KC_RGHT); + tap_key(KC_RGHT); + tap_key(KC_RGHT); + tap_key(KC_ENTER); + } + return false; + + case M_BOLD: + if (record->event.pressed) { + surround_type(4, KC_8, true); + } + return false; + + case M_ITAL: + if (record->event.pressed) { + surround_type(2, KC_8, true); + } + return false; + + case M_ULIN: + if (record->event.pressed) { + surround_type(4, KC_MINS, true); + } + return false; + + case KC_LSFT: + if (record->event.pressed) { + set_color(mod_color(underglow, true, 50), false); + SEND_STRING(SS_DOWN(X_LSHIFT)); + } else { + set_color(underglow, false); + SEND_STRING(SS_UP(X_LSHIFT)); + } + return false; + + case MEDIA: + case LAZY: + case KEEB: + case RAISE: + case LOWER: + return true; + + default: + if (record->event.pressed) { + active_timer_one = timer_read(); + state = active; + } + return true; + } +} + +uint32_t layer_state_set_user(uint32_t state) { + switch (biton32(state)) { + case _LAZY: + save_color(underglow); + underglow = mod_color(underglow, true, 50); + break; + case _MEDIA: + save_color(underglow); + underglow = mod_color(underglow, true, 150); + break; + case _KEEB: + save_color(underglow); + underglow = mod_color(underglow, false, 150); + break; + case _LOWER: + save_color(underglow); + underglow = mod_color(underglow, false, 100); + break; + case _RAISE: + save_color(underglow); + underglow = mod_color(underglow, true, 100); + break; + default: + reset_color(); + break; + } + set_color(underglow, false); + return state; +} diff --git a/users/arkag/arkag.h b/users/arkag/arkag.h new file mode 100644 index 000000000000..c4e7bd9f0432 --- /dev/null +++ b/users/arkag/arkag.h @@ -0,0 +1,167 @@ +#pragma once + +#include "quantum.h" +#include "process_keycode/process_tap_dance.h" + +#define _QWERTY 0 +#define _RAISE 1 +#define _LOWER 2 +#define _KEEB 3 +#define _MEDIA 4 +#define _LAZY 5 + +#define EECONFIG_USERSPACE (uint8_t *)20 + +#define LRALT TD(TD_LALT_RALT) +#define QUOTE TD(TD_SING_DOUB) +#define GRAVE TD(TD_GRV_3GRV) +#define OBRACK TD(TD_BRCK_PARN_O) +#define CBRACK TD(TD_BRCK_PARN_C) +#define THREE TD(TD_3_GRV_ACT) +#define STRIKE TD(TD_STRK_SHOT) +#define HYPHEN TD(TD_HYPH_UNDR) +#define CEDILLA TD(TD_C_CED) + +#define RAISE MO(1) +#define LOWER MO(2) +#define KEEB MO(3) +#define MEDIA MO(4) +#define LAZY MO(5) + +#define MOD_CTL_MASK (MOD_BIT(KC_LCTL) | MOD_BIT(KC_RCTL)) +#define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) +#define MOD_SFT_MASK (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) + +#define LED_FLASH_DELAY 150 +#define LED_FADE_DELAY 10 + +#define INACTIVE_DELAY 200 +#define SLEEP_DELAY 60000 + +typedef enum { + OS_MAC, // Don't assign values + OS_WIN, + OS_NIX, + _OS_COUNT, +} OS; + +typedef struct { + uint16_t h; + uint8_t s; + uint8_t v; +} Color; + +typedef enum { + no_flash = 0, + flash_off, + flash_on, +} flashState; + +typedef enum { + add_fade = 0, + sub_fade, +} fadeState; + +typedef enum { + active = 0, + inactive, + sleeping, + boot, +} activityState; + +uint8_t current_os, mod_primary_mask, fade_delay; +uint16_t flash_timer_one, flash_timer_two, + fade_timer_one, fade_timer_two, + active_timer_one, active_timer_two, + elapsed = 0, + num_extra_flashes_off = 0; +Color underglow, + flash_color, + saved_color, + hsv_none = {0,0,0}, + hsv_white = {0,0,127}; +flashState flash_state = no_flash; +fadeState fade_state = add_fade; +activityState state = boot; + +enum custom_keycodes { + M_PMOD = SAFE_RANGE, + M_SMOD, + M_P_B, + M_C_A_D, + M_CALC, + M_OS, + M_TF, + M_TM, + M_GGT, + M_LOD, + M_LENNY, + M_BOLD, + M_ITAL, + M_ULIN, + M_SNIPT, + M_REPO, + M_SHRUG, + M_UF, +}; + +enum tapdances { + TD_3_GRV_ACT = 0, + TD_C_CED, + TD_GRV_3GRV, + TD_SLSH_HTTP, + TD_SING_DOUB, + TD_HYPH_UNDR, + TD_STRK_SHOT, + TD_SPECIAL, + TD_BRCK_PARN_O, + TD_BRCK_PARN_C, + TD_LALT_RALT, +}; + +//Tap Dance Definitions +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_3_GRV_ACT] = ACTION_TAP_DANCE_FN (dance_3), + [TD_C_CED] = ACTION_TAP_DANCE_FN (dance_c), + [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), + [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), + [TD_STRK_SHOT] = ACTION_TAP_DANCE_FN (dance_strk), + [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), + [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), + [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, LSFT(KC_0)), + [TD_LALT_RALT] = ACTION_TAP_DANCE_DOUBLE (KC_LALT, KC_RALT), +}; + +void send_unicode_hex_string(const char *str); + +void set_color (Color new, bool update); +void save_color(Color to_save); +void reset_color(void); + +Color mod_color(Color current_color, bool should_add, uint8_t change_amount); + +void reverse_fade (void); + +void check_state (void); + +void fade_rgb (void); + +void flash_rgb (void); + +void set_os (uint8_t os, bool update); + +void tap_key(uint8_t keycode); + +void pri_mod(bool press); + +void sec_mod(bool press); + +void surround_type(uint8_t num_of_chars, uint16_t keycode, bool use_shift); + +void long_keystroke(size_t num_of_keys, uint16_t keys[]); + +void dance_grv (qk_tap_dance_state_t *state, void *user_data) +void dance_quot (qk_tap_dance_state_t *state, void *user_data) +void dance_strk (qk_tap_dance_state_t *state, void *user_data) +void dance_3 (qk_tap_dance_state_t *state, void *user_data) +void dance_c (qk_tap_dance_state_t *state, void *user_data) diff --git a/users/arkag/config.h b/users/arkag/config.h new file mode 100644 index 000000000000..8c56fd2248b6 --- /dev/null +++ b/users/arkag/config.h @@ -0,0 +1,9 @@ +#pragma once + +#define TAPPING_TERM 200 + +// save me space! +#define NO_ACTION_MACRO +#define NO_ACTION_FUNCTION +#define DISABLE_LEADER +#define NO_MUSIC_MODE diff --git a/users/arkag/readme.md b/users/arkag/readme.md new file mode 100644 index 000000000000..76a5c4525b6f --- /dev/null +++ b/users/arkag/readme.md @@ -0,0 +1,14 @@ +Copyright 2018 arkag arkag@pm.me + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . diff --git a/users/arkag/rules.mk b/users/arkag/rules.mk new file mode 100644 index 000000000000..3513f0ea6c62 --- /dev/null +++ b/users/arkag/rules.mk @@ -0,0 +1 @@ + SRC += arkag.c From 3f0dfc04e80ea3d3b88bed14bd9825d01d87484a Mon Sep 17 00:00:00 2001 From: Alex K Date: Thu, 20 Sep 2018 14:26:51 -0600 Subject: [PATCH 15/21] userspace stuff.... --- users/arkag/arkag.c | 53 +++++++++++++++++++++++++++++++++++++ users/arkag/arkag.h | 64 +++++++++++++++++++++++++++++++++------------ 2 files changed, 101 insertions(+), 16 deletions(-) diff --git a/users/arkag/arkag.c b/users/arkag/arkag.c index 029f7b1a9825..4bfc748d818e 100644 --- a/users/arkag/arkag.c +++ b/users/arkag/arkag.c @@ -350,6 +350,59 @@ void dance_c (qk_tap_dance_state_t *state, void *user_data) { } } +int cur_dance (qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (state->interrupted || !state->pressed) return SINGLE_TAP; + //key has not been interrupted, but they key is still held. Means you want to send a 'HOLD'. + else return SINGLE_HOLD; + } + else if (state->count == 2) { + /* + * DOUBLE_SINGLE_TAP is to distinguish between typing "pepper", and actually wanting a double tap + * action when hitting 'pp'. Suggested use case for this return value is when you want to send two + * keystrokes of the key, and not the 'double tap' action/macro. + */ + if (state->interrupted) return DOUBLE_SINGLE_TAP; + else if (state->pressed) return DOUBLE_HOLD; + else return DOUBLE_TAP; + } + //Assumes no one is trying to type the same letter three times (at least not quickly). + //If your tap dance key is 'KC_W', and you want to type "www." quickly - then you will need to add + //an exception here to return a 'TRIPLE_SINGLE_TAP', and define that enum just like 'DOUBLE_SINGLE_TAP' + if (state->count == 3) { + if (state->interrupted || !state->pressed) return TRIPLE_TAP; + else return TRIPLE_HOLD; + } + else return 8; //magic number. At some point this method will expand to work for more presses +} + +static tap spc_tap_state = { + .is_press_action = true, + .state = 0 +}; + +void x_finished (qk_tap_dance_state_t *state, void *user_data) { + spc_tap_state.state = cur_dance(state); + switch (spc_tap_state.state) { + case SINGLE_TAP: register_code(KC_SPC); break; + case SINGLE_HOLD: register_code(KC_LSFT); break; + case DOUBLE_TAP: break; + case DOUBLE_HOLD: layer_on(_NSHFT); break; + case DOUBLE_SINGLE_TAP: tap_key(KC_SPC); register_code(KC_SPC); + } +} + +void x_reset (qk_tap_dance_state_t *state, void *user_data) { + switch (spc_tap_state.state) { + case SINGLE_TAP: unregister_code(KC_SPC); break; + case SINGLE_HOLD: unregister_code(KC_LSFT); break; + case DOUBLE_TAP: break; + case DOUBLE_HOLD: layer_off(_NSHFT); break; + case DOUBLE_SINGLE_TAP: unregister_code(KC_SPC); + } + spc_tap_state.state = 0; +} + void matrix_init_keymap(void) { current_os = eeprom_read_byte(EECONFIG_USERSPACE); set_os(current_os, false); diff --git a/users/arkag/arkag.h b/users/arkag/arkag.h index c4e7bd9f0432..261efa7f7ad6 100644 --- a/users/arkag/arkag.h +++ b/users/arkag/arkag.h @@ -9,6 +9,7 @@ #define _KEEB 3 #define _MEDIA 4 #define _LAZY 5 +#define _NSHFT 6 #define EECONFIG_USERSPACE (uint8_t *)20 @@ -21,6 +22,7 @@ #define STRIKE TD(TD_STRK_SHOT) #define HYPHEN TD(TD_HYPH_UNDR) #define CEDILLA TD(TD_C_CED) +#define SPACE TD(SPC_SFT_NSFT) #define RAISE MO(1) #define LOWER MO(2) @@ -117,20 +119,32 @@ enum tapdances { TD_BRCK_PARN_O, TD_BRCK_PARN_C, TD_LALT_RALT, + SPC_SFT_NSFT, }; -//Tap Dance Definitions -qk_tap_dance_action_t tap_dance_actions[] = { - [TD_3_GRV_ACT] = ACTION_TAP_DANCE_FN (dance_3), - [TD_C_CED] = ACTION_TAP_DANCE_FN (dance_c), - [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), - [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), - [TD_STRK_SHOT] = ACTION_TAP_DANCE_FN (dance_strk), - [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), - [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), - [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, LSFT(KC_0)), - [TD_LALT_RALT] = ACTION_TAP_DANCE_DOUBLE (KC_LALT, KC_RALT), + +// start fancy tap dancing +typedef struct { + bool is_press_action; + int state; +} tap; + +enum { + SINGLE_TAP = 1, + SINGLE_HOLD = 2, + DOUBLE_TAP = 3, + DOUBLE_HOLD = 4, + DOUBLE_SINGLE_TAP = 5, //send two single taps + TRIPLE_TAP = 6, + TRIPLE_HOLD = 7 +}; + +//Tap dance enums +enum { + X_CTL = 0, + SOME_OTHER_DANCE }; +// end fancy tap dancing void send_unicode_hex_string(const char *str); @@ -160,8 +174,26 @@ void surround_type(uint8_t num_of_chars, uint16_t keycode, bool use_shift); void long_keystroke(size_t num_of_keys, uint16_t keys[]); -void dance_grv (qk_tap_dance_state_t *state, void *user_data) -void dance_quot (qk_tap_dance_state_t *state, void *user_data) -void dance_strk (qk_tap_dance_state_t *state, void *user_data) -void dance_3 (qk_tap_dance_state_t *state, void *user_data) -void dance_c (qk_tap_dance_state_t *state, void *user_data) +void dance_grv (qk_tap_dance_state_t *state, void *user_data); +void dance_quot (qk_tap_dance_state_t *state, void *user_data); +void dance_strk (qk_tap_dance_state_t *state, void *user_data); +void dance_3 (qk_tap_dance_state_t *state, void *user_data); +void dance_c (qk_tap_dance_state_t *state, void *user_data); + +int cur_dance (qk_tap_dance_state_t *state); +void spc_finished (qk_tap_dance_state_t *state, void *user_data); +void spc_reset (qk_tap_dance_state_t *state, void *user_data); + +//Tap Dance Definitions +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_3_GRV_ACT] = ACTION_TAP_DANCE_FN (dance_3), + [TD_C_CED] = ACTION_TAP_DANCE_FN (dance_c), + [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), + [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), + [TD_STRK_SHOT] = ACTION_TAP_DANCE_FN (dance_strk), + [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), + [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), + [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, LSFT(KC_0)), + [TD_LALT_RALT] = ACTION_TAP_DANCE_DOUBLE (KC_LALT, KC_RALT), + [SPC_SFT_NSFT] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, spc_finished, spc_reset), +}; From cbe128a14dfd800a921cc76e963bbd06cbb391c0 Mon Sep 17 00:00:00 2001 From: Alex K Date: Thu, 20 Sep 2018 14:27:10 -0600 Subject: [PATCH 16/21] userspace stuff.... --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 36836379c1ff..a42c6b99760c 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -6,7 +6,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, QUOTE, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, - M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, LAZY, KC_LEFT, KC_DOWN, KC_RGHT), + M_PMOD, LRALT, M_SMOD, LOWER, RAISE, SPACE, KC_SLSH, LAZY, KC_LEFT, KC_DOWN, KC_RGHT), [_RAISE] = LAYOUT_2u_space_ortho( GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, @@ -14,6 +14,12 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, CEDILLA, _______, KC_COMM, KC_PDOT, KC_1, KC_2, KC_3, KC_PPLS, KC_PENT, _______, _______, _______, KEEB, _______, _______, KC_BSLS, M_OS, KC_PSLS, KC_PMNS, KC_PAST), + [_NSHFT] = LAYOUT_2u_space_ortho( + _______, _______, _______, _______, _______, _______, _______, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, + _______, _______, _______, _______, _______, _______, _______, KC_DLR, KC_PERC, KC_CIRC, _______, _______, + _______, _______, _______, _______, _______, _______, _______, KC_EXLM, KC_AT, KC_HASH, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), + [_LOWER] = LAYOUT_2u_space_ortho( _______, _______, _______, _______, _______, _______, _______, M_ULIN, M_ITAL, _______, M_P_B, M_C_A_D, _______, _______, STRIKE, _______, _______, _______, _______, _______, _______, _______, _______, _______, From 4401c1812d7d233d8526c4da744ef415287edebd Mon Sep 17 00:00:00 2001 From: Alex K Date: Thu, 20 Sep 2018 15:05:26 -0600 Subject: [PATCH 17/21] layout changes, working userspace, Removed left side shift and replaced it with a MT() for LSFT and SPC. Userspace seems to be working properly now! HURRAY --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 14 +--- users/arkag/arkag.c | 87 +++++++------------- users/arkag/arkag.h | 57 +------------ 3 files changed, 37 insertions(+), 121 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index a42c6b99760c..85a0f0bd2c11 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -5,26 +5,20 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_QWERTY] = LAYOUT_2u_space_ortho( KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, QUOTE, - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, - M_PMOD, LRALT, M_SMOD, LOWER, RAISE, SPACE, KC_SLSH, LAZY, KC_LEFT, KC_DOWN, KC_RGHT), + M_PMOD, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, + M_SMOD, LRALT, LAZY, LOWER, RAISE, SPACE, KC_SLSH, KC_BSLS, KC_LEFT, KC_DOWN, KC_RGHT), [_RAISE] = LAYOUT_2u_space_ortho( GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, _______, OBRACK, CBRACK, KC_EQL, HYPHEN, _______, _______, KC_4, KC_5, KC_6, _______, KC_NLCK, _______, _______, _______, CEDILLA, _______, KC_COMM, KC_PDOT, KC_1, KC_2, KC_3, KC_PPLS, KC_PENT, - _______, _______, _______, KEEB, _______, _______, KC_BSLS, M_OS, KC_PSLS, KC_PMNS, KC_PAST), - - [_NSHFT] = LAYOUT_2u_space_ortho( - _______, _______, _______, _______, _______, _______, _______, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, _______, - _______, _______, _______, _______, _______, _______, _______, KC_DLR, KC_PERC, KC_CIRC, _______, _______, - _______, _______, _______, _______, _______, _______, _______, KC_EXLM, KC_AT, KC_HASH, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), + _______, _______, M_OS, KEEB, _______, _______, _______, _______, KC_PSLS, KC_PMNS, KC_PAST), [_LOWER] = LAYOUT_2u_space_ortho( _______, _______, _______, _______, _______, _______, _______, M_ULIN, M_ITAL, _______, M_P_B, M_C_A_D, _______, _______, STRIKE, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, _______, _______, _______, M_BOLD, _______, _______, _______, _______, KC_PGUP, _______, - _______, _______, _______, _______, _______, MEDIA, _______, M_CALC, KC_HOME, KC_PGDN, KC_END), + _______, _______, M_CALC, _______, _______, MEDIA, _______, _______, KC_HOME, KC_PGDN, KC_END), [_KEEB] = LAYOUT_2u_space_ortho( KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, diff --git a/users/arkag/arkag.c b/users/arkag/arkag.c index 4bfc748d818e..0f7552002112 100644 --- a/users/arkag/arkag.c +++ b/users/arkag/arkag.c @@ -32,6 +32,21 @@ void send_unicode_hex_string(const char *str) { } // End: Written by konstantin: vomindoraan +uint8_t current_os, mod_primary_mask, fade_delay; +uint16_t flash_timer_one, flash_timer_two, + fade_timer_one, fade_timer_two, + active_timer_one, active_timer_two, + elapsed = 0, + num_extra_flashes_off = 0; +Color underglow, + flash_color, + saved_color, + hsv_none = {0,0,0}, + hsv_white = {0,0,127}; +flashState flash_state = no_flash; +fadeState fade_state = add_fade; +activityState state = boot; + void set_color (Color new, bool update) { rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); } @@ -350,71 +365,18 @@ void dance_c (qk_tap_dance_state_t *state, void *user_data) { } } -int cur_dance (qk_tap_dance_state_t *state) { - if (state->count == 1) { - if (state->interrupted || !state->pressed) return SINGLE_TAP; - //key has not been interrupted, but they key is still held. Means you want to send a 'HOLD'. - else return SINGLE_HOLD; - } - else if (state->count == 2) { - /* - * DOUBLE_SINGLE_TAP is to distinguish between typing "pepper", and actually wanting a double tap - * action when hitting 'pp'. Suggested use case for this return value is when you want to send two - * keystrokes of the key, and not the 'double tap' action/macro. - */ - if (state->interrupted) return DOUBLE_SINGLE_TAP; - else if (state->pressed) return DOUBLE_HOLD; - else return DOUBLE_TAP; - } - //Assumes no one is trying to type the same letter three times (at least not quickly). - //If your tap dance key is 'KC_W', and you want to type "www." quickly - then you will need to add - //an exception here to return a 'TRIPLE_SINGLE_TAP', and define that enum just like 'DOUBLE_SINGLE_TAP' - if (state->count == 3) { - if (state->interrupted || !state->pressed) return TRIPLE_TAP; - else return TRIPLE_HOLD; - } - else return 8; //magic number. At some point this method will expand to work for more presses -} - -static tap spc_tap_state = { - .is_press_action = true, - .state = 0 -}; - -void x_finished (qk_tap_dance_state_t *state, void *user_data) { - spc_tap_state.state = cur_dance(state); - switch (spc_tap_state.state) { - case SINGLE_TAP: register_code(KC_SPC); break; - case SINGLE_HOLD: register_code(KC_LSFT); break; - case DOUBLE_TAP: break; - case DOUBLE_HOLD: layer_on(_NSHFT); break; - case DOUBLE_SINGLE_TAP: tap_key(KC_SPC); register_code(KC_SPC); - } -} - -void x_reset (qk_tap_dance_state_t *state, void *user_data) { - switch (spc_tap_state.state) { - case SINGLE_TAP: unregister_code(KC_SPC); break; - case SINGLE_HOLD: unregister_code(KC_LSFT); break; - case DOUBLE_TAP: break; - case DOUBLE_HOLD: layer_off(_NSHFT); break; - case DOUBLE_SINGLE_TAP: unregister_code(KC_SPC); - } - spc_tap_state.state = 0; -} - -void matrix_init_keymap(void) { +void matrix_init_user(void) { current_os = eeprom_read_byte(EECONFIG_USERSPACE); set_os(current_os, false); } -void matrix_scan_keymap(void) { +void matrix_scan_user(void) { check_state(); flash_rgb(); fade_rgb(); } -bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { +bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case M_PMOD: if (record->event.pressed) { @@ -602,3 +564,16 @@ uint32_t layer_state_set_user(uint32_t state) { set_color(underglow, false); return state; } + +//Tap Dance Definitions +qk_tap_dance_action_t tap_dance_actions[] = { + [TD_3_GRV_ACT] = ACTION_TAP_DANCE_FN (dance_3), + [TD_C_CED] = ACTION_TAP_DANCE_FN (dance_c), + [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), + [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), + [TD_STRK_SHOT] = ACTION_TAP_DANCE_FN (dance_strk), + [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), + [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), + [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, LSFT(KC_0)), + [TD_LALT_RALT] = ACTION_TAP_DANCE_DOUBLE (KC_LALT, KC_RALT), +}; diff --git a/users/arkag/arkag.h b/users/arkag/arkag.h index 261efa7f7ad6..b8c467b65394 100644 --- a/users/arkag/arkag.h +++ b/users/arkag/arkag.h @@ -9,7 +9,6 @@ #define _KEEB 3 #define _MEDIA 4 #define _LAZY 5 -#define _NSHFT 6 #define EECONFIG_USERSPACE (uint8_t *)20 @@ -22,7 +21,8 @@ #define STRIKE TD(TD_STRK_SHOT) #define HYPHEN TD(TD_HYPH_UNDR) #define CEDILLA TD(TD_C_CED) -#define SPACE TD(SPC_SFT_NSFT) + +#define SPACE MT(MOD_LSFT, KC_SPC) #define RAISE MO(1) #define LOWER MO(2) @@ -71,21 +71,6 @@ typedef enum { boot, } activityState; -uint8_t current_os, mod_primary_mask, fade_delay; -uint16_t flash_timer_one, flash_timer_two, - fade_timer_one, fade_timer_two, - active_timer_one, active_timer_two, - elapsed = 0, - num_extra_flashes_off = 0; -Color underglow, - flash_color, - saved_color, - hsv_none = {0,0,0}, - hsv_white = {0,0,127}; -flashState flash_state = no_flash; -fadeState fade_state = add_fade; -activityState state = boot; - enum custom_keycodes { M_PMOD = SAFE_RANGE, M_SMOD, @@ -122,30 +107,6 @@ enum tapdances { SPC_SFT_NSFT, }; - -// start fancy tap dancing -typedef struct { - bool is_press_action; - int state; -} tap; - -enum { - SINGLE_TAP = 1, - SINGLE_HOLD = 2, - DOUBLE_TAP = 3, - DOUBLE_HOLD = 4, - DOUBLE_SINGLE_TAP = 5, //send two single taps - TRIPLE_TAP = 6, - TRIPLE_HOLD = 7 -}; - -//Tap dance enums -enum { - X_CTL = 0, - SOME_OTHER_DANCE -}; -// end fancy tap dancing - void send_unicode_hex_string(const char *str); void set_color (Color new, bool update); @@ -183,17 +144,3 @@ void dance_c (qk_tap_dance_state_t *state, void *user_data); int cur_dance (qk_tap_dance_state_t *state); void spc_finished (qk_tap_dance_state_t *state, void *user_data); void spc_reset (qk_tap_dance_state_t *state, void *user_data); - -//Tap Dance Definitions -qk_tap_dance_action_t tap_dance_actions[] = { - [TD_3_GRV_ACT] = ACTION_TAP_DANCE_FN (dance_3), - [TD_C_CED] = ACTION_TAP_DANCE_FN (dance_c), - [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), - [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), - [TD_STRK_SHOT] = ACTION_TAP_DANCE_FN (dance_strk), - [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), - [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), - [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, LSFT(KC_0)), - [TD_LALT_RALT] = ACTION_TAP_DANCE_DOUBLE (KC_LALT, KC_RALT), - [SPC_SFT_NSFT] = ACTION_TAP_DANCE_FN_ADVANCED (NULL, spc_finished, spc_reset), -}; From 1166a8dbf484c800a990265c4aa1f5e5a5003b26 Mon Sep 17 00:00:00 2001 From: Alex K Date: Fri, 21 Sep 2018 08:27:22 -0600 Subject: [PATCH 18/21] Layout change Removed space/shift and reset modifiers to what they were originally. Added homerow modifiers. --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 10 +++++----- users/arkag/arkag.h | 12 ++++++++++++ users/arkag/config.h | 2 ++ 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 85a0f0bd2c11..23e8ade14233 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -4,21 +4,21 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_QWERTY] = LAYOUT_2u_space_ortho( KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, - KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, QUOTE, - M_PMOD, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, - M_SMOD, LRALT, LAZY, LOWER, RAISE, SPACE, KC_SLSH, KC_BSLS, KC_LEFT, KC_DOWN, KC_RGHT), + KC_TAB, TAP_A, TAP_S, TAP_D, TAP_F, KC_G, KC_H, TAP_J, TAP_K, TAP_L, TAP_SCN, QUOTE, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, + M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, LAZY, KC_LEFT, KC_DOWN, KC_RGHT), [_RAISE] = LAYOUT_2u_space_ortho( GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, _______, OBRACK, CBRACK, KC_EQL, HYPHEN, _______, _______, KC_4, KC_5, KC_6, _______, KC_NLCK, _______, _______, _______, CEDILLA, _______, KC_COMM, KC_PDOT, KC_1, KC_2, KC_3, KC_PPLS, KC_PENT, - _______, _______, M_OS, KEEB, _______, _______, _______, _______, KC_PSLS, KC_PMNS, KC_PAST), + _______, _______, _______, KEEB, _______, _______, KC_BSLS, M_OS, KC_PSLS, KC_PMNS, KC_PAST), [_LOWER] = LAYOUT_2u_space_ortho( _______, _______, _______, _______, _______, _______, _______, M_ULIN, M_ITAL, _______, M_P_B, M_C_A_D, _______, _______, STRIKE, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, _______, _______, _______, M_BOLD, _______, _______, _______, _______, KC_PGUP, _______, - _______, _______, M_CALC, _______, _______, MEDIA, _______, _______, KC_HOME, KC_PGDN, KC_END), + _______, _______, _______, _______, _______, MEDIA, _______, M_CALC, KC_HOME, KC_PGDN, KC_END), [_KEEB] = LAYOUT_2u_space_ortho( KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, diff --git a/users/arkag/arkag.h b/users/arkag/arkag.h index b8c467b65394..a9085c1cd700 100644 --- a/users/arkag/arkag.h +++ b/users/arkag/arkag.h @@ -34,6 +34,18 @@ #define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) #define MOD_SFT_MASK (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) +#define TAP_A LALT_T(KC_A) +#define TAP_SCN RALT_T(KC_SCOLON) + +#define TAP_S LCTL_T(KC_S) +#define TAP_L RCTL_T(KC_L) + +#define TAP_D LSFT_T(KC_D) +#define TAP_K RSFT_T(KC_K) + +#define TAP_F LGUI_T(KC_F) +#define TAP_J RGUI_T(KC_J) + #define LED_FLASH_DELAY 150 #define LED_FADE_DELAY 10 diff --git a/users/arkag/config.h b/users/arkag/config.h index 8c56fd2248b6..7e3921935928 100644 --- a/users/arkag/config.h +++ b/users/arkag/config.h @@ -2,6 +2,8 @@ #define TAPPING_TERM 200 +#define IGNORE_MOD_TAP_INTERRUPT + // save me space! #define NO_ACTION_MACRO #define NO_ACTION_FUNCTION From ff317c60b74fa831677f256ba2ee8f4c203ec695 Mon Sep 17 00:00:00 2001 From: Alex K Date: Fri, 21 Sep 2018 15:02:58 -0600 Subject: [PATCH 19/21] Removed excessive tabs in files --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 60 +- users/arkag/arkag.c | 929 +++++++++---------- users/arkag/arkag.h | 108 +-- 3 files changed, 543 insertions(+), 554 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 23e8ade14233..d0aa9fd558e9 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -2,39 +2,39 @@ #include "arkag.h" const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_QWERTY] = LAYOUT_2u_space_ortho( - KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, - KC_TAB, TAP_A, TAP_S, TAP_D, TAP_F, KC_G, KC_H, TAP_J, TAP_K, TAP_L, TAP_SCN, QUOTE, - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, - M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, LAZY, KC_LEFT, KC_DOWN, KC_RGHT), + [_QWERTY] = LAYOUT_2u_space_ortho( + KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, + KC_TAB, KC_A, KC_S, KC_D, TAP_F, KC_G, KC_H, TAP_J, KC_K, KC_L, KC_SCLN, QUOTE, + XXXXXXX, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, + M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, LAZY, KC_LEFT, KC_DOWN, KC_RGHT), - [_RAISE] = LAYOUT_2u_space_ortho( - GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, - _______, OBRACK, CBRACK, KC_EQL, HYPHEN, _______, _______, KC_4, KC_5, KC_6, _______, KC_NLCK, - _______, _______, _______, CEDILLA, _______, KC_COMM, KC_PDOT, KC_1, KC_2, KC_3, KC_PPLS, KC_PENT, - _______, _______, _______, KEEB, _______, _______, KC_BSLS, M_OS, KC_PSLS, KC_PMNS, KC_PAST), + [_RAISE] = LAYOUT_2u_space_ortho( + GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, + _______, OBRACK, CBRACK, KC_EQL, TAP_MIN, _______, _______, TAP_4, KC_5, KC_6, _______, KC_NLCK, + _______, _______, _______, CEDILLA, _______, KC_COMM, KC_PDOT, KC_1, KC_2, KC_3, KC_PPLS, KC_PENT, + _______, _______, _______, KEEB, _______, _______, _______, M_OS, KC_PSLS, KC_PMNS, KC_PAST), - [_LOWER] = LAYOUT_2u_space_ortho( - _______, _______, _______, _______, _______, _______, _______, M_ULIN, M_ITAL, _______, M_P_B, M_C_A_D, - _______, _______, STRIKE, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, KC_DEL, _______, _______, _______, M_BOLD, _______, _______, _______, _______, KC_PGUP, _______, - _______, _______, _______, _______, _______, MEDIA, _______, M_CALC, KC_HOME, KC_PGDN, KC_END), + [_LOWER] = LAYOUT_2u_space_ortho( + _______, _______, _______, _______, _______, _______, _______, M_ULIN, M_ITAL, _______, M_P_B, M_C_A_D, + _______, _______, STRIKE, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, KC_DEL, _______, _______, _______, M_BOLD, _______, _______, _______, _______, KC_PGUP, _______, + _______, _______, _______, _______, _______, MEDIA, KC_BSLS, M_CALC, KC_HOME, KC_PGDN, KC_END), - [_KEEB] = LAYOUT_2u_space_ortho( - KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, - _______, BL_TOGG, BL_STEP, BL_INC, BL_DEC, BL_BRTG, _______, _______, _______, _______, _______, _______, - RGB_M_P, RGB_TOG, RGB_MOD, RGB_VAI, RGB_VAD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, _______, _______, _______, - RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), + [_KEEB] = LAYOUT_2u_space_ortho( + KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, + _______, BL_TOGG, BL_STEP, BL_INC, BL_DEC, BL_BRTG, _______, _______, _______, _______, _______, _______, + RGB_M_P, RGB_TOG, RGB_MOD, RGB_VAI, RGB_VAD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, _______, _______, _______, + RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), - [_MEDIA] = LAYOUT_2u_space_ortho( - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_VOLU, KC_MUTE, - _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT), + [_MEDIA] = LAYOUT_2u_space_ortho( + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_MPLY, KC_VOLU, KC_MUTE, + _______, _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT), - [_LAZY] = LAYOUT_2u_space_ortho( - _______, _______, _______, _______, _______, M_TM, _______, M_SNIPT, M_SHRUG, _______, _______, _______, - _______, _______, _______, _______, _______, M_GGT, _______, M_UF, M_LOD, M_REPO, _______, _______, - _______, _______, _______, _______, _______, _______, _______, M_TF, M_LENNY, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), + [_LAZY] = LAYOUT_2u_space_ortho( + _______, _______, _______, _______, _______, M_TM, _______, M_SNIPT, M_SHRUG, _______, _______, _______, + _______, _______, _______, _______, _______, M_GGT, _______, M_UF, M_LOD, M_REPO, _______, _______, + _______, _______, _______, _______, _______, _______, _______, M_TF, M_LENNY, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), }; diff --git a/users/arkag/arkag.c b/users/arkag/arkag.c index 0f7552002112..6c01424a1ffc 100644 --- a/users/arkag/arkag.c +++ b/users/arkag/arkag.c @@ -9,26 +9,26 @@ #include void send_unicode_hex_string(const char *str) { - if (!str) { return; } // Saftey net - while (*str) { - // Find the next code point (token) in the string - for (; *str == ' '; str++); - size_t n = strcspn(str, " "); // Length of the current token - char code_point[n+1]; - strncpy(code_point, str, n); - code_point[n] = '\0'; // Make sure it's null-terminated - - // Normalize the code point: make all hex digits lowercase - for (char *p = code_point; *p; p++) { - *p = tolower(*p); - } - - // Send the code point as a Unicode input string - unicode_input_start(); - send_string(code_point); - unicode_input_finish(); - str += n; // Move to the first ' ' (or '\0') after the current token - } + if (!str) { return; } // Saftey net + while (*str) { + // Find the next code point (token) in the string + for (; *str == ' '; str++); + size_t n = strcspn(str, " "); // Length of the current token + char code_point[n+1]; + strncpy(code_point, str, n); + code_point[n] = '\0'; // Make sure it's null-terminated + + // Normalize the code point: make all hex digits lowercase + for (char *p = code_point; *p; p++) { + *p = tolower(*p); + } + + // Send the code point as a Unicode input string + unicode_input_start(); + send_string(code_point); + unicode_input_finish(); + str += n; // Move to the first ' ' (or '\0') after the current token + } } // End: Written by konstantin: vomindoraan @@ -48,532 +48,529 @@ fadeState fade_state = add_fade; activityState state = boot; void set_color (Color new, bool update) { - rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); + rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); } void save_color(Color to_save) { - saved_color = to_save; + saved_color = to_save; } void reset_color(void) { - underglow = saved_color; + underglow = saved_color; } Color mod_color(Color current_color, bool should_add, uint8_t change_amount) { - save_color(underglow); - int addlim = 359 - change_amount; - int sublim = change_amount; - int leftovers; - if (should_add) { - if (current_color.h <= addlim) { - current_color.h += change_amount; - } else { - leftovers = (359 + change_amount) % 359; - current_color.h = 0 + leftovers; - } - } else { - if (current_color.h >= sublim) { - current_color.h -= change_amount; - } else { - leftovers = change_amount - current_color.h; - current_color.h = 359 - leftovers; - } - } - return current_color; + save_color(underglow); + int addlim = 359 - change_amount; + int sublim = change_amount; + int leftovers; + if (should_add) { + if (current_color.h <= addlim) { + current_color.h += change_amount; + } else { + leftovers = (359 + change_amount) % 359; + current_color.h = 0 + leftovers; + } + } else { + if (current_color.h >= sublim) { + current_color.h -= change_amount; + } else { + leftovers = change_amount - current_color.h; + current_color.h = 359 - leftovers; + } + } + return current_color; } void reverse_fade (void) { - if (fade_state == add_fade){ - fade_state = sub_fade; - } else { - fade_state = add_fade; - } + if (fade_state == add_fade){ + fade_state = sub_fade; + } else { + fade_state = add_fade; + } } void check_state (void) { static bool activated, deactivated, slept; switch (state) { case active: - if (!activated) { - fade_delay = LED_FADE_DELAY; - reverse_fade(); - activated = true; - deactivated = false; - } - active_timer_two = timer_read(); - elapsed = active_timer_two - active_timer_one; - if (elapsed < INACTIVE_DELAY) {return;} - state = inactive; - return; + if (!activated) { + fade_delay = LED_FADE_DELAY; + reverse_fade(); + activated = true; + deactivated = false; + } + active_timer_two = timer_read(); + elapsed = active_timer_two - active_timer_one; + if (elapsed < INACTIVE_DELAY) {return;} + state = inactive; + return; case inactive: - if (!deactivated) { - fade_delay = LED_FADE_DELAY * 2; - reverse_fade(); - deactivated = true; - slept = false; - activated = false; - } - active_timer_two = timer_read(); - elapsed = active_timer_two - active_timer_one; - if (elapsed < SLEEP_DELAY) {return;} - state = sleeping; - return; + if (!deactivated) { + fade_delay = LED_FADE_DELAY * 2; + reverse_fade(); + deactivated = true; + slept = false; + activated = false; + } + active_timer_two = timer_read(); + elapsed = active_timer_two - active_timer_one; + if (elapsed < SLEEP_DELAY) {return;} + state = sleeping; + return; case sleeping: - if (!slept) { - fade_delay = LED_FADE_DELAY * 6; - reverse_fade(); - slept = true; - deactivated = false; - activated = false; - } - return; + if (!slept) { + fade_delay = LED_FADE_DELAY * 6; + reverse_fade(); + slept = true; + deactivated = false; + activated = false; + } + return; case boot: - return; - + return; } - } void fade_rgb (void) { - static bool ran_once; - if (flash_state != no_flash) {return;} - if (state == boot) {return;} - switch (fade_state) { - case add_fade: - if (!ran_once) { - fade_timer_one = timer_read(); - ran_once = true; - } - fade_timer_two = timer_read(); - elapsed = fade_timer_two - fade_timer_one; - if (elapsed < fade_delay) {return;} - if (underglow.h == 359) { - fade_state = sub_fade; - return; - } - underglow.h = underglow.h + 1; - set_color(underglow, false); - // set_color_at(underglow, 0); - fade_timer_one = fade_timer_two; - return; - - case sub_fade: - fade_timer_two = timer_read(); - elapsed = fade_timer_two - fade_timer_one; - if (elapsed < fade_delay) {return;} - if (underglow.h == 0) { - fade_state = add_fade; - return; - } - underglow.h = underglow.h - 1; - set_color(underglow, false); - // set_color_at(underglow, 0); - fade_timer_one = fade_timer_two; - return; - } + static bool ran_once; + if (flash_state != no_flash) {return;} + if (state == boot) {return;} + switch (fade_state) { + case add_fade: + if (!ran_once) { + fade_timer_one = timer_read(); + ran_once = true; + } + fade_timer_two = timer_read(); + elapsed = fade_timer_two - fade_timer_one; + if (elapsed < fade_delay) {return;} + if (underglow.h == 359) { + fade_state = sub_fade; + return; + } + underglow.h = underglow.h + 1; + set_color(underglow, false); + // set_color_at(underglow, 0); + fade_timer_one = fade_timer_two; + return; + + case sub_fade: + fade_timer_two = timer_read(); + elapsed = fade_timer_two - fade_timer_one; + if (elapsed < fade_delay) {return;} + if (underglow.h == 0) { + fade_state = add_fade; + return; + } + underglow.h = underglow.h - 1; + set_color(underglow, false); + // set_color_at(underglow, 0); + fade_timer_one = fade_timer_two; + return; + } } void flash_rgb (void) { - static bool ran_once; - switch(flash_state) { - case no_flash: - return; - - case flash_off: - if (!ran_once) { - set_color(hsv_none, false); - flash_timer_one = timer_read(); - ran_once = true; - flash_state = flash_on; - return; - } - flash_timer_two = timer_read(); - elapsed = flash_timer_two - flash_timer_one; - if (elapsed >= LED_FLASH_DELAY) { - set_color(hsv_none, false); - flash_timer_one = timer_read(); - flash_state = flash_on; - } - return; - - case flash_on: - flash_timer_two = timer_read(); - elapsed = flash_timer_two - flash_timer_one; - if (elapsed >= LED_FLASH_DELAY) { - set_color(flash_color, false); - flash_timer_one = timer_read(); - if (num_extra_flashes_off > 0) { - flash_state = flash_off; - num_extra_flashes_off--; - } else { - set_color(underglow, false); - flash_state = no_flash; - ran_once = false; - } - } - return; - } + static bool ran_once; + switch(flash_state) { + case no_flash: + return; + + case flash_off: + if (!ran_once) { + set_color(hsv_none, false); + flash_timer_one = timer_read(); + ran_once = true; + flash_state = flash_on; + return; + } + flash_timer_two = timer_read(); + elapsed = flash_timer_two - flash_timer_one; + if (elapsed >= LED_FLASH_DELAY) { + set_color(hsv_none, false); + flash_timer_one = timer_read(); + flash_state = flash_on; + } + return; + + case flash_on: + flash_timer_two = timer_read(); + elapsed = flash_timer_two - flash_timer_one; + if (elapsed >= LED_FLASH_DELAY) { + set_color(flash_color, false); + flash_timer_one = timer_read(); + if (num_extra_flashes_off > 0) { + flash_state = flash_off; + num_extra_flashes_off--; + } else { + set_color(underglow, false); + flash_state = no_flash; + ran_once = false; + } + } + return; + } } void set_os (uint8_t os, bool update) { - current_os = os; - if (update) { - eeprom_update_byte(EECONFIG_USERSPACE, current_os); - } - switch (os) { - case OS_MAC: - set_unicode_input_mode(UC_OSX); - underglow = (Color){ 300, 255, 255 }; - mod_primary_mask = MOD_GUI_MASK; - break; - case OS_WIN: - set_unicode_input_mode(UC_WINC); - underglow = (Color){ 180, 255, 255 }; - mod_primary_mask = MOD_CTL_MASK; - break; - case OS_NIX: - set_unicode_input_mode(UC_LNX); - underglow = (Color){ 60, 255, 255 }; - mod_primary_mask = MOD_CTL_MASK; - break; - default: - underglow = (Color){ 0, 0, 255 }; - mod_primary_mask = MOD_CTL_MASK; - } - set_color(underglow, update); - flash_color = underglow; - flash_state = flash_off; - num_extra_flashes_off = 1; + current_os = os; + if (update) { + eeprom_update_byte(EECONFIG_USERSPACE, current_os); + } + switch (os) { + case OS_MAC: + set_unicode_input_mode(UC_OSX); + underglow = (Color){ 300, 255, 255 }; + mod_primary_mask = MOD_GUI_MASK; + break; + case OS_WIN: + set_unicode_input_mode(UC_WINC); + underglow = (Color){ 180, 255, 255 }; + mod_primary_mask = MOD_CTL_MASK; + break; + case OS_NIX: + set_unicode_input_mode(UC_LNX); + underglow = (Color){ 60, 255, 255 }; + mod_primary_mask = MOD_CTL_MASK; + break; + default: + underglow = (Color){ 0, 0, 255 }; + mod_primary_mask = MOD_CTL_MASK; + } + set_color(underglow, update); + flash_color = underglow; + flash_state = flash_off; + num_extra_flashes_off = 1; } void tap_key(uint8_t keycode) { - register_code(keycode); - unregister_code(keycode); + register_code(keycode); + unregister_code(keycode); } // register GUI if Mac or Ctrl if other void pri_mod(bool press) { - if (press) { - if (current_os == OS_MAC) { - register_code(KC_LGUI); - } else { - register_code(KC_LCTL); - } - } else { - if (current_os == OS_MAC) { - unregister_code(KC_LGUI); - } else { - unregister_code(KC_LCTL); - } - } + if (press) { + if (current_os == OS_MAC) { + register_code(KC_LGUI); + } else { + register_code(KC_LCTL); + } + } else { + if (current_os == OS_MAC) { + unregister_code(KC_LGUI); + } else { + unregister_code(KC_LCTL); + } + } } // register Ctrl if Mac or GUI if other void sec_mod(bool press) { - if (press) { - if (current_os == OS_MAC) { - register_code(KC_LCTL); - } else { - register_code(KC_LGUI); - } - } else { - if (current_os == OS_MAC) { - unregister_code(KC_LCTL); - } else { - unregister_code(KC_LGUI); - } - } + if (press) { + if (current_os == OS_MAC) { + register_code(KC_LCTL); + } else { + register_code(KC_LGUI); + } + } else { + if (current_os == OS_MAC) { + unregister_code(KC_LCTL); + } else { + unregister_code(KC_LGUI); + } + } } void surround_type(uint8_t num_of_chars, uint16_t keycode, bool use_shift) { - if (use_shift) { - register_code(KC_LSFT); - } - for (int i = 0; i < num_of_chars; i++) { - tap_key(keycode); - } - if (use_shift) { - unregister_code(KC_LSFT); - } - for (int i = 0; i < (num_of_chars/2); i++) { - tap_key(KC_LEFT); - } + if (use_shift) { + register_code(KC_LSFT); + } + for (int i = 0; i < num_of_chars; i++) { + tap_key(keycode); + } + if (use_shift) { + unregister_code(KC_LSFT); + } + for (int i = 0; i < (num_of_chars/2); i++) { + tap_key(KC_LEFT); + } } void long_keystroke(size_t num_of_keys, uint16_t keys[]) { - for (int i = 0; i < num_of_keys-1; i++) { - register_code(keys[i]); - } - tap_key(keys[num_of_keys-1]); - for (int i = 0; i < num_of_keys-1; i++) { - unregister_code(keys[i]); - } + for (int i = 0; i < num_of_keys-1; i++) { + register_code(keys[i]); + } + tap_key(keys[num_of_keys-1]); + for (int i = 0; i < num_of_keys-1; i++) { + unregister_code(keys[i]); + } } void dance_grv (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - tap_key(KC_GRV); - } else if (state->count == 2) { - surround_type(2, KC_GRAVE, false); - } else { - surround_type(6, KC_GRAVE, false); - } + if (state->count == 1) { + tap_key(KC_GRV); + } else if (state->count == 2) { + surround_type(2, KC_GRAVE, false); + } else { + surround_type(6, KC_GRAVE, false); + } } void dance_quot (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - tap_key(KC_QUOT); - } else if (state->count == 2) { - surround_type(2, KC_QUOTE, false); - } else if (state->count == 3) { - surround_type(2, KC_QUOTE, true); - } + if (state->count == 1) { + tap_key(KC_QUOT); + } else if (state->count == 2) { + surround_type(2, KC_QUOTE, false); + } else if (state->count == 3) { + surround_type(2, KC_QUOTE, true); + } } void dance_strk (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - surround_type(4, KC_TILDE, true); - } else if (state->count == 2) { - if (current_os == OS_MAC) { - long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_4}); - } else if (current_os == OS_WIN) { - long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_S}); - } else { - return; - } - } + if (state->count == 1) { + surround_type(4, KC_TILDE, true); + } else if (state->count == 2) { + if (current_os == OS_MAC) { + long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_4}); + } else if (current_os == OS_WIN) { + long_keystroke(3, (uint16_t[]){KC_LGUI, KC_LSFT, KC_S}); + } else { + return; + } + } } void dance_3 (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - tap_key(KC_3); - } else if (state->count == 2) { - send_unicode_hex_string("00E8"); - } else if (state->count == 3) { - send_unicode_hex_string("00E9"); - } + if (state->count == 1) { + tap_key(KC_3); + } else if (state->count == 2) { + send_unicode_hex_string("00E8"); + } else if (state->count == 3) { + send_unicode_hex_string("00E9"); + } } void dance_c (qk_tap_dance_state_t *state, void *user_data) { - if (state->count == 1) { - tap_key(KC_C); - } else if (state->count == 2) { - send_unicode_hex_string("00E7"); - } + if (state->count == 1) { + tap_key(KC_C); + } else if (state->count == 2) { + send_unicode_hex_string("00E7"); + } } void matrix_init_user(void) { - current_os = eeprom_read_byte(EECONFIG_USERSPACE); - set_os(current_os, false); + current_os = eeprom_read_byte(EECONFIG_USERSPACE); + set_os(current_os, false); } void matrix_scan_user(void) { - check_state(); - flash_rgb(); - fade_rgb(); + check_state(); + flash_rgb(); + fade_rgb(); } bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case M_PMOD: - if (record->event.pressed) { - pri_mod(true); - } else { - pri_mod(false); - } - return false; - - case M_SMOD: - if (record->event.pressed) { - sec_mod(true); - } else { - sec_mod(false); - } - return false; - - case M_P_B: - if (record->event.pressed) { - if (current_os == OS_WIN) { - SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_PAUSE) SS_UP(X_LGUI)); - } else { - } - } - return false; - - case M_C_A_D: - if (record->event.pressed) { - if (current_os == OS_WIN) { - SEND_STRING(SS_DOWN(X_LCTRL) SS_DOWN(X_LALT) SS_TAP(X_DELETE) SS_UP(X_LALT) SS_UP(X_LCTRL)); - } else { - } - } - return false; - - case M_CALC: - if (record->event.pressed) { - if (current_os == OS_WIN) { - SEND_STRING(SS_TAP(X_CALCULATOR)); - // SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_R) SS_UP(X_LGUI) "calc.exe" SS_TAP(X_ENTER)); - } else if (current_os == OS_MAC) { - SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_SPACE) SS_UP(X_LGUI) "calculator" SS_TAP(X_ENTER)); - } - } - return false; - - case M_OS: - if (record->event.pressed) { - set_os((current_os+1) % _OS_COUNT, true); - } - return false; - - case M_LOD: - if (record->event.pressed) { - send_unicode_hex_string("0CA0 005F 005F 0CA0"); - } - return false; - - case M_LENNY: - if (record->event.pressed) { - send_unicode_hex_string("0028 0020 0361 00B0 0020 035C 0296 0020 0361 00B0 0029"); - } - return false; - - - case M_TF: - if (record->event.pressed) { - send_unicode_hex_string("0028 256F 2035 0414 2032 0029 256F 5F61 253B 2501 253B"); - } - return false; - - case M_UF: - if (record->event.pressed) { - send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 0020 30CE 0029"); - } - return false; - - case M_SHRUG: - if (record->event.pressed) { - send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF"); - } - return false; - - case M_TM: - if (record->event.pressed) { - send_unicode_hex_string("2122"); - } - return false; - - case M_REPO: - if (record->event.pressed) { - SEND_STRING("https://github.com/arkag/qmk_firmware/tree/master/keyboards/mechmini/v2/keymaps/arkag"); - } - return false; - - case M_GGT: - if (record->event.pressed) { - SEND_STRING("@GrahamGoldenTech.com"); - } - return false; - - case M_SNIPT: - if (record->event.pressed) { - surround_type(6, KC_GRAVE, false); - pri_mod(true); - tap_key(KC_V); - pri_mod(false); - tap_key(KC_RGHT); - tap_key(KC_RGHT); - tap_key(KC_RGHT); - tap_key(KC_ENTER); - } - return false; - - case M_BOLD: - if (record->event.pressed) { - surround_type(4, KC_8, true); - } - return false; - - case M_ITAL: - if (record->event.pressed) { - surround_type(2, KC_8, true); - } - return false; - - case M_ULIN: - if (record->event.pressed) { - surround_type(4, KC_MINS, true); - } - return false; - - case KC_LSFT: - if (record->event.pressed) { - set_color(mod_color(underglow, true, 50), false); - SEND_STRING(SS_DOWN(X_LSHIFT)); - } else { - set_color(underglow, false); - SEND_STRING(SS_UP(X_LSHIFT)); - } - return false; - - case MEDIA: - case LAZY: - case KEEB: - case RAISE: - case LOWER: - return true; - - default: - if (record->event.pressed) { - active_timer_one = timer_read(); - state = active; - } - return true; - } + switch (keycode) { + case M_PMOD: + if (record->event.pressed) { + pri_mod(true); + } else { + pri_mod(false); + } + return false; + + case M_SMOD: + if (record->event.pressed) { + sec_mod(true); + } else { + sec_mod(false); + } + return false; + + case M_P_B: + if (record->event.pressed) { + if (current_os == OS_WIN) { + SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_PAUSE) SS_UP(X_LGUI)); + } else { + } + } + return false; + + case M_C_A_D: + if (record->event.pressed) { + if (current_os == OS_WIN) { + SEND_STRING(SS_DOWN(X_LCTRL) SS_DOWN(X_LALT) SS_TAP(X_DELETE) SS_UP(X_LALT) SS_UP(X_LCTRL)); + } else { + } + } + return false; + + case M_CALC: + if (record->event.pressed) { + if (current_os == OS_WIN) { + SEND_STRING(SS_TAP(X_CALCULATOR)); + } else if (current_os == OS_MAC) { + SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_SPACE) SS_UP(X_LGUI) "calculator" SS_TAP(X_ENTER)); + } + } + return false; + + case M_OS: + if (record->event.pressed) { + set_os((current_os+1) % _OS_COUNT, true); + } + return false; + + case M_LOD: + if (record->event.pressed) { + send_unicode_hex_string("0CA0 005F 005F 0CA0"); + } + return false; + + case M_LENNY: + if (record->event.pressed) { + send_unicode_hex_string("0028 0020 0361 00B0 0020 035C 0296 0020 0361 00B0 0029"); + } + return false; + + + case M_TF: + if (record->event.pressed) { + send_unicode_hex_string("0028 256F 2035 0414 2032 0029 256F 5F61 253B 2501 253B"); + } + return false; + + case M_UF: + if (record->event.pressed) { + send_unicode_hex_string("252C 2500 252C 30CE 0028 0020 00BA 0020 005F 0020 00BA 0020 30CE 0029"); + } + return false; + + case M_SHRUG: + if (record->event.pressed) { + send_unicode_hex_string("00AF 005C 005F 0028 30C4 0029 005F 002F 00AF"); + } + return false; + + case M_TM: + if (record->event.pressed) { + send_unicode_hex_string("2122"); + } + return false; + + case M_REPO: + if (record->event.pressed) { + SEND_STRING("https://github.com/arkag/qmk_firmware/tree/master/keyboards/mechmini/v2/keymaps/arkag"); + } + return false; + + case M_GGT: + if (record->event.pressed) { + SEND_STRING("@GrahamGoldenTech.com"); + } + return false; + + case M_SNIPT: + if (record->event.pressed) { + surround_type(6, KC_GRAVE, false); + pri_mod(true); + tap_key(KC_V); + pri_mod(false); + tap_key(KC_RGHT); + tap_key(KC_RGHT); + tap_key(KC_RGHT); + tap_key(KC_ENTER); + } + return false; + + case M_BOLD: + if (record->event.pressed) { + surround_type(4, KC_8, true); + } + return false; + + case M_ITAL: + if (record->event.pressed) { + surround_type(2, KC_8, true); + } + return false; + + case M_ULIN: + if (record->event.pressed) { + surround_type(4, KC_MINS, true); + } + return false; + + case KC_LSFT: + if (record->event.pressed) { + set_color(mod_color(underglow, true, 50), false); + SEND_STRING(SS_DOWN(X_LSHIFT)); + } else { + set_color(underglow, false); + SEND_STRING(SS_UP(X_LSHIFT)); + } + return false; + + case MEDIA: + case LAZY: + case KEEB: + case RAISE: + case LOWER: + return true; + + default: + if (record->event.pressed) { + active_timer_one = timer_read(); + state = active; + } + return true; + } } uint32_t layer_state_set_user(uint32_t state) { - switch (biton32(state)) { - case _LAZY: - save_color(underglow); - underglow = mod_color(underglow, true, 50); - break; - case _MEDIA: - save_color(underglow); - underglow = mod_color(underglow, true, 150); - break; - case _KEEB: - save_color(underglow); - underglow = mod_color(underglow, false, 150); - break; - case _LOWER: - save_color(underglow); - underglow = mod_color(underglow, false, 100); - break; - case _RAISE: - save_color(underglow); - underglow = mod_color(underglow, true, 100); - break; - default: - reset_color(); - break; - } - set_color(underglow, false); - return state; + switch (biton32(state)) { + case _LAZY: + save_color(underglow); + underglow = mod_color(underglow, true, 50); + break; + case _MEDIA: + save_color(underglow); + underglow = mod_color(underglow, true, 150); + break; + case _KEEB: + save_color(underglow); + underglow = mod_color(underglow, false, 150); + break; + case _LOWER: + save_color(underglow); + underglow = mod_color(underglow, false, 100); + break; + case _RAISE: + save_color(underglow); + underglow = mod_color(underglow, true, 100); + break; + default: + reset_color(); + break; + } + set_color(underglow, false); + return state; } //Tap Dance Definitions qk_tap_dance_action_t tap_dance_actions[] = { - [TD_3_GRV_ACT] = ACTION_TAP_DANCE_FN (dance_3), - [TD_C_CED] = ACTION_TAP_DANCE_FN (dance_c), - [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), - [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), - [TD_STRK_SHOT] = ACTION_TAP_DANCE_FN (dance_strk), - [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), - [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), - [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, LSFT(KC_0)), - [TD_LALT_RALT] = ACTION_TAP_DANCE_DOUBLE (KC_LALT, KC_RALT), + [TD_3_GRV_ACT] = ACTION_TAP_DANCE_FN (dance_3), + [TD_C_CED] = ACTION_TAP_DANCE_FN (dance_c), + [TD_GRV_3GRV] = ACTION_TAP_DANCE_FN (dance_grv), + [TD_SING_DOUB] = ACTION_TAP_DANCE_FN (dance_quot), + [TD_STRK_SHOT] = ACTION_TAP_DANCE_FN (dance_strk), + [TD_HYPH_UNDR] = ACTION_TAP_DANCE_DOUBLE (KC_MINS, LSFT(KC_MINS)), + [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_DOUBLE (KC_LBRC, LSFT(KC_9)), + [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_DOUBLE (KC_RBRC, LSFT(KC_0)), + [TD_LALT_RALT] = ACTION_TAP_DANCE_DOUBLE (KC_LALT, KC_RALT), }; diff --git a/users/arkag/arkag.h b/users/arkag/arkag.h index a9085c1cd700..e8f50f836819 100644 --- a/users/arkag/arkag.h +++ b/users/arkag/arkag.h @@ -22,8 +22,6 @@ #define HYPHEN TD(TD_HYPH_UNDR) #define CEDILLA TD(TD_C_CED) -#define SPACE MT(MOD_LSFT, KC_SPC) - #define RAISE MO(1) #define LOWER MO(2) #define KEEB MO(3) @@ -34,17 +32,11 @@ #define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) #define MOD_SFT_MASK (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) -#define TAP_A LALT_T(KC_A) -#define TAP_SCN RALT_T(KC_SCOLON) - -#define TAP_S LCTL_T(KC_S) -#define TAP_L RCTL_T(KC_L) - -#define TAP_D LSFT_T(KC_D) -#define TAP_K RSFT_T(KC_K) +#define TAP_F LSFT_T(KC_F) +#define TAP_J RSFT_T(KC_J) -#define TAP_F LGUI_T(KC_F) -#define TAP_J RGUI_T(KC_J) +#define TAP_MIN LSFT_T(KC_MINUS) +#define TAP_4 RSFT_T(KC_4) #define LED_FLASH_DELAY 150 #define LED_FADE_DELAY 10 @@ -53,70 +45,70 @@ #define SLEEP_DELAY 60000 typedef enum { - OS_MAC, // Don't assign values - OS_WIN, - OS_NIX, - _OS_COUNT, + OS_MAC, // Don't assign values + OS_WIN, + OS_NIX, + _OS_COUNT, } OS; typedef struct { - uint16_t h; - uint8_t s; - uint8_t v; + uint16_t h; + uint8_t s; + uint8_t v; } Color; typedef enum { - no_flash = 0, - flash_off, - flash_on, + no_flash = 0, + flash_off, + flash_on, } flashState; typedef enum { - add_fade = 0, - sub_fade, + add_fade = 0, + sub_fade, } fadeState; typedef enum { - active = 0, - inactive, - sleeping, - boot, + active = 0, + inactive, + sleeping, + boot, } activityState; enum custom_keycodes { - M_PMOD = SAFE_RANGE, - M_SMOD, - M_P_B, - M_C_A_D, - M_CALC, - M_OS, - M_TF, - M_TM, - M_GGT, - M_LOD, - M_LENNY, - M_BOLD, - M_ITAL, - M_ULIN, - M_SNIPT, - M_REPO, - M_SHRUG, - M_UF, + M_PMOD = SAFE_RANGE, + M_SMOD, + M_P_B, + M_C_A_D, + M_CALC, + M_OS, + M_TF, + M_TM, + M_GGT, + M_LOD, + M_LENNY, + M_BOLD, + M_ITAL, + M_ULIN, + M_SNIPT, + M_REPO, + M_SHRUG, + M_UF, }; enum tapdances { - TD_3_GRV_ACT = 0, - TD_C_CED, - TD_GRV_3GRV, - TD_SLSH_HTTP, - TD_SING_DOUB, - TD_HYPH_UNDR, - TD_STRK_SHOT, - TD_SPECIAL, - TD_BRCK_PARN_O, - TD_BRCK_PARN_C, - TD_LALT_RALT, - SPC_SFT_NSFT, + TD_3_GRV_ACT = 0, + TD_C_CED, + TD_GRV_3GRV, + TD_SLSH_HTTP, + TD_SING_DOUB, + TD_HYPH_UNDR, + TD_STRK_SHOT, + TD_SPECIAL, + TD_BRCK_PARN_O, + TD_BRCK_PARN_C, + TD_LALT_RALT, + SPC_SFT_NSFT, }; void send_unicode_hex_string(const char *str); From 4944177b594eb87d078abb607aa700479683807f Mon Sep 17 00:00:00 2001 From: Alex K Date: Fri, 21 Sep 2018 16:47:49 -0600 Subject: [PATCH 20/21] Moved mods on homerow around... --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 4 ++-- users/arkag/arkag.h | 17 +++++++++++++---- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index d0aa9fd558e9..65cc0b469e2e 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -4,13 +4,13 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_QWERTY] = LAYOUT_2u_space_ortho( KC_ESC, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, - KC_TAB, KC_A, KC_S, KC_D, TAP_F, KC_G, KC_H, TAP_J, KC_K, KC_L, KC_SCLN, QUOTE, + KC_TAB, TAP_A, TAP_S, TAP_D, TAP_F, KC_G, KC_H, TAP_J, TAP_K, TAP_L, TAP_SCN, QUOTE, XXXXXXX, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_UP, KC_ENT, M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, KC_SLSH, LAZY, KC_LEFT, KC_DOWN, KC_RGHT), [_RAISE] = LAYOUT_2u_space_ortho( GRAVE, KC_1, KC_2, THREE, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, _______, - _______, OBRACK, CBRACK, KC_EQL, TAP_MIN, _______, _______, TAP_4, KC_5, KC_6, _______, KC_NLCK, + _______, OBRACK, CBRACK, TAP_EQ, HYPHEN, _______, _______, KC_4, TAP_5, KC_6, _______, KC_NLCK, _______, _______, _______, CEDILLA, _______, KC_COMM, KC_PDOT, KC_1, KC_2, KC_3, KC_PPLS, KC_PENT, _______, _______, _______, KEEB, _______, _______, _______, M_OS, KC_PSLS, KC_PMNS, KC_PAST), diff --git a/users/arkag/arkag.h b/users/arkag/arkag.h index e8f50f836819..875d9cf00f24 100644 --- a/users/arkag/arkag.h +++ b/users/arkag/arkag.h @@ -32,11 +32,20 @@ #define MOD_GUI_MASK (MOD_BIT(KC_LGUI) | MOD_BIT(KC_RGUI)) #define MOD_SFT_MASK (MOD_BIT(KC_LSFT) | MOD_BIT(KC_RSFT)) -#define TAP_F LSFT_T(KC_F) -#define TAP_J RSFT_T(KC_J) +#define TAP_A LALT_T(KC_A) +#define TAP_SCN RALT_T(KC_SCOLON) -#define TAP_MIN LSFT_T(KC_MINUS) -#define TAP_4 RSFT_T(KC_4) +#define TAP_S LCTL_T(KC_S) +#define TAP_L RCTL_T(KC_L) + +#define TAP_D LSFT_T(KC_D) +#define TAP_K RSFT_T(KC_K) + +#define TAP_F LGUI_T(KC_F) +#define TAP_J RGUI_T(KC_J) + +#define TAP_EQ LSFT_T(KC_MINUS) +#define TAP_5 RSFT_T(KC_5) #define LED_FLASH_DELAY 150 #define LED_FADE_DELAY 10 From 0612cd596791c10824c1905697acc336814a1102 Mon Sep 17 00:00:00 2001 From: Alex Kagno Date: Fri, 21 Sep 2018 19:08:42 -0600 Subject: [PATCH 21/21] changes recommended by @drashna --- keyboards/mechmini/v2/keymaps/arkag/config.h | 2 -- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 2 +- users/arkag/arkag.c | 3 --- users/arkag/arkag.h | 18 ++++++++++-------- users/arkag/config.h | 6 ------ 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/config.h b/keyboards/mechmini/v2/keymaps/arkag/config.h index 8c56fd2248b6..f5f3a90fa70c 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/config.h +++ b/keyboards/mechmini/v2/keymaps/arkag/config.h @@ -1,7 +1,5 @@ #pragma once -#define TAPPING_TERM 200 - // save me space! #define NO_ACTION_MACRO #define NO_ACTION_FUNCTION diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 65cc0b469e2e..10502a5b618f 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -17,7 +17,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_LOWER] = LAYOUT_2u_space_ortho( _______, _______, _______, _______, _______, _______, _______, M_ULIN, M_ITAL, _______, M_P_B, M_C_A_D, _______, _______, STRIKE, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, KC_DEL, _______, _______, _______, M_BOLD, _______, _______, _______, _______, KC_PGUP, _______, + KC_CAPS, KC_DEL, _______, _______, _______, M_BOLD, _______, _______, _______, _______, KC_PGUP, _______, _______, _______, _______, _______, _______, MEDIA, KC_BSLS, M_CALC, KC_HOME, KC_PGDN, KC_END), [_KEEB] = LAYOUT_2u_space_ortho( diff --git a/users/arkag/arkag.c b/users/arkag/arkag.c index 6c01424a1ffc..c716b5e93ff0 100644 --- a/users/arkag/arkag.c +++ b/users/arkag/arkag.c @@ -1,7 +1,4 @@ #include "arkag.h" -#include "quantum.h" -#include "action.h" -#include "process_keycode/process_tap_dance.h" // Start: Written by konstantin: vomindoraan #include diff --git a/users/arkag/arkag.h b/users/arkag/arkag.h index 875d9cf00f24..9c81e4487c9a 100644 --- a/users/arkag/arkag.h +++ b/users/arkag/arkag.h @@ -3,13 +3,6 @@ #include "quantum.h" #include "process_keycode/process_tap_dance.h" -#define _QWERTY 0 -#define _RAISE 1 -#define _LOWER 2 -#define _KEEB 3 -#define _MEDIA 4 -#define _LAZY 5 - #define EECONFIG_USERSPACE (uint8_t *)20 #define LRALT TD(TD_LALT_RALT) @@ -44,7 +37,7 @@ #define TAP_F LGUI_T(KC_F) #define TAP_J RGUI_T(KC_J) -#define TAP_EQ LSFT_T(KC_MINUS) +#define TAP_EQ LSFT_T(KC_EQUAL) #define TAP_5 RSFT_T(KC_5) #define LED_FLASH_DELAY 150 @@ -53,6 +46,15 @@ #define INACTIVE_DELAY 200 #define SLEEP_DELAY 60000 +enum { + _QWERTY = 0, + _RAISE, + _LOWER, + _KEEB, + _MEDIA, + _LAZY, +}; + typedef enum { OS_MAC, // Don't assign values OS_WIN, diff --git a/users/arkag/config.h b/users/arkag/config.h index 7e3921935928..e715e5534ee0 100644 --- a/users/arkag/config.h +++ b/users/arkag/config.h @@ -3,9 +3,3 @@ #define TAPPING_TERM 200 #define IGNORE_MOD_TAP_INTERRUPT - -// save me space! -#define NO_ACTION_MACRO -#define NO_ACTION_FUNCTION -#define DISABLE_LEADER -#define NO_MUSIC_MODE