[Keymap] ninjonas keymap updates (#8373)

* [keymap(ninjonas)] ninjonas keymap updates

* [refactor] switching encoder rotation logic. recent pull seems to have flipped encoder stuff

* [keymap(lily58)] added chrome change profile key on RAISE

Co-authored-by: Jonas Avellana <jonas.avellana@workday.com>
This commit is contained in:
Jonas Avellana 2020-03-13 17:56:21 -06:00 committed by GitHub
parent 40e8d60ecd
commit 0fdd37ee19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 293 additions and 173 deletions

View File

@ -20,7 +20,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once #pragma once
#define TAPPING_TERM 300 #define TAPPING_TERM 200
#define MASTER_LEFT #define MASTER_LEFT

View File

@ -16,7 +16,7 @@
#pragma once #pragma once
#define TAPPING_TERM 300 #define TAPPING_TERM 200
#ifdef OLED_DRIVER_ENABLE #ifdef OLED_DRIVER_ENABLE
#define OLED_DISPLAY_128X64 #define OLED_DISPLAY_128X64

View File

@ -1,84 +0,0 @@
/* Copyright 2020 ninjonas
*
* 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/>.
*/
#include "ninjonas.h"
#ifdef ENCODER_ENABLE
void encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) {
switch (get_highest_layer(layer_state)) {
case _LOWER:
if (clockwise) {
tap_code16(SGUI(KC_TAB));
} else {
tap_code16(LGUI(KC_TAB));
}
break;
case _RAISE:
if (clockwise) {
tap_code(KC_PGUP);
} else {
tap_code(KC_PGDN);
}
break;
case _ADJUST:
if (clockwise) {
rgblight_increase_hue();
} else {
rgblight_decrease_hue();
}
break;
default:
if (clockwise) {
tap_code(KC_BRIU);
} else {
tap_code(KC_BRID);
}
break;
}
} else if (index == 1) {
switch (get_highest_layer(layer_state)) {
case _LOWER:
if (clockwise) {
tap_code(KC_UP);
} else {
tap_code(KC_DOWN);
}
break;
case _RAISE:
if (clockwise) {
tap_code16(LCTL(KC_TAB));
} else {
tap_code16(LCTL(LSFT(KC_TAB)));
}
break;
case _ADJUST:
if (clockwise) {
rgblight_increase_val();
} else {
rgblight_decrease_val();
}
break;
default:
if (clockwise) {
tap_code(KC_VOLU);
} else {
tap_code(KC_VOLD);
}
break;
}
}
}
#endif

View File

