Add pcoves's userspace (#9354)

Co-authored-by: Ryan <fauxpark@gmail.com>
Co-authored-by: Pablo COVES <pablo.coves@anatoscope.com>
master
pcoves 2020-07-08 22:57:11 +02:00 committed by GitHub
parent 071e0c2029
commit facca23315
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 375 additions and 0 deletions

2
users/pcoves/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
secret.h
secret.c

44
users/pcoves/combo.c Normal file
View File

@ -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),
};

2
users/pcoves/config.h Normal file
View File

@ -0,0 +1,2 @@
#define COMBO_TERM 200
#define COMBO_COUNT 9

44
users/pcoves/pcoves.c Normal file
View File

@ -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
;
}

32
users/pcoves/pcoves.h Normal file
View File

@ -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);

View File

@ -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;
}

View File

@ -0,0 +1,5 @@
#pragma once
#include "quantum.h"
__attribute__((weak)) bool process_record_rainbowUnicorn(uint16_t keycode, keyrecord_t* keyrecord);

14
users/pcoves/readme.md Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.

30
users/pcoves/rules.mk Normal file
View File

@ -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

127
users/pcoves/tapDance.c Normal file
View File

@ -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),
};

8
users/pcoves/tapDance.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
enum {
ALT,
CTRL,
LEFT,
RIGHT,
};

20
users/pcoves/unicode.c Normal file
View File

@ -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;
}

5
users/pcoves/unicode.h Normal file
View File

@ -0,0 +1,5 @@
#pragma once
#include "quantum.h"
__attribute__((weak)) bool process_record_unicode(uint16_t keycode, keyrecord_t *record);