From 2558372b3f5b383582ee35f318d75a2dc7a28c6e Mon Sep 17 00:00:00 2001 From: Alexander Kagno Date: Thu, 14 Mar 2019 19:04:59 +0000 Subject: [PATCH] fresh commit for a new fork for PR to upstream/master (#5406) --- keyboards/mechmini/v2/keymaps/arkag/keymap.c | 37 +-- keyboards/mechmini/v2/keymaps/arkag/rules.mk | 2 +- users/arkag/arkag.c | 270 ++++++++++++------- users/arkag/arkag.h | 31 +-- users/arkag/config.h | 2 +- 5 files changed, 206 insertions(+), 136 deletions(-) diff --git a/keyboards/mechmini/v2/keymaps/arkag/keymap.c b/keyboards/mechmini/v2/keymaps/arkag/keymap.c index 29e125394b..0b1cc4dacb 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/keymap.c +++ b/keyboards/mechmini/v2/keymaps/arkag/keymap.c @@ -8,32 +8,39 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_QWERTY] = LAYOUT_2u_space_ortho( - KC_LEAD, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSPC, + 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, KC_BSLS, KC_LEFT, KC_DOWN, KC_RGHT), + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT, + M_PMOD, LRALT, M_SMOD, LOWER, RAISE, KC_SPC, MEDIA, FUNCT, XXXXXXX, XXXXXXX, KC_LEAD), [_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, _______, + GRAVE, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, _______, KC_7, KC_8, KC_9, _______, _______, _______, 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, _______, _______, _______, M_OS, KC_PSLS, KC_PMNS, KC_PAST), + _______, _______, _______, CEDILLA, _______, KC_COMM, KC_PDOT, KC_1, KC_2, KC_3, KC_BSLS, KC_PENT, + _______, _______, _______, KEEB, _______, _______, KC_0, KC_PSLS, KC_PMNS, KC_PPLS, KC_PAST), [_LOWER] = LAYOUT_2u_space_ortho( - KC_ESC, _______, _______, _______, _______, _______, _______, _______, _______, _______, M_P_B, M_C_A_D, + _______, _______, _______, _______, _______, _______, _______, _______, KC_UP, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - KC_CAPS, KC_DEL, _______, _______, _______, _______, _______, _______, _______, _______, KC_PGUP, _______, - _______, _______, _______, _______, _______, _______, _______, _______, KC_HOME, KC_PGDN, KC_END), + _______, LRALT, _______, _______, _______, _______, _______, _______, _______, _______, _______), + + [_MEDIA] = LAYOUT_2u_space_ortho( + _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLU, _______, _______, KC_MUTE, + _______, _______, _______, _______, _______, _______, _______, KC_MPRV, KC_VOLD, KC_MNXT, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, KC_MPLY, _______, _______, _______, _______, _______), + + [_FUNCT] = 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, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + KC_CAPS, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, M_SFT, M_SPC, M_OS), [_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, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______), - [_LAZY] = LAYOUT_2u_space_ortho( - _______, _______, _______, _______, _______, M_TM, _______, M_SNIPT, M_SHRUG, _______, _______, KC_MUTE, - _______, _______, _______, _______, _______, M_GGT, _______, M_UF, M_LOD, M_REPO, _______, _______, - _______, _______, _______, _______, _______, _______, _______, M_TF, M_LENNY, _______, KC_VOLU, KC_MPLY, - _______, _______, _______, _______, _______, _______, M_CALC, _______, 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 c1d5afa1eb..1330a2738a 100644 --- a/keyboards/mechmini/v2/keymaps/arkag/rules.mk +++ b/keyboards/mechmini/v2/keymaps/arkag/rules.mk @@ -1,4 +1,4 @@ -BOOTMAGIC_ENABLE = no +BOOTMAGIC_ENABLE = full MOUSEKEY_ENABLE = no STENO_ENABLE = no EXTRAKEY_ENABLE = yes diff --git a/users/arkag/arkag.c b/users/arkag/arkag.c index 212d06de67..80f7b1bbc1 100644 --- a/users/arkag/arkag.c +++ b/users/arkag/arkag.c @@ -5,34 +5,7 @@ https://github.com/arkag/qmk_firmware/blob/master/keyboards/mechmini/v2/keymaps/arkag/keymap.c */ -// 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 +#include // Start: Written by Chris Lewis #ifndef MIN @@ -78,6 +51,8 @@ Color underglow, flashState flash_state = no_flash; fadeState fade_state = add_fade; activityState state = boot; +bool aesthetic = false, + shifty = false; void set_color (Color new, bool update) { rgblight_sethsv_eeprom_helper(new.h, new.s, new.v, update); @@ -146,7 +121,7 @@ void check_state (void) { case sleeping: if (!slept) { - rgblight_mode_noeeprom(4); + rgblight_mode_noeeprom(2); slept = true; activated = false; deactivated = false; @@ -249,11 +224,6 @@ void set_os (uint8_t os, bool update) { 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) { @@ -293,13 +263,13 @@ void surround_type(uint8_t num_of_chars, uint16_t keycode, bool use_shift) { register_code(KC_LSFT); } for (int i = 0; i < num_of_chars; i++) { - tap_key(keycode); + tap_code(keycode); } if (use_shift) { unregister_code(KC_LSFT); } for (int i = 0; i < (num_of_chars/2); i++) { - tap_key(KC_LEFT); + tap_code(KC_LEFT); } } @@ -307,7 +277,7 @@ 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]); + tap_code(keys[num_of_keys-1]); for (int i = 0; i < num_of_keys-1; i++) { unregister_code(keys[i]); } @@ -315,7 +285,10 @@ void long_keystroke(size_t num_of_keys, uint16_t keys[]) { void dance_grv (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { - tap_key(KC_GRV); + tap_code(KC_GRV); + if (aesthetic) { + tap_code(KC_SPACE); + } } else if (state->count == 2) { surround_type(2, KC_GRAVE, false); } else { @@ -325,7 +298,10 @@ void dance_grv (qk_tap_dance_state_t *state, void *user_data) { void dance_quot (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { - tap_key(KC_QUOT); + tap_code(KC_QUOT); + if (aesthetic) { + tap_code(KC_SPACE); + } } else if (state->count == 2) { surround_type(2, KC_QUOTE, false); } else if (state->count == 3) { @@ -333,35 +309,53 @@ 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_hyph (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; + tap_code(KC_MINS); + if (aesthetic) { + tap_code(KC_SPACE); } - } -} - -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"); + register_code(KC_LSFT); + tap_code(KC_MINS); + if (aesthetic) { + tap_code(KC_SPACE); + } + unregister_code(KC_LSFT); } else if (state->count == 3) { - send_unicode_hex_string("00E9"); + send_unicode_hex_string("2014"); } } -void dance_c (qk_tap_dance_state_t *state, void *user_data) { +void dance_obrck (qk_tap_dance_state_t *state, void *user_data) { if (state->count == 1) { - tap_key(KC_C); + tap_code(KC_LBRC); + if (aesthetic) { + tap_code(KC_SPACE); + } } else if (state->count == 2) { - send_unicode_hex_string("00E7"); + register_code(KC_LSFT); + tap_code(KC_9); + if (aesthetic) { + tap_code(KC_SPACE); + } + unregister_code(KC_LSFT); + } +} + +void dance_cbrck (qk_tap_dance_state_t *state, void *user_data) { + if (state->count == 1) { + tap_code(KC_RBRC); + if (aesthetic) { + tap_code(KC_SPACE); + } + } else if (state->count == 2) { + register_code(KC_LSFT); + tap_code(KC_0); + if (aesthetic) { + tap_code(KC_SPACE); + } + unregister_code(KC_LSFT); } } @@ -383,13 +377,28 @@ void matrix_scan_user(void) { // begin OS functions SEQ_TWO_KEYS(KC_P, KC_B) { if (current_os == OS_WIN) { - SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_PAUSE) SS_UP(X_LGUI)); + long_keystroke(2, (uint16_t[]){KC_LGUI, KC_PAUSE}); } else { } } + SEQ_TWO_KEYS(KC_LSFT, M_PMOD) { + if (current_os == OS_WIN) { + long_keystroke(3, (uint16_t[]){KC_LCTL, KC_LSFT, KC_ESC}); + } else { + } + } + SEQ_TWO_KEYS(KC_S, KC_S) { + 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; + } + } SEQ_THREE_KEYS(KC_C, KC_A, KC_D) { 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)); + long_keystroke(3, (uint16_t[]){KC_LCTL, KC_LALT, KC_DEL}); } else { } } @@ -415,33 +424,33 @@ void matrix_scan_user(void) { SEQ_ONE_KEY(KC_S) { surround_type(4, KC_GRAVE, true); } - SEQ_TWO_KEYS(KC_S, KC_S) { - 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; - } - } SEQ_ONE_KEY(KC_C) { - surround_type(2, KC_GRAVE, false); + send_unicode_hex_string("00E7"); } SEQ_TWO_KEYS(KC_C, KC_C) { + surround_type(2, KC_GRAVE, false); + } + SEQ_THREE_KEYS(KC_C, KC_C, KC_C) { surround_type(6, KC_GRAVE, false); } + SEQ_ONE_KEY(KC_E) { + send_unicode_hex_string("00E8"); + } + SEQ_TWO_KEYS(KC_E, KC_E) { + send_unicode_hex_string("00E9"); + } // end format functions // start fancy functions SEQ_THREE_KEYS(KC_C, KC_C, KC_C) { surround_type(6, KC_GRAVE, false); pri_mod(true); - tap_key(KC_V); + tap_code(KC_V); pri_mod(false); - tap_key(KC_RGHT); - tap_key(KC_RGHT); - tap_key(KC_RGHT); - tap_key(KC_ENTER); + tap_code(KC_RGHT); + tap_code(KC_RGHT); + tap_code(KC_RGHT); + tap_code(KC_ENTER); } // end fancy functions @@ -450,8 +459,8 @@ void matrix_scan_user(void) { // ™ send_unicode_hex_string("2122"); } - SEQ_THREE_KEYS(KC_G, KC_G, KC_T) { - SEND_STRING("@GrahamGoldenTech.com"); + SEQ_TWO_KEYS(KC_D, KC_D) { + SEND_STRING(".\\Administrator"); } SEQ_THREE_KEYS(KC_L, KC_O, KC_D) { // ಠ__ಠ @@ -482,29 +491,103 @@ void matrix_scan_user(void) { } bool process_record_user(uint16_t keycode, keyrecord_t *record) { + if (aesthetic) { + switch (keycode) { + case KC_A ... KC_0: + case KC_SPACE ... KC_SLASH: + if (record->event.pressed) { + state = active; + velocikey_accelerate(); + tap_code(keycode); + tap_code(KC_SPACE); + } + return false; + + case KC_BSPACE: + if (record->event.pressed) { + state = active; + velocikey_accelerate(); + tap_code(keycode); + tap_code(keycode); + } + return false; + default: // Do nothing + break; + } + } + + if (shifty) { + switch (keycode) { + case KC_A ... KC_Z: + if (record->event.pressed) { + int shift = rand() % 2; + state = active; + velocikey_accelerate(); + if (shift == 1){ + register_code(KC_LSFT); + } + tap_code(keycode); + if (shift == 1){ + unregister_code(KC_LSFT); + } + } + return false; + case KC_SPC: + if (record->event.pressed) { + state = active; + velocikey_accelerate(); + tap_code(keycode); + } + return false; + default: // Do nothing + break; + } + } + switch (keycode) { case M_PMOD: - if (record->event.pressed) { - pri_mod(true); - } else { - pri_mod(false); - } + pri_mod(record->event.pressed); return false; case M_SMOD: - if (record->event.pressed) { - sec_mod(true); - } else { - sec_mod(false); - } + sec_mod(record->event.pressed); return false; case M_OS: - if (record->event.pressed) { + if (record->event.pressed){ set_os((current_os+1) % _OS_COUNT, true); } + return false; + case M_SPC: + if(record->event.pressed){ + if (aesthetic) { + aesthetic = false; + num_extra_flashes_off = 1; + } else { + aesthetic = true; + } + flash_color = underglow; + flash_state = flash_off; + return false; + } + + + case M_SFT: + if(record->event.pressed){ + if (shifty) { + shifty = false; + num_extra_flashes_off = 1; + } else { + shifty = true; + } + flash_color = underglow; + flash_state = flash_off; + return false; + } + + default: if (record->event.pressed) { state = active; @@ -516,13 +599,10 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { //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_HYPH_UNDR] = ACTION_TAP_DANCE_FN (dance_hyph), + [TD_BRCK_PARN_O] = ACTION_TAP_DANCE_FN (dance_obrck), + [TD_BRCK_PARN_C] = ACTION_TAP_DANCE_FN (dance_cbrck), [TD_LALT_RALT] = ACTION_TAP_DANCE_DOUBLE (KC_LALT, KC_RALT), }; diff --git a/users/arkag/arkag.h b/users/arkag/arkag.h index a4672a8e82..a5f2a6a352 100644 --- a/users/arkag/arkag.h +++ b/users/arkag/arkag.h @@ -17,9 +17,9 @@ #define RAISE MO(1) #define LOWER MO(2) -#define KEEB MO(3) -#define MEDIA MO(4) -#define LAZY MO(5) +#define MEDIA MO(3) +#define FUNCT MO(4) +#define KEEB 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)) @@ -37,9 +37,9 @@ enum { _QWERTY = 0, _RAISE, _LOWER, - _KEEB, _MEDIA, - _LAZY, + _FUNCT, + _KEEB, }; typedef enum { @@ -76,22 +76,9 @@ typedef enum { 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_SFT, + M_SPC, }; enum tapdances { @@ -101,16 +88,12 @@ enum tapdances { 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); - void velocikey_accelerate(void); void velocikey_decelerate(void); uint8_t velocikey_match_speed(uint8_t minValue, uint8_t maxValue); diff --git a/users/arkag/config.h b/users/arkag/config.h index 2e0a9ad019..5a89a18f60 100644 --- a/users/arkag/config.h +++ b/users/arkag/config.h @@ -1,6 +1,6 @@ #pragma once #define TAPPING_TERM 200 -#define LEADER_TIMEOUT 250 +#define LEADER_TIMEOUT 300 #define LEADER_PER_KEY_TIMING