@ -24,7 +24,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// |--------+-----——-+——------+-——-----+——------+——-----| |------—+——------+——------+——------+——------+--------| // |--------+-----——-+——------+-——-----+——------+——-----| |------—+——------+——------+——------+——------+--------|
_____________________QWERTY_L2______________________, _____________________QWERTY_R2______________________, _____________________QWERTY_L2______________________, _____________________QWERTY_R2______________________,
// |--------+-----——-+——------+-——-----+——------+——-----+———-----------. ,——————————————+------—+——------+——------+——------+——------+--------| // |--------+-----——-+——------+-——-----+——------+——-----+———-----------. ,——————————————+------—+——------+——------+——------+——------+--------|
_____________________QWERTY_L3______________________,XXXXXXX,KC_LALT, T_CPNU,XXXXXXX,_____________________QWERTY_R3______________________, _____________________QWERTY_L3______________________,XXXXXXX,KC_LALT, T_CPAP,XXXXXXX,_____________________QWERTY_R3______________________,
// `--------------------------+--------+--------+-------+-------+------| |------+-------+-------+--------+--------+--------+--------+--------' // `--------------------------+--------+--------+-------+-------+------| |------+-------+-------+--------+--------+--------+--------+--------'
_____________MOD_LEFT_____________,T_LBRC, T_RBRC,________MOD_RIGHT________,KC_MUTE _____________MOD_LEFT_____________,T_LBRC, T_RBRC,________MOD_RIGHT________,KC_MUTE
// `----------------------------------------' `----------------------------------------' // `----------------------------------------' `----------------------------------------'
@ -36,7 +36,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// |--------+-----——-+——------+-——-----+——------+——-----| |------—+——------+——------+——------+——------+--------| // |--------+-----——-+——------+-——-----+——------+——-----| |------—+——------+——------+——------+——------+--------|
_____________________DVORAK_L2______________________, _____________________DVORAK_R2______________________, _____________________DVORAK_L2______________________, _____________________DVORAK_R2______________________,
// |--------+-----——-+——------+-——-----+——------+——-----+———-----------. ,——————————————+------—+——------+——------+——------+——------+--------| // |--------+-----——-+——------+-——-----+——------+——-----+———-----------. ,——————————————+------—+——------+——------+——------+——------+--------|
_____________________DVORAK_L3______________________,XXXXXXX,KC_LALT, T_CPNU,XXXXXXX,_____________________DVORAK_R3______________________, _____________________DVORAK_L3______________________,XXXXXXX,KC_LALT, T_CPAP,XXXXXXX,_____________________DVORAK_R3______________________,
// `--------------------------+--------+--------+-------+-------+------| |------+-------+-------+--------+--------+--------+--------+--------' // `--------------------------+--------+--------+-------+-------+------| |------+-------+-------+--------+--------+--------+--------+--------'
_____________MOD_LEFT_____________,T_LBRC, T_RBRC,________MOD_RIGHT________,KC_MUTE _____________MOD_LEFT_____________,T_LBRC, T_RBRC,________MOD_RIGHT________,KC_MUTE
// `----------------------------------------' `----------------------------------------' // `----------------------------------------' `----------------------------------------'
@ -48,7 +48,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// |--------+-----——-+——------+-——-----+——------+——-----| |------—+——------+——------+——------+——------+--------| // |--------+-----——-+——------+-——-----+——------+——-----| |------—+——------+——------+——------+——------+--------|
_____________________COLEMAK_L2_____________________, _____________________COLEMAK_R2_____________________, _____________________COLEMAK_L2_____________________, _____________________COLEMAK_R2_____________________,
// |--------+-----——-+——------+-——-----+——------+——-----+———-----------. ,——————————————+------—+——------+——------+——------+——------+--------| // |--------+-----——-+——------+-——-----+——------+——-----+———-----------. ,——————————————+------—+——------+——------+——------+——------+--------|
_____________________COLEMAK_L3_____________________,XXXXXXX,KC_LALT, T_CPNU,XXXXXXX,_____________________COLEMAK_R3_____________________, _____________________COLEMAK_L3_____________________,XXXXXXX,KC_LALT, T_CPAP,XXXXXXX,_____________________COLEMAK_R3_____________________,
// `--------------------------+--------+--------+-------+-------+------| |------+-------+-------+--------+--------+--------+--------+--------' // `--------------------------+--------+--------+-------+-------+------| |------+-------+-------+--------+--------+--------+--------+--------'
_____________MOD_LEFT_____________,T_LBRC, T_RBRC,________MOD_RIGHT________,KC_MUTE _____________MOD_LEFT_____________,T_LBRC, T_RBRC,________MOD_RIGHT________,KC_MUTE
// `----------------------------------------' `----------------------------------------' // `----------------------------------------' `----------------------------------------'

View File

