From facca2331519d5d56a926f93f0cdf925fe0857da Mon Sep 17 00:00:00 2001 From: pcoves <33952527+pcoves@users.noreply.github.com> Date: Wed, 8 Jul 2020 22:57:11 +0200 Subject: [PATCH] Add pcoves's userspace (#9354) Co-authored-by: Ryan Co-authored-by: Pablo COVES --- users/pcoves/.gitignore | 2 + users/pcoves/combo.c | 44 ++++++++++++ users/pcoves/config.h | 2 + users/pcoves/pcoves.c | 44 ++++++++++++ users/pcoves/pcoves.h | 32 +++++++++ users/pcoves/rainbowUnicorn.c | 42 +++++++++++ users/pcoves/rainbowUnicorn.h | 5 ++ users/pcoves/readme.md | 14 ++++ users/pcoves/rules.mk | 30 ++++++++ users/pcoves/tapDance.c | 127 ++++++++++++++++++++++++++++++++++ users/pcoves/tapDance.h | 8 +++ users/pcoves/unicode.c | 20 ++++++ users/pcoves/unicode.h | 5 ++ 13 files changed, 375 insertions(+) create mode 100644 users/pcoves/.gitignore create mode 100644 users/pcoves/combo.c create mode 100644 users/pcoves/config.h create mode 100644 users/pcoves/pcoves.c create mode 100644 users/pcoves/pcoves.h create mode 100644 users/pcoves/rainbowUnicorn.c create mode 100644 users/pcoves/rainbowUnicorn.h create mode 100644 users/pcoves/readme.md create mode 100644 users/pcoves/rules.mk create mode 100644 users/pcoves/tapDance.c create mode 100644 users/pcoves/tapDance.h create mode 100644 users/pcoves/unicode.c create mode 100644 users/pcoves/unicode.h diff --git a/users/pcoves/.gitignore b/users/pcoves/.gitignore new file mode 100644 index 00000000000..c0579ed3290 --- /dev/null +++ b/users/pcoves/.gitignore @@ -0,0 +1,2 @@ +secret.h +secret.c diff --git a/users/pcoves/combo.c b/users/pcoves/combo.c new file mode 100644 index 00000000000..a9a1ffe9887 --- /dev/null +++ b/users/pcoves/combo.c @@ -0,0 +1,44 @@ +#include "quantum.h" + +enum { + MIN, + EQL, + + ESC, + BSP, + DEL, + + TAB, + BSL, + + CUT, + GRA, +}; + +const uint16_t PROGMEM min[] = {KC_C, KC_V, COMBO_END}; +const uint16_t PROGMEM eql[] = {KC_M, KC_COMM, COMBO_END}; + +const uint16_t PROGMEM esc[] = {KC_D, KC_F, COMBO_END}; +const uint16_t PROGMEM bsp[] = {KC_J, KC_K, COMBO_END}; +const uint16_t PROGMEM del[] = {KC_DOWN, KC_UP, COMBO_END}; + +const uint16_t PROGMEM tab[] = {KC_S, KC_F, COMBO_END}; +const uint16_t PROGMEM bsl[] = {KC_J, KC_L, COMBO_END}; + +const uint16_t PROGMEM cut[] = {KC_K, KC_L, COMBO_END}; +const uint16_t PROGMEM gra[] = {KC_S, KC_D, COMBO_END}; + +combo_t key_combos[COMBO_COUNT] = { + [MIN] = COMBO(min, KC_MINS), + [EQL] = COMBO(eql, KC_EQL), + + [ESC] = COMBO(esc, KC_ESC), + [BSP] = COMBO(bsp, KC_BSPC), + [DEL] = COMBO(del, KC_DEL), + + [TAB] = COMBO(tab, KC_TAB), + [BSL] = COMBO(bsl, KC_BSLS), + + [CUT] = COMBO(cut, KC_QUOT), + [GRA] = COMBO(gra, KC_GRAVE), +}; diff --git a/users/pcoves/config.h b/users/pcoves/config.h new file mode 100644 index 00000000000..645dcbbf4c9 --- /dev/null +++ b/users/pcoves/config.h @@ -0,0 +1,2 @@ +#define COMBO_TERM 200 +#define COMBO_COUNT 9 diff --git a/users/pcoves/pcoves.c b/users/pcoves/pcoves.c new file mode 100644 index 00000000000..af5b987a6f3 --- /dev/null +++ b/users/pcoves/pcoves.c @@ -0,0 +1,44 @@ +#include "pcoves.h" + +#ifdef RAINBOW_UNICORN_ENABLE +#include "rainbowUnicorn.h" +#endif + +#ifdef UNICODE_ENABLE +#include "unicode.h" +#endif + +#if SECRET_ENABLE +#include "secret.h" +#endif + +__attribute__((weak)) void eeconfig_init_keymap(void) {} + +void eeconfig_init_user(void) { +#ifdef UNICODE_ENABLE + set_unicode_input_mode(UC_LNX); +#endif + eeconfig_init_keymap(); +} + +__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case AUTRUCHE: + if (record->event.pressed) SEND_STRING("Autruche"); + return true; + } + + return process_record_keymap(keycode, record) +#ifdef RAINBOW_UNICORN_ENABLE + && process_record_rainbowUnicorn(keycode, record) +#endif +#ifdef UNICODE_ENABLE + && process_record_unicode(keycode, record) +#endif +#if SECRET_ENABLE + && process_record_secret(keycode, record) +#endif + ; +} diff --git a/users/pcoves/pcoves.h b/users/pcoves/pcoves.h new file mode 100644 index 00000000000..10dfc56bd36 --- /dev/null +++ b/users/pcoves/pcoves.h @@ -0,0 +1,32 @@ +#pragma once + +#include "quantum.h" + +#define SECRET_ENABLE (__has_include("secret.h") && !defined(NO_SECRET)) + +enum { + AUTRUCHE = SAFE_RANGE, +#ifdef RAINBOW_UNICORN_ENABLE + RAINBOW_UNICORN_TOGGLE, +#endif +#ifdef UNICODE_ENABLE + EMOTE0, + EMOTE1, + EMOTE2, + EMOTE3, +#endif +#if SECRET_ENABLE + SECRET0, + SECRET1, + SECRET2, + SECRET3, + SECRET4, +#endif + PCOVES_SAFE_RANGE, +}; + +__attribute__((weak)) void eeconfig_init_keymap(void); +void eeconfig_init_user(void); + +__attribute__((weak)) bool process_record_keymap(uint16_t keycode, keyrecord_t *record); +bool process_record_user(uint16_t keycode, keyrecord_t *record); diff --git a/users/pcoves/rainbowUnicorn.c b/users/pcoves/rainbowUnicorn.c new file mode 100644 index 00000000000..9520415051e --- /dev/null +++ b/users/pcoves/rainbowUnicorn.c @@ -0,0 +1,42 @@ +#include "rainbowUnicorn.h" +#include "pcoves.h" + +static struct { + bool enabled; + uint8_t color; + char string[2]; + uint8_t mods; +} state = {false, 0}; + +bool process_record_rainbowUnicorn(uint16_t keycode, keyrecord_t* record) { + if (keycode == RAINBOW_UNICORN_TOGGLE) { + state.enabled ^= true; + return false; + } + + if (!state.enabled) return true; + + switch (keycode) { + case KC_A ... KC_Z: + case KC_1 ... KC_0: + case ALT_T(KC_A)... ALT_T(KC_Z): + case CTL_T(KC_A)... CTL_T(KC_Z): + case GUI_T(KC_A)... GUI_T(KC_Z): + case SFT_T(KC_A)... SFT_T(KC_Z): + if (record->event.pressed) { + state.mods = get_mods(); + clear_mods(); + + tap_code16(C(KC_C)); + + itoa(state.color + 3, state.string, 10); + send_string(state.string); + + set_mods(state.mods); + } else { + state.color = (state.color + 1) % 11; + } + } + + return true; +} diff --git a/users/pcoves/rainbowUnicorn.h b/users/pcoves/rainbowUnicorn.h new file mode 100644 index 00000000000..0c709b4b7af --- /dev/null +++ b/users/pcoves/rainbowUnicorn.h @@ -0,0 +1,5 @@ +#pragma once + +#include "quantum.h" + +__attribute__((weak)) bool process_record_rainbowUnicorn(uint16_t keycode, keyrecord_t* keyrecord); diff --git a/users/pcoves/readme.md b/users/pcoves/readme.md new file mode 100644 index 00000000000..1d076d92f6b --- /dev/null +++ b/users/pcoves/readme.md @@ -0,0 +1,14 @@ +Copyright 2020 @pcoves + +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/pcoves/rules.mk b/users/pcoves/rules.mk new file mode 100644 index 00000000000..400497b151a --- /dev/null +++ b/users/pcoves/rules.mk @@ -0,0 +1,30 @@ +SRC += pcoves.c + +RAINBOW_UNICORN_ENABLE ?= no +ifneq ($(strip $(RAINBOW_UNICORN_ENABLE)), no) + SRC += rainbowUnicorn.c + OPT_DEFS += -DRAINBOW_UNICORN_ENABLE +endif + +ifeq ($(strip $(TAP_DANCE_ENABLE)), yes) + SRC += tapDance.c +endif + +ifeq ($(strip $(COMBO_ENABLE)), yes) + SRC += combo.c +endif + +ifeq ($(strip $(UNICODE_ENABLE)), yes) + SRC += unicode.c + OPT_DEFS += -DUNICODE_ENABLE +endif + +ifneq ($(strip $(NO_SECRET)), yes) + ifneq ("$(wildcard $(USER_PATH)/secret.c)","") + SRC += secret.c + else + OPT_DEFS += -DNO_SECRET + endif +else + OPT_DEFS += -DNO_SECRET +endif diff --git a/users/pcoves/tapDance.c b/users/pcoves/tapDance.c new file mode 100644 index 00000000000..f8c9aaf4667 --- /dev/null +++ b/users/pcoves/tapDance.c @@ -0,0 +1,127 @@ +#include "tapDance.h" + +#include "quantum.h" + +void left(qk_tap_dance_state_t* state, void* user_data) { + switch (state->count) { + case 1: + if (state->pressed) + tap_code16(S(KC_LBRACKET)); + else + tap_code16(S(KC_9)); + break; + case 2: + if (state->pressed) + tap_code16(S(KC_COMM)); + else + tap_code(KC_LBRACKET); + break; + default: + reset_tap_dance(state); + } +} + +void right(qk_tap_dance_state_t* state, void* user_data) { + switch (state->count) { + case 1: + if (state->pressed) + tap_code16(S(KC_RBRACKET)); + else + tap_code16(S(KC_0)); + break; + case 2: + if (state->pressed) + tap_code16(S(KC_DOT)); + else + tap_code(KC_RBRACKET); + break; + default: + reset_tap_dance(state); + } +} + +enum { REST, HOLD1, HOLD2, HOLD3 }; + +static int Alt = REST; +void altFinish(qk_tap_dance_state_t* state, void* user_data) { + switch (state->count) { + case 1: + if (state->pressed) { + register_code(KC_LALT); + Alt = HOLD1; + } + break; + case 2: + if (state->pressed) { + register_code(KC_RALT); + Alt = HOLD2; + } + break; + case 3: + if (state->pressed) { + register_code(KC_RALT); + register_code(KC_RSHIFT); + Alt = HOLD3; + } + break; + default: + reset_tap_dance(state); + } +} + +void altReset(qk_tap_dance_state_t* state, void* user_data) { + switch (Alt) { + case HOLD1: + unregister_code(KC_LALT); + break; + case HOLD2: + unregister_code(KC_RALT); + break; + case HOLD3: + unregister_code(KC_RSHIFT); + unregister_code(KC_RALT); + break; + } + Alt = REST; +} + +static int Ctrl = REST; +void ctrlFinish(qk_tap_dance_state_t* state, void* user_data) { + switch (state->count) { + case 1: + if (state->pressed) { + register_code(KC_LCTL); + Ctrl = HOLD1; + } else { + tap_code(KC_ESC); + } + break; + case 2: + if (state->pressed) { + register_code(KC_LGUI); + Ctrl = HOLD2; + } + break; + default: + reset_tap_dance(state); + } +} + +void ctrlReset(qk_tap_dance_state_t* state, void* user_data) { + switch (Ctrl) { + case HOLD1: + unregister_code(KC_LCTL); + break; + case HOLD2: + unregister_code(KC_LGUI); + break; + } + Ctrl = REST; +} + +qk_tap_dance_action_t tap_dance_actions[] = { + [ALT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, altFinish, altReset), + [CTRL] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, ctrlFinish, ctrlReset), + [LEFT] = ACTION_TAP_DANCE_FN(left), + [RIGHT] = ACTION_TAP_DANCE_FN(right), +}; diff --git a/users/pcoves/tapDance.h b/users/pcoves/tapDance.h new file mode 100644 index 00000000000..98fd8ae2c7f --- /dev/null +++ b/users/pcoves/tapDance.h @@ -0,0 +1,8 @@ +#pragma once + +enum { + ALT, + CTRL, + LEFT, + RIGHT, +}; diff --git a/users/pcoves/unicode.c b/users/pcoves/unicode.c new file mode 100644 index 00000000000..966a9d3852a --- /dev/null +++ b/users/pcoves/unicode.c @@ -0,0 +1,20 @@ +#include "unicode.h" +#include "pcoves.h" + +bool process_record_unicode(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case EMOTE0: + if (record->event.pressed) send_unicode_string("(╯°□°)╯︵┻━┻"); + return false; + case EMOTE1: + if (record->event.pressed) send_unicode_string("(ヘ・_・)ヘ┳━┳"); + return false; + case EMOTE2: + if (record->event.pressed) send_unicode_string("¯\\_(ツ)_/¯"); + return false; + case EMOTE3: + if (record->event.pressed) send_unicode_string("ಠ_ಠ"); + return false; + } + return true; +} diff --git a/users/pcoves/unicode.h b/users/pcoves/unicode.h new file mode 100644 index 00000000000..ba8a881787d --- /dev/null +++ b/users/pcoves/unicode.h @@ -0,0 +1,5 @@ +#pragma once + +#include "quantum.h" + +__attribute__((weak)) bool process_record_unicode(uint16_t keycode, keyrecord_t *record);