Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Keymap] Add paulomp90 lily58 keymap #20327

Merged
merged 13 commits into from
Apr 12, 2023
25 changes: 25 additions & 0 deletions keyboards/lily58/keymaps/paulomp90/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once
paulomp90 marked this conversation as resolved.
Show resolved Hide resolved

#define MASTER_LEFT
paulomp90 marked this conversation as resolved.
Show resolved Hide resolved

#define QUICK_TAP_TERM 0
#define TAPPING_TERM 150

#undef RGBLED_NUM
#define RGBLIGHT_EFFECT_BREATHING
#define RGBLIGHT_EFFECT_RAINBOW_MOOD
#define RGBLIGHT_EFFECT_RAINBOW_SWIRL
#define RGBLIGHT_EFFECT_SNAKE
#define RGBLIGHT_EFFECT_KNIGHT
#define RGBLIGHT_EFFECT_CHRISTMAS
#define RGBLIGHT_EFFECT_STATIC_GRADIENT
#define RGBLIGHT_EFFECT_RGB_TEST
#define RGBLIGHT_EFFECT_ALTERNATING
#define RGBLIGHT_EFFECT_TWINKLE
#define RGBLED_NUM 27
drashna marked this conversation as resolved.
Show resolved Hide resolved
#define RGBLIGHT_LIMIT_VAL 120
#define RGBLIGHT_HUE_STEP 10
#define RGBLIGHT_SAT_STEP 17
#define RGBLIGHT_VAL_STEP 17

#define TAP_CODE_DELAY 10
54 changes: 54 additions & 0 deletions keyboards/lily58/keymaps/paulomp90/features/custom_shift_keys.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// Copyright 2021-2023 Google LLC.
// SPDX-License-Identifier: Apache-2.0

#include "custom_shift_keys.h"