@ -105,8 +105,12 @@ void oled_white_space(void){
oled_write_P(PSTR(" "), false); oled_write_P(PSTR(" "), false);
} }
void oled_slash_separator(void){
oled_write_P(PSTR(" / "), false);
}
void render_layout_state(void) { void render_layout_state(void) {
oled_write_P(PSTR("\nLayout: "), false); oled_write_P(PSTR("Layout: "), false);
switch (biton32(default_layer_state)) { switch (biton32(default_layer_state)) {
case _COLEMAK: case _COLEMAK:
oled_write_P(PSTR("Colemak"), false); oled_write_P(PSTR("Colemak"), false);
@ -121,6 +125,37 @@ void render_layout_state(void) {
oled_write_ln_P(PSTR("Undefined"), false); oled_write_ln_P(PSTR("Undefined"), false);
} }
} }
#ifdef ENCODER_ENABLE
static void render_encoder_state(void) {
oled_write_P(PSTR("\nEnc: "), false);
bool lower = layer_state_is(_LOWER) & !layer_state_is(_ADJUST);
bool raise = layer_state_is(_RAISE) & !layer_state_is(_ADJUST);
bool adjust = layer_state_is(_ADJUST);
if(lower){
oled_write_P(PSTR("APPSW"), left_encoder_rotated);
oled_slash_separator();
oled_write_P(PSTR("UPDN"), right_encoder_rotated);
} else if(raise){
oled_write_P(PSTR("PGUD"), left_encoder_rotated);
oled_slash_separator();
oled_write_P(PSTR("TABSW"), right_encoder_rotated);
} else if(adjust){
oled_write_P(PSTR("RHUE"), left_encoder_rotated);
oled_slash_separator();
oled_write_P(PSTR("RBRI"), right_encoder_rotated);
} else {
oled_write_P(PSTR("BRI"), left_encoder_rotated);
oled_slash_separator();
oled_write_P(PSTR("VOL"), right_encoder_rotated);
}
if (timer_elapsed(encoder_rotated_timer) > 200) {
left_encoder_rotated = false;
right_encoder_rotated = false;
}
}
#endif
static void render_layer_state(void) { static void render_layer_state(void) {
oled_write_P(PSTR("\nLayer:"), false); oled_write_P(PSTR("\nLayer:"), false);
@ -156,6 +191,9 @@ void render_mod_state(uint8_t modifiers) {
static void render_status(void) { static void render_status(void) {
render_qmk_logo(); render_qmk_logo();
render_layout_state(); render_layout_state();
#ifdef ENCODER_ENABLE
render_encoder_state();
#endif
render_layer_state(); render_layer_state();
render_mod_state(get_mods()|get_oneshot_mods()); render_mod_state(get_mods()|get_oneshot_mods());
} }

View File

@ -3,5 +3,4 @@ ENCODER_ENABLE = yes # Enables the use of one or more encoders
RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow RGBLIGHT_ENABLE = yes # Enable keyboard RGB underglow
LINK_TIME_OPTIMIZATION_ENABLE = yes LINK_TIME_OPTIMIZATION_ENABLE = yes
SRC += encoder.c \ SRC += oled.c
oled.c

View File

@ -125,7 +125,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
XXXXXXX, XXXXXXX, _____________MOUSE_1______________, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _____________MOUSE_1______________, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, _____________MOUSE_2______________, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, _____________MOUSE_2______________, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
__________________________________, __________________________________ __________________________________, _______, _______, _______, K_CPRF
), ),
/* ADJUST /* ADJUST

View File

@ -1 +1,2 @@
OLED_DRIVER_ENABLE = yes OLED_DRIVER_ENABLE = yes
LINK_TIME_OPTIMIZATION_ENABLE = yes

View File

@ -27,5 +27,5 @@
#define USE_SERIAL_PD2 #define USE_SERIAL_PD2
#define TAPPING_FORCE_HOLD #define TAPPING_FORCE_HOLD
#define TAPPING_TERM 300 #define TAPPING_TERM 200
#define RETRO_TAPPPING #define RETRO_TAPPPING

View File

@ -31,7 +31,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------| //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
_____________________QWERTY_L3______________________, LT_RAI, LT_LOW, _____________________QWERTY_R3______________________, _____________________QWERTY_L3______________________, LT_RAI, LT_LOW, _____________________QWERTY_R3______________________,
//|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------| //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
________MOD_LEFT_________, K_LAPP, K_RAPP, ________MOD_RIGHT________ ________MOD_LEFT_________, XXXXXXX, XXXXXXX, ________MOD_RIGHT________
//`---------------------------------------' `---------------------------------------' //`---------------------------------------' `---------------------------------------'
), ),
@ -43,7 +43,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------| //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
_____________________DVORAK_L3______________________, LT_RAI, LT_LOW, _____________________DVORAK_R3______________________, _____________________DVORAK_L3______________________, LT_RAI, LT_LOW, _____________________DVORAK_R3______________________,
//|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------| //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
________MOD_LEFT_________, K_LAPP, K_RAPP, ________MOD_RIGHT________ ________MOD_LEFT_________, XXXXXXX, XXXXXXX, ________MOD_RIGHT________
//`---------------------------------------' `---------------------------------------' //`---------------------------------------' `---------------------------------------'
), ),
@ -55,7 +55,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
//|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------| //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
_____________________COLEMAK_L3_____________________, LT_RAI, LT_LOW, _____________________COLEMAK_R3_____________________, _____________________COLEMAK_L3_____________________, LT_RAI, LT_LOW, _____________________COLEMAK_R3_____________________,
//|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------| //|---------+---------+---------+---------+---------+---------+---------| |---------+---------+---------+---------+---------+---------+---------|
________MOD_LEFT_________, K_LAPP, K_RAPP, ________MOD_RIGHT________ ________MOD_LEFT_________, XXXXXXX, XXXXXXX, ________MOD_RIGHT________
//`---------------------------------------' `---------------------------------------' //`---------------------------------------' `---------------------------------------'
), ),

View File

@ -23,8 +23,6 @@ See: https://docs.qmk.fm/#/feature_userspace
|K_LOCK | MacOS shortcut to execute lock command Cmd + CTRL + Q | |K_LOCK | MacOS shortcut to execute lock command Cmd + CTRL + Q |
|K_CSCN | MacOS shortcut to copy a portion of the screen to the clipboard | |K_CSCN | MacOS shortcut to copy a portion of the screen to the clipboard |
|K_MDSH | MacOS shortcut to get em-dash `` | |K_MDSH | MacOS shortcut to get em-dash `` |
|K_RAPP | MacOS shortcut to switch apps to the right |
|K_LAPP | MacOS shortcut to switch apps to the left |
|K_CPRF | Cmd + Shift + M. Used for switching Google Chrome profiles | |K_CPRF | Cmd + Shift + M. Used for switching Google Chrome profiles |
### [Layers](ninjonas.h) ### [Layers](ninjonas.h)
@ -32,17 +30,12 @@ See: https://docs.qmk.fm/#/feature_userspace
|---|---| |---|---|
|LT_LOW | Tap for ENTER, hold for RAISE | |LT_LOW | Tap for ENTER, hold for RAISE |
|LT_RAI | Tap for SPACE, hold for LOWER | |LT_RAI | Tap for SPACE, hold for LOWER |
|LT_LOW + LT_RAI | Hold for ADJUST |
|LM_LOW | Dedicated key to momentarily toggle to use LOWER layer |
|LM_RAI | Dedicated key to momentarily toggle to use RAISE layer |
|LG_LOW | Press to toggle LOWER layer |
|LG_RAI | Press to toggle RAISE layer |
### [Mod-Taps](ninjonas.h) ### [Mod-Taps](ninjonas.h)
|Code | Description | |Code | Description |
|---|---| |---|---|
|MT_DEL | Tap for Delete, hold for Cmd + ALT + SHIFT | |MT_DEL | Tap for Delete, hold for ALT + SHIFT |
|MT_EQL | Tap for =, hold for ALT + SHIFT | |MT_EQL | Tap for =, SHIFT |
### [Layout Blocks](ninjonas.h) ### [Layout Blocks](ninjonas.h)
Predefined keyboard layout templates to speed up configuring split keyboards Predefined keyboard layout templates to speed up configuring split keyboards
@ -72,7 +65,6 @@ Predefined keyboard layout templates to speed up configuring split keyboards
|M_SHFT | Sends Cmd + alt + shift to a keycode to activate [ShiftIt](https://github.com/fikovnik/ShiftIt) | |M_SHFT | Sends Cmd + alt + shift to a keycode to activate [ShiftIt](https://github.com/fikovnik/ShiftIt) |
|M_CODE | Opens [Visual Studio Code](https://code.visualstudio.com/) on current directory | |M_CODE | Opens [Visual Studio Code](https://code.visualstudio.com/) on current directory |
|M_TERM | Launches Spotlight and calls Terminal | |M_TERM | Launches Spotlight and calls Terminal |
|M_COPA | Single key copy/paste |
|M_XXX1 to M_XXX5 | Reserved for secret macros see [Secrets](#secrets) | |M_XXX1 to M_XXX5 | Reserved for secret macros see [Secrets](#secrets) |
### [Tap-Dance](tap_dances.h) ### [Tap-Dance](tap_dances.h)
@ -84,11 +76,18 @@ Predefined keyboard layout templates to speed up configuring split keyboards
|T_TAB | Tap once for TAB, double for CTRL + TAB | |T_TAB | Tap once for TAB, double for CTRL + TAB |
|T_GRV | Tap once for GRV, double for Cmd + GRV | |T_GRV | Tap once for GRV, double for Cmd + GRV |
|T_GUI | Tap once for Cmd, double to open spotlight | |T_GUI | Tap once for Cmd, double to open spotlight |
|T_W | Tap for W, double tap for Cmd + W | |T_CPAP | Tap for Cmd + V, hold for Cmd + C, double tap to open [Line](https://line.me/en/) app, triple tap for itunes. |
|T_Q | Tap for Q, double tap for Cmd + Q |
|T_CPNU | Tap for Cmd + V, hold for Cmd + C, double tap for NUMPAD layer |
|T_Y | Tap for Y, double tap for NUMPAD layer | |T_Y | Tap for Y, double tap for NUMPAD layer |
### [Combos](combos.h)
|Code | Description |
|---|---|
|EQ_QUIT | Press E + Q will trigger Cmd + Q |
|RW_CLOSE | Press R + W will trigger Cmd + W|
|ET_TAB | Press E + T will trigger Cmd + T|
|ZC_COPY | Press Z + C will trigger Cmd + C|
|XV_PASTE | Press X + V will trigger Cmd + V|
### Secrets ### Secrets
There's times where you have macros you don't want to share like emails, an address you need but you always forget, passwords 😱, & and private strings. Based off [drashna's secret macros](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/readme_secrets.md), it's now possible to do this. All you need to do is create a `secrets.c` file. Below is an example of how this is used. There's times where you have macros you don't want to share like emails, an address you need but you always forget, passwords 😱, & and private strings. Based off [drashna's secret macros](https://github.com/qmk/qmk_firmware/blob/master/users/drashna/readme_secrets.md), it's now possible to do this. All you need to do is create a `secrets.c` file. Below is an example of how this is used.

55
users/ninjonas/combos.c Normal file
View File

@ -0,0 +1,55 @@
#include "ninjonas.h"
#ifdef COMBO_ENABLE
enum combo_events {
EQ_QUIT,
RW_CLOSE,
QT_TAB,
ZC_COPY,
XV_PASTE
};
const uint16_t PROGMEM quit_combo[] = {KC_E, KC_Q, COMBO_END};
const uint16_t PROGMEM close_combo[] = {KC_R, KC_W, COMBO_END};
const uint16_t PROGMEM tab_combo[] = {KC_Q, KC_T, COMBO_END};
const uint16_t PROGMEM copy_combo[] = {KC_Z, KC_C, COMBO_END};
const uint16_t PROGMEM paste_combo[] = {KC_X, KC_V, COMBO_END};
combo_t key_combos[COMBO_COUNT] = {
[EQ_QUIT] = COMBO_ACTION(quit_combo),
[RW_CLOSE] = COMBO_ACTION(close_combo),
[QT_TAB] = COMBO_ACTION(tab_combo),
[ZC_COPY] = COMBO_ACTION(copy_combo),
[XV_PASTE] = COMBO_ACTION(paste_combo),
};
void process_combo_event(uint8_t combo_index, bool pressed) {
switch(combo_index) {
case EQ_QUIT:
if (pressed) {
tap_code16(LGUI(KC_Q));
}
break;
case RW_CLOSE:
if (pressed) {
tap_code16(LGUI(KC_W));
}
break;
case QT_TAB:
if (pressed) {
tap_code16(LGUI(KC_T));
}
break;
case ZC_COPY:
if (pressed) {
tap_code16(LGUI(KC_C));
}
break;
case XV_PASTE:
if (pressed) {
tap_code16(LGUI(KC_V));
}
break;
}
}
#endif

View File

@ -1,6 +1,6 @@
#ifdef TAPPING_TERM #ifdef TAPPING_TERM
#undef TAPPING_TERM #undef TAPPING_TERM
#define TAPPING_TERM 300 #define TAPPING_TERM 200
#endif #endif
// Mouse Settings: Smoothing out mouse movement on keypress // Mouse Settings: Smoothing out mouse movement on keypress
@ -11,4 +11,11 @@
#define MOUSEKEY_DELAY 0 #define MOUSEKEY_DELAY 0
#define MOUSEKEY_TIME_TO_MAX 60 #define MOUSEKEY_TIME_TO_MAX 60
#define MOUSEKEY_MAX_SPEED 7 #define MOUSEKEY_MAX_SPEED 7
#define MOUSEKEY_WHEEL_DELAY 0 #define MOUSEKEY_WHEEL_DELAY 0
#ifdef COMBO_ENABLE
#undef COMBO_COUNT
#undef COMBO_TERM
#define COMBO_COUNT 5
#define COMBO_TERM 60
#endif

104
users/ninjonas/encoder.c Normal file
View File

@ -0,0 +1,104 @@
/* Copyright 2020 ninjonas
*
* 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/>.
*/
#include "ninjonas.h"
#ifdef ENCODER_ENABLE
void left_encoder_cw(void) {
switch (get_highest_layer(layer_state)) {
case _LOWER:
tap_code16(LGUI(KC_TAB));
break;
case _RAISE:
tap_code(KC_PGDN);
break;
case _ADJUST:
rgblight_decrease_hue();
break;
default:
tap_code(KC_BRID);
break;
}
}
void left_encoder_acw(void) {
switch (get_highest_layer(layer_state)) {
case _LOWER:
tap_code16(SGUI(KC_TAB));
break;
case _RAISE:
tap_code(KC_PGUP);
break;
case _ADJUST:
rgblight_increase_hue();
break;
default:
tap_code(KC_BRIU);
break;
}
}
void right_encoder_cw(void) {
switch (get_highest_layer(layer_state)) {
case _LOWER:
tap_code(KC_DOWN);
break;
case _RAISE:
tap_code16(LCTL(LSFT(KC_TAB)));
break;
case _ADJUST:
rgblight_decrease_val();
break;
default:
tap_code(KC_VOLD);
break;
}
}
void right_encoder_acw(void) {
switch (get_highest_layer(layer_state)) {
case _LOWER:
tap_code(KC_UP);
break;
case _RAISE:
tap_code16(LCTL(KC_TAB));
break;
case _ADJUST:
rgblight_increase_val();
break;
default:
tap_code(KC_VOLU);
break;
}
}
void encoder_update_user(uint8_t index, bool clockwise) {
encoder_rotated_timer = timer_read();
if (index == 0) {
left_encoder_rotated = true;
if (clockwise) {
left_encoder_cw();
} else {
left_encoder_acw();
}
}
else if (index == 1) {
right_encoder_rotated = true;
if (clockwise) {
right_encoder_cw();
} else {
right_encoder_acw();
}
}
}
#endif

View File

@ -27,6 +27,12 @@
#include "split_util.h" #include "split_util.h"
#endif #endif
#ifdef ENCODER_ENABLE
bool left_encoder_rotated;
bool right_encoder_rotated;
uint16_t encoder_rotated_timer;
#endif
#define _QWERTY 0 #define _QWERTY 0
#define _DVORAK 1 #define _DVORAK 1
#define _COLEMAK 2 #define _COLEMAK 2
@ -40,24 +46,17 @@
#define K_CSCN LGUI(LCTL(LSFT(KC_4))) // Copy a portion of the screen to the clipboard #define K_CSCN LGUI(LCTL(LSFT(KC_4))) // Copy a portion of the screen to the clipboard
#define K_CPRF LGUI(LSFT(KC_M)) // Cmd + Shift + M. Used for switching Google Chrome profiles #define K_CPRF LGUI(LSFT(KC_M)) // Cmd + Shift + M. Used for switching Google Chrome profiles
#define K_MDSH LSFT(LALT(KC_MINS)) #define K_MDSH LSFT(LALT(KC_MINS))
#define K_LAPP SGUI(KC_TAB) // Cmd + Shift + Tab
#define K_RAPP LGUI(KC_TAB) // Cmd + Tab
// Layer Keys // Layer Keys
#define LM_LOW MO(_LOWER)
#define LM_RAI MO(_RAISE)
#define LG_LOW TG(_LOWER)
#define LG_RAI TG(_RAISE)
#define LG_NUM TG(_NUMPAD)
#define LT_LOW LT(_LOWER, KC_ENT) #define LT_LOW LT(_LOWER, KC_ENT)
#define LT_RAI LT(_RAISE, KC_SPC) #define LT_RAI LT(_RAISE, KC_SPC)
// Mod-Tap Keys // Mod-Tap Keys
#define MT_DEL MT(MOD_LGUI | MOD_LALT | MOD_LSFT, KC_DEL) #define MT_DEL MT(MOD_LALT | MOD_LSFT, KC_DEL)
#define MT_EQL MT(MOD_LALT | MOD_LSFT, KC_EQL) #define MT_EQL MT(MOD_RSFT, KC_EQL)
// Layout blocks // Layout blocks
#define _____________________QWERTY_L1______________________ T_TAB, T_Q, KC_W, KC_E, KC_R, KC_T #define _____________________QWERTY_L1______________________ T_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T
#define _____________________QWERTY_L2______________________ T_ESC, KC_A, KC_S, KC_D, KC_F, KC_G #define _____________________QWERTY_L2______________________ T_ESC, KC_A, KC_S, KC_D, KC_F, KC_G
#define _____________________QWERTY_L3______________________ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B #define _____________________QWERTY_L3______________________ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B
@ -130,7 +129,7 @@
#define __________________________________ _______, _______, _______, _______ #define __________________________________ _______, _______, _______, _______
#define _____________MOD_LEFT_____________ KC_LALT, T_GUI, KC_LCTL, LT_RAI #define _____________MOD_LEFT_____________ KC_LALT, T_GUI, KC_LCTL, LT_RAI
#define _____________MOD_RIGHT____________ LT_LOW, KC_BSPC, MT_DEL, T_CPNU #define _____________MOD_RIGHT____________ LT_LOW, KC_BSPC, MT_DEL, T_CPAP
#define _________MEDIA_1_________ KC_BRIU, KC_MPLY, KC_MUTE #define _________MEDIA_1_________ KC_BRIU, KC_MPLY, KC_MUTE
#define _________MEDIA_2_________ KC_BRID, KC_MFFD, KC__VOLUP #define _________MEDIA_2_________ KC_BRID, KC_MFFD, KC__VOLUP
@ -141,7 +140,7 @@
#define ________MOD_RIGHT________ LT_LOW, KC_BSPC, MT_DEL #define ________MOD_RIGHT________ LT_LOW, KC_BSPC, MT_DEL
#else #else
#define ________MOD_LEFT_________ KC_LALT, T_GUI, KC_LCTL #define ________MOD_LEFT_________ KC_LALT, T_GUI, KC_LCTL
#define ________MOD_RIGHT________ KC_BSPC, MT_DEL, T_CPNU #define ________MOD_RIGHT________ KC_BSPC, MT_DEL, T_CPAP
#endif #endif
// Layout wrappers // Layout wrappers

View File

@ -1,7 +1,5 @@
#include "ninjonas.h" #include "ninjonas.h"
uint16_t copy_paste_timer;
__attribute__((weak)) __attribute__((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; } bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }
@ -92,18 +90,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
} }
break; break;
// Single key copy/paste
case M_COPA:
if (record->event.pressed) {
copy_paste_timer = timer_read();
} else {
if (timer_elapsed(copy_paste_timer) > TAPPING_TERM) {
tap_code16(LGUI(KC_C)); // Hold Cmd + C
} else {
tap_code16(LGUI(KC_V)); // Tap Cmd + V
}
}
// BEGIN: Layer macros // BEGIN: Layer macros
case QWERTY: case QWERTY:
if (record->event.pressed) { if (record->event.pressed) {

View File

@ -15,7 +15,6 @@ enum custom_keycodes {
M_VRSN, M_VRSN,
M_CODE, M_CODE,
M_TERM, M_TERM,
M_COPA,
// Secret Macros // Secret Macros
M_XXX1, M_XXX1,
M_XXX2, M_XXX2,

View File

@ -2,11 +2,14 @@ BOOTMAGIC_ENABLE = no # Disable Boot Magic (https://beta.docs.qmk.fm/featu
MOUSEKEY_ENABLE = yes # Mouse keys(+4700) MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450) EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
TAP_DANCE_ENABLE = yes # Enable Tap Dance. TAP_DANCE_ENABLE = yes # Enable Tap Dance.
COMBO_ENABLE = yes # Enable Combos
SRC += ninjonas.c \ SRC += ninjonas.c \
process_records.c \ process_records.c \
tap_dances.c \ tap_dances.c \
oled.c oled.c \
encoder.c \
combos.c
ifneq ("$(wildcard $(USER_PATH)/secrets.c)","") ifneq ("$(wildcard $(USER_PATH)/secrets.c)","")
SRC += secrets.c SRC += secrets.c

View File

@ -2,28 +2,41 @@
//// BEGIN: Advanced Tap Dances //// BEGIN: Advanced Tap Dances
int cur_dance (qk_tap_dance_state_t *state) { int cur_dance (qk_tap_dance_state_t *state) {
if (state->count == 1) { if (state->count == 1) {
if (!state->pressed) { if (state->interrupted || !state->pressed) return SINGLE_TAP;
return SINGLE_TAP; //key has not been interrupted, but they key is still held. Means you want to send a 'HOLD'.
} else { else return SINGLE_HOLD;
return SINGLE_HOLD;
}
} else if (state->count == 2) {
return DOUBLE_TAP;
} }
else return 8; 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
} }
// BEGIN: Copy, Paste, NUMPAD // BEGIN: Copy, Paste, Apps
// https://beta.docs.qmk.fm/features/feature_tap_dance#example-6-using-tap-dance-for-momentary-layer-switch-and-layer-toggle-keys // https://beta.docs.qmk.fm/features/feature_tap_dance#example-6-using-tap-dance-for-momentary-layer-switch-and-layer-toggle-keys
static tap copy_paste_numpad_tap_state = { static tap copy_paste_app_tap_state = {
.is_press_action = true, .is_press_action = true,
.state = 0 .state = 0
}; };
void copy_paste_numpad_finished (qk_tap_dance_state_t *state, void *user_data) { void copy_paste_app_finished (qk_tap_dance_state_t *state, void *user_data) {
copy_paste_numpad_tap_state.state = cur_dance(state); copy_paste_app_tap_state.state = cur_dance(state);
switch (copy_paste_numpad_tap_state.state) { switch (copy_paste_app_tap_state.state) {
case SINGLE_TAP: case SINGLE_TAP:
tap_code16(LGUI(KC_V)); // Tap Cmd + V tap_code16(LGUI(KC_V)); // Tap Cmd + V
break; break;
@ -31,19 +44,22 @@ void copy_paste_numpad_finished (qk_tap_dance_state_t *state, void *user_data) {
tap_code16(LGUI(KC_C)); // Hold Cmd + C tap_code16(LGUI(KC_C)); // Hold Cmd + C
break; break;
case DOUBLE_TAP: case DOUBLE_TAP:
if (layer_state_is(_NUMPAD)) { SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_SPACE) SS_UP(X_LGUI));
layer_off(_NUMPAD); wait_ms(250);
} else { SEND_STRING("line\n");
layer_on(_NUMPAD); break;
} case TRIPLE_TAP:
SEND_STRING(SS_DOWN(X_LGUI) SS_TAP(X_SPACE) SS_UP(X_LGUI));
wait_ms(250);
SEND_STRING("itunes\n");
break; break;
} }
} }
void copy_paste_numpad_reset (qk_tap_dance_state_t *state, void *user_data) { void copy_paste_app_reset (qk_tap_dance_state_t *state, void *user_data) {
copy_paste_numpad_tap_state.state = 0; copy_paste_app_tap_state.state = 0;
} }
// END: Copy, Paste, NUMPAD // END: Copy, Paste, Apps
// BEGIN: Y, NUMPAD // BEGIN: Y, NUMPAD
static tap y_numpad_tap_state = { static tap y_numpad_tap_state = {
@ -89,10 +105,8 @@ qk_tap_dance_action_t tap_dance_actions[] = {
[TD_TAB_CTRLTAB] = ACTION_TAP_DANCE_DOUBLE(KC_TAB, LCTL(KC_TAB)), [TD_TAB_CTRLTAB] = ACTION_TAP_DANCE_DOUBLE(KC_TAB, LCTL(KC_TAB)),
[TD_GRV_CTRLGRV] = ACTION_TAP_DANCE_DOUBLE(KC_GRV, LGUI(KC_GRV)), [TD_GRV_CTRLGRV] = ACTION_TAP_DANCE_DOUBLE(KC_GRV, LGUI(KC_GRV)),
[TD_GUI_GUISPC] = ACTION_TAP_DANCE_DOUBLE(KC_LGUI, LGUI(KC_SPC)), [TD_GUI_GUISPC] = ACTION_TAP_DANCE_DOUBLE(KC_LGUI, LGUI(KC_SPC)),
[TD_W_CTRLW] = ACTION_TAP_DANCE_DOUBLE(KC_W, LGUI(KC_W)),
[TD_Q_GUIQ] = ACTION_TAP_DANCE_DOUBLE(KC_Q, LGUI(KC_Q)),
// Advanced Tap Dances // Advanced Tap Dances
[TD_COPY_PASTE_NUMPAD] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, copy_paste_numpad_finished, copy_paste_numpad_reset), [TD_COPY_PASTE_APP] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, copy_paste_app_finished, copy_paste_app_reset, 300),
[TD_Y_NUMPAD] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, y_numpad_finished, y_numpad_reset), [TD_Y_NUMPAD] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, y_numpad_finished, y_numpad_reset, 300),
}; };

