Skip to content

Commit

Permalink
[Keymap] ninjonas keymap updates (qmk#8373)
Browse files Browse the repository at this point in the history
* [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 <[email protected]>
  • Loading branch information
ninjonas and Jonas Avellana authored Mar 13, 2020
1 parent 2499c83 commit 11b4be5
Show file tree
Hide file tree
Showing 10 changed files with 242 additions and 76 deletions.
25 changes: 12 additions & 13 deletions users/ninjonas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,19 @@ See: https://docs.qmk.fm/#/feature_userspace
|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_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 |

### [Layers](ninjonas.h)
|Code | Description |
|---|---|
|LT_LOW | Tap for ENTER, hold for RAISE |
|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)
|Code | Description |
|---|---|
|MT_DEL | Tap for Delete, hold for Cmd + ALT + SHIFT |
|MT_EQL | Tap for =, hold for ALT + SHIFT |
|MT_DEL | Tap for Delete, hold for ALT + SHIFT |
|MT_EQL | Tap for =, SHIFT |

### [Layout Blocks](ninjonas.h)
Predefined keyboard layout templates to speed up configuring split keyboards
Expand Down Expand Up @@ -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_CODE | Opens [Visual Studio Code](https://code.visualstudio.com/) on current directory |
|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) |

### [Tap-Dance](tap_dances.h)
Expand All @@ -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_GRV | Tap once for GRV, double for Cmd + GRV |
|T_GUI | Tap once for Cmd, double to open spotlight |
|T_W | Tap for W, double tap for Cmd + W |
|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_CPAP | Tap for Cmd + V, hold for Cmd + C, double tap to open [Line](https://line.me/en/) app, triple tap for itunes. |
|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
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.

Expand Down
55 changes: 55 additions & 0 deletions users/ninjonas/combos.c
Original file line number Diff line number Diff line change
@@ -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
11 changes: 9 additions & 2 deletions users/ninjonas/config.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifdef TAPPING_TERM
#undef TAPPING_TERM
#define TAPPING_TERM 300
#define TAPPING_TERM 200
#endif

// Mouse Settings: Smoothing out mouse movement on keypress
Expand All @@ -11,4 +11,11 @@
#define MOUSEKEY_DELAY 0
#define MOUSEKEY_TIME_TO_MAX 60
#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 changes: 104 additions & 0 deletions users/ninjonas/encoder.c
Original file line number Diff line number Diff line change
@@ -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
23 changes: 11 additions & 12 deletions users/ninjonas/ninjonas.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
#include "split_util.h"
#endif

#ifdef ENCODER_ENABLE
bool left_encoder_rotated;
bool right_encoder_rotated;
uint16_t encoder_rotated_timer;
#endif

#define _QWERTY 0
#define _DVORAK 1
#define _COLEMAK 2
Expand All @@ -40,24 +46,17 @@
#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_MDSH LSFT(LALT(KC_MINS))
#define K_LAPP SGUI(KC_TAB) // Cmd + Shift + Tab
#define K_RAPP LGUI(KC_TAB) // Cmd + Tab

// 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_RAI LT(_RAISE, KC_SPC)

// Mod-Tap Keys
#define MT_DEL MT(MOD_LGUI | MOD_LALT | MOD_LSFT, KC_DEL)
#define MT_EQL MT(MOD_LALT | MOD_LSFT, KC_EQL)
#define MT_DEL MT(MOD_LALT | MOD_LSFT, KC_DEL)
#define MT_EQL MT(MOD_RSFT, KC_EQL)

// 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_L3______________________ KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B

Expand Down Expand Up @@ -130,7 +129,7 @@
#define __________________________________ _______, _______, _______, _______

#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_2_________ KC_BRID, KC_MFFD, KC__VOLUP
Expand All @@ -141,7 +140,7 @@
#define ________MOD_RIGHT________ LT_LOW, KC_BSPC, MT_DEL
#else
#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

// Layout wrappers
Expand Down
14 changes: 0 additions & 14 deletions users/ninjonas/process_records.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "ninjonas.h"

uint16_t copy_paste_timer;

__attribute__((weak))
bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { return true; }

Expand Down Expand Up @@ -92,18 +90,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
}
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
case QWERTY:
if (record->event.pressed) {
Expand Down
1 change: 0 additions & 1 deletion users/ninjonas/process_records.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ enum custom_keycodes {
M_VRSN,
M_CODE,
M_TERM,
M_COPA,
// Secret Macros
M_XXX1,
M_XXX2,
Expand Down
5 changes: 4 additions & 1 deletion users/ninjonas/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ BOOTMAGIC_ENABLE = no # Disable Boot Magic (https://beta.docs.qmk.fm/featu
MOUSEKEY_ENABLE = yes # Mouse keys(+4700)
EXTRAKEY_ENABLE = yes # Audio control and System control(+450)
TAP_DANCE_ENABLE = yes # Enable Tap Dance.
COMBO_ENABLE = yes # Enable Combos

SRC += ninjonas.c \
process_records.c \
tap_dances.c \
oled.c
oled.c \
encoder.c \
combos.c

ifneq ("$(wildcard $(USER_PATH)/secrets.c)","")
SRC += secrets.c
Expand Down
Loading

0 comments on commit 11b4be5

Please sign in to comment.