bool process_custom_shift_keys(uint16_t keycode, keyrecord_t *record) {
static uint16_t registered_keycode = KC_NO;

// If a custom shift key is registered, then this event is either
// releasing it or manipulating another key at the same time. Either way,
// we release the currently registered key.
if (registered_keycode != KC_NO) {
unregister_code16(registered_keycode);
registered_keycode = KC_NO;
}

if (record->event.pressed) { // Press event.
const uint8_t mods = get_mods();
#ifndef NO_ACTION_ONESHOT
if ((mods | get_weak_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT) {
#else
if ((mods | get_weak_mods()) & MOD_MASK_SHIFT) { // Shift is held.
#endif // NO_ACTION_ONESHOT
// Continue default handling if this is a tap-hold key being held.
if ((IS_QK_MOD_TAP(keycode) || IS_QK_LAYER_TAP(keycode)) &&
record->tap.count == 0) {
return true;
}

// Search for a custom shift key whose keycode is `keycode`.
for (int i = 0; i < NUM_CUSTOM_SHIFT_KEYS; ++i) {
if (keycode == custom_shift_keys[i].keycode) {
registered_keycode = custom_shift_keys[i].shifted_keycode;
if (IS_QK_MODS(registered_keycode) && // Should key be shifted?
(QK_MODS_GET_MODS(registered_keycode) & MOD_LSFT) != 0) {
register_code16(registered_keycode); // If so, press directly.
} else {
// If not, cancel shift mods, press the key, and restore mods.
del_weak_mods(MOD_MASK_SHIFT);
#ifndef NO_ACTION_ONESHOT
del_oneshot_mods(MOD_MASK_SHIFT);
#endif // NO_ACTION_ONESHOT
unregister_mods(MOD_MASK_SHIFT);
register_code16(registered_keycode);
set_mods(mods);
}
return false;
}
}
}
}

return true; // Continue with default handling.
}
15 changes: 15 additions & 0 deletions keyboards/lily58/keymaps/paulomp90/features/custom_shift_keys.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright 2021 Google LLC.
// SPDX-License-Identifier: Apache-2.0

#pragma once
#include QMK_KEYBOARD_H

typedef struct {
uint16_t keycode;
uint16_t shifted_keycode;
} custom_shift_key_t;

extern const custom_shift_key_t custom_shift_keys[];
extern uint8_t NUM_CUSTOM_SHIFT_KEYS;

bool process_custom_shift_keys(uint16_t keycode, keyrecord_t *record);
237 changes: 237 additions & 0 deletions keyboards/lily58/keymaps/paulomp90/keymap.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
#include QMK_KEYBOARD_H
paulomp90 marked this conversation as resolved.
Show resolved Hide resolved
#include "keymap_portuguese.h"
#include "features/custom_shift_keys.h"

enum layer_number {
_QWERTY = 0,
_LOWER,
_RAISE,
_ADJUST,
};

/* tap dance shifts */
typedef struct {
bool is_press_action;
int state;
} tap;

enum {
SINGLE_TAP = 1,
SINGLE_HOLD = 2,
};

enum { LEFT_SHIFT = 0, RIGHT_SHIFT = 1 };

const custom_shift_key_t custom_shift_keys[] = {
{KC_BSPC, KC_DEL},
};

uint8_t NUM_CUSTOM_SHIFT_KEYS = sizeof(custom_shift_keys) / sizeof(custom_shift_key_t);

#define RAISE MO(_RAISE)
#define LOWER MO(_LOWER)

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

/* QWERTY
* ,-----------------------------------------. ,-----------------------------------------.
* | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | '? |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | Tab | Q | W | E | R | T | | Y | U | I | O | P | +* |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* |LShift| A | S | D | F | G |-------. ,-------| H | J | K | L | Ç | BACK |
* |------+------+------+------+------+------| <> | | ´` |------+------+------+------+------+------|
* |LCTRL | Z | X | C | V | B |-------| |-------| N | M | , | . | - |Shift|
* `-----------------------------------------/ / \ \-----------------------------------------'
* | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE | RGUI | RAlt |
* | | | |/ / \ \ | | | |
* `-------------------''-------' '------''--------------------'
*/
[_QWERTY] = LAYOUT(
KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_EQL,
TD(LEFT_SHIFT), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_BSPC,
KC_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_GRV, KC_RBRC, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, TD(RIGHT_SHIFT),
KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_ENT, RAISE, KC_RGUI, KC_RALT
),

/* LOWER
* ,-----------------------------------------. ,-----------------------------------------.
* | | | | | | | | | | | | | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | BRG- | BRG+ | VOL- | VOL+ | | | | | | | | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | MUTE | PREV | PLAY | NEXT | |-------. ,-------| | | \| | ºª | ~^ | |
* |------+------+------+------+------+------| | | |------+------+------+------+------+------|
* | | | | | | |-------| |-------| | | | | | |
* `-----------------------------------------/ / \ \-----------------------------------------'
* | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE | RGUI | RAlt |
* | | | |/ / \ \ | | | |
* `-------------------''-------' '------''--------------------'
*/

[_LOWER] = LAYOUT(
_______, _______, _______, _______, _______, _______, _______, _______, _______,_______, _______, _______,
_______, KC_BRID, KC_BRIU, KC_VOLD, KC_VOLU, _______, _______, _______, _______, _______, _______, _______,
_______, KC_MUTE, KC_MPRV, KC_MPLY, KC_MNXT, _______, _______, _______, KC_BSLS, KC_LBRC, KC_QUOT, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______
),

/* RAISE
* ,-----------------------------------------. ,-----------------------------------------.
* | | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | F1 | | | | | | | | | Up | | | F12 |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | End | Home | PGDN | PGUP | |-------. ,-------| | Left | Down |Right | | |
* |------+------+------+------+------+------| | | |------+------+------+------+------+------|
* | | | | | | |-------| |-------| | | | | | |
* `-----------------------------------------/ / \ \-----------------------------------------'
* | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE | RGUI | RAlt |
* | | | |/ / \ \ | | | |
* `-------------------''-------' '------''--------------------'
*/

[_RAISE] = LAYOUT(
_______, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, _______,
KC_F1, _______, _______, _______, _______, _______, _______, XXXXXXX, KC_UP, XXXXXXX, _______, KC_F12,
_______, KC_END, KC_HOME, KC_PGDN, KC_PGUP, _______, XXXXXXX, KC_LEFT, KC_DOWN, KC_RGHT, XXXXXXX, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______
),

/* ADJUST
* ,-----------------------------------------. ,-----------------------------------------.
* | | | | | | | | | | | | | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* | | | | | | | | | | | | | |
* |------+------+------+------+------+------| |------+------+------+------+------+------|
* |RGB ON| HUE+ | SAT+ | VAL+ | | |-------. ,-------| | | | | | |
* |------+------+------+------+------+------| | | |------+------+------+------+------+------|
* | MODE | HUE- | SAT- | VAL- | | |-------| |-------| | | | | | |
* `-----------------------------------------/ / \ \-----------------------------------------'
* | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE | RGUI | RAlt |
* | | | |/ / \ \ | | | |
* `----------------------------' '------''--------------------'
*/

[_ADJUST] = LAYOUT(
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX,
_______, _______, _______, _______, _______, _______, _______, _______
)
};

layer_state_t layer_state_set_user(layer_state_t state) {
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
}

paulomp90 marked this conversation as resolved.
Show resolved Hide resolved
// SSD1306 OLED update loop, make sure to enable OLED_ENABLE=yes in rules.mk
#ifdef OLED_ENABLE

oled_rotation_t oled_init_user(oled_rotation_t rotation) {
if (!is_keyboard_master()) return OLED_ROTATION_180; // flips the display 180 degrees if offhand
return rotation;
}

// When you add source files to SRC in rules.mk, you can use functions.
const char *read_layer_state(void);
const char *read_logo(void);
void set_keylog(uint16_t keycode, keyrecord_t *record);
const char *read_keylog(void);
const char *read_keylogs(void);

bool oled_task_user(void) {
if (is_keyboard_master()) {
oled_write_ln(read_layer_state(), false);
oled_write_ln(read_keylog(), false);
oled_write_ln(read_keylogs(), false);
} else {
oled_write(read_logo(), false);
}
return false;
}
#endif // OLED_ENABLE

bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (!process_custom_shift_keys(keycode, record)) {
return false;
}
if (record->event.pressed) {
#ifdef OLED_ENABLE
set_keylog(keycode, record);
#endif
}
return true;
}