View File

@ -9,7 +9,11 @@ typedef struct {
enum tapdance_types{ enum tapdance_types{
SINGLE_TAP = 1, SINGLE_TAP = 1,
SINGLE_HOLD = 2, SINGLE_HOLD = 2,
DOUBLE_TAP = 3 DOUBLE_TAP = 3,
DOUBLE_HOLD = 4,
DOUBLE_SINGLE_TAP = 5, //send two single taps
TRIPLE_TAP = 6,
TRIPLE_HOLD = 7
}; };
enum custom_tapdances{ enum custom_tapdances{
@ -19,9 +23,7 @@ enum custom_tapdances{
TD_TAB_CTRLTAB, TD_TAB_CTRLTAB,
TD_GRV_CTRLGRV, TD_GRV_CTRLGRV,
TD_GUI_GUISPC, TD_GUI_GUISPC,
TD_W_CTRLW, TD_COPY_PASTE_APP,
TD_Q_GUIQ,
TD_COPY_PASTE_NUMPAD,
TD_Y_NUMPAD, TD_Y_NUMPAD,
}; };
@ -31,7 +33,5 @@ enum custom_tapdances{
#define T_TAB TD(TD_TAB_CTRLTAB) // Tap for TAB, double tap for CTRL + TAB #define T_TAB TD(TD_TAB_CTRLTAB) // Tap for TAB, double tap for CTRL + TAB
#define T_GRV TD(TD_GRV_CTRLGRV) // Tap for GRV, double tap for Cmd + GRV #define T_GRV TD(TD_GRV_CTRLGRV) // Tap for GRV, double tap for Cmd + GRV
#define T_GUI TD(TD_GUI_GUISPC) // Tap for Cmd, double tap for Cmd + Space #define T_GUI TD(TD_GUI_GUISPC) // Tap for Cmd, double tap for Cmd + Space
#define T_W TD(TD_W_CTRLW) // Tap for W, double tap for Cmd + W #define T_CPAP TD(TD_COPY_PASTE_APP) // Tap for paste, hold for copy, double tap for Line App
#define T_Q TD(TD_Q_GUIQ) // Tap for Q, double tap for Cmd + Q
#define T_CPNU TD(TD_COPY_PASTE_NUMPAD) // Tap for paste, hold for copy, double tap for NUMPAD
#define T_Y TD(TD_Y_NUMPAD) // Tap for Y, double tap for NUMPAD #define T_Y TD(TD_Y_NUMPAD) // Tap for Y, double tap for NUMPAD