/* Tap dance shifts */
int cur_dance(tap_dance_state_t *state) {
if (state->count == 1) {
if (state->pressed)
return SINGLE_HOLD;
else
return SINGLE_TAP;
} else
return 0;
}

static tap lshifttap_state = {.is_press_action = true, .state = 0};

static tap rshifttap_state = {.is_press_action = true, .state = 0};

void lshift_finished(tap_dance_state_t *state, void *user_data) {
lshifttap_state.state = cur_dance(state);
switch (lshifttap_state.state) {
case SINGLE_TAP:
register_code16(LALT(KC_LEFT));
break;
case SINGLE_HOLD:
register_code(KC_LSFT);
break;
}
}

void lshift_reset(tap_dance_state_t *state, void *user_data) {
switch (lshifttap_state.state) {
case SINGLE_TAP:
unregister_code16(LALT(KC_LEFT));
break;
case SINGLE_HOLD:
unregister_code(KC_LSFT);
break;
}
lshifttap_state.state = 0;
}

void rshift_finished(tap_dance_state_t *state, void *user_data) {
rshifttap_state.state = cur_dance(state);
switch (rshifttap_state.state) {
case SINGLE_TAP:
register_code16(LALT(KC_RGHT));
break;
case SINGLE_HOLD:
register_code(KC_RSFT);
break;
}
}

void rshift_reset(tap_dance_state_t *state, void *user_data) {
switch (rshifttap_state.state) {
case SINGLE_TAP:
unregister_code16(LALT(KC_RGHT));
break;
case SINGLE_HOLD:
unregister_code(KC_RSFT);
break;
}
rshifttap_state.state = 0;
}

tap_dance_action_t tap_dance_actions[] = {
[LEFT_SHIFT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, lshift_finished, lshift_reset),
[RIGHT_SHIFT] = ACTION_TAP_DANCE_FN_ADVANCED(NULL, rshift_finished, rshift_reset),
};
7 changes: 7 additions & 0 deletions keyboards/lily58/keymaps/paulomp90/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Paulo Lily58

Lily58 is 6×4+5keys column-staggered split keyboard.

- Add portuguese include
- Add custom shift behaviour, when tap move by 1 word left <> right, when held act as shift.
idea taken from [here](https://getreuer.info/posts/keyboards/custom-shift-keys/index.html).
13 changes: 13 additions & 0 deletions keyboards/lily58/keymaps/paulomp90/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
EXTRAKEY_ENABLE = yes # Audio control and System control
OLED_ENABLE= yes # OLED display
TAP_DANCE_ENABLE = yes

# If you want to change the display of OLED, you need to change here
SRC += ./lib/rgb_state_reader.c \
./lib/layer_state_reader.c \
./lib/logo_reader.c \
./lib/keylogger.c \
features/custom_shift_keys.c \
# ./lib/mode_icon_reader.c \
# ./lib/host_led_state_reader.c \
# ./lib/timelogger.c \