summaryrefslogtreecommitdiff
path: root/keyboards/lily58/keymaps/niolang/keymap.c
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2022-06-27 16:38:28 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2022-06-27 16:38:28 +0200
commit98b9909429aea0869f7a6f2f44ab386a4a3ff094 (patch)
treee1080a61bb89a75edc70818489f8044adf597c48 /keyboards/lily58/keymaps/niolang/keymap.c
parentb610965fd6d851484025166fb255078b1c809261 (diff)
parentfa3dd373b4925734d9843ae6014349069ffec353 (diff)
downloadqmk_firmware-98b9909429aea0869f7a6f2f44ab386a4a3ff094.tar.gz
qmk_firmware-98b9909429aea0869f7a6f2f44ab386a4a3ff094.zip
Merge branch 'master' into taamas
Diffstat (limited to 'keyboards/lily58/keymaps/niolang/keymap.c')
-rw-r--r--keyboards/lily58/keymaps/niolang/keymap.c359
1 files changed, 359 insertions, 0 deletions
diff --git a/keyboards/lily58/keymaps/niolang/keymap.c b/keyboards/lily58/keymaps/niolang/keymap.c
new file mode 100644
index 0000000000..e2f37f678c
--- /dev/null
+++ b/keyboards/lily58/keymaps/niolang/keymap.c
@@ -0,0 +1,359 @@
+ /* Copyright 2017 F_YUUCHI
+ * Copyright 2020 Drashna Jaelre <@drashna>
+ * Copyright 2020 Ben Roesner (keycapsss.com)
+ * Copyright 2022 Niolang
+ *
+ * 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 QMK_KEYBOARD_H
+#include "keymap_bepo.h"
+
+
+enum layers {
+ _BEPO,
+ _LOWER,
+ _RAISE,
+ _ADJUST,
+};
+
+#define RAISE MO(_RAISE)
+#define LOWER MO(_LOWER)
+
+//Modification of cut/copy/paste by their combination, works in more cases
+#define KC_COPY LCTL(KC_H)
+#define KC_CUT LCTL(KC_C)
+#define KC_PSTE2 LCTL(KC_U)
+
+const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
+
+/* BÉPO
+ * ,-----------------------------------------. ,-----------------------------------------.
+ * |ESC/VM| " 1 | « 2 | » 3 | ( 4 | ) 5 | | @ 6 | + 7 | - 8 | / 9 | * 0 | W |
+ * |------+------+------+------+------+------| |------+------+------+------+------+------|
+ * | Tab | B | | É | P & | O œ | È | | !^ | V | D | L | J | Z |
+ * |------+------+------+------+------+------| |------+------+------+------+------+------|
+ * |LCTRL | A | Uù | I¨ | E€ | ,;' |-------. ,-------| C/ç | Tᵉ | S | R | N | M |
+ * |------+------+------+------+------+------|CtPtScn| |SUPPR |------+------+------+------+------+------|
+ * |LShift| À \ | Y { | X } | .:… | K ~ |-------| |-------| ’? | Q | G | H | F |RShift|
+ * `-----------------------------------------/ / \ \-----------------------------------------'
+ * | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE |BackSP| AltGr|
+ * | | | |/ / \ \ | | | |
+ * `----------------------------' '------''--------------------'
+ */
+
+ [_BEPO] = LAYOUT(
+ MT(KC_CAPS, KC_ESC), BP_DQUO, BP_LDAQ, BP_RDAQ, BP_LPRN, BP_RPRN, BP_AT, BP_PLUS, BP_MINS, BP_SLSH, BP_ASTR, BP_W,
+ KC_TAB, BP_B, BP_EACU, BP_P, BP_O, BP_EGRV, BP_DCIR, BP_V, BP_D, BP_L, BP_J, BP_Z,
+ KC_LCTRL, BP_A, BP_U, BP_I, BP_E, BP_COMM, MT(BP_CCED, BP_C), BP_T, BP_S, BP_R, BP_N, BP_M,
+ KC_LSFT, BP_AGRV, BP_Y, BP_X, BP_DOT, BP_K, LSFT(KC_PSCR), KC_DEL, BP_QUOT, BP_Q, BP_G, BP_H, BP_F, KC_RSFT,
+ KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_ENT, RAISE, KC_BSPC, KC_RALT
+),
+/* LOWER
+ * ,-----------------------------------------. ,-----------------------------------------.
+ * | F1 | F2 | F3 | F4 | F5 | F6 | | + | 7 | 8 | 9 | = | # |
+ * |------+------+------+------+------+------| |------+------+------+------+------+------|
+ * | F7 | F8 | F9 | F10 | F11 | F12 | | - | 4 | 5 | 6 | % | ^ |
+ * |------+------+------+------+------+------| |------+------+------+------+------+------|
+ * |LCTRL | c+c | c+v | Up | home | end |-------. ,-------| / | 1 | 2 | 3 | < | > |
+ * |------+------+------+------+------+------|TGHi/Lo| |SUPPR |------+------+------+------+------+------|
+ * |LShift| c+x | Left | Down | Right| pscr |-------| |-------| * | 0 | . | , | ( | ) |
+ * `-----------------------------------------/ / \ \-----------------------------------------'
+ * | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE |BackSP| AltGr|
+ * | | | |/ / \ \ | | | |
+ * `----------------------------' '------''--------------------'
+ */
+[_LOWER] = LAYOUT(
+ KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_PPLS, KC_P7, KC_P8, KC_P9, BP_EQL, BP_HASH,
+ KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PMNS, KC_P4, KC_P5, KC_P6, BP_PERC, BP_RABK,
+ _______, KC_COPY, KC_PSTE2, KC_UP, KC_HOME, KC_END, KC_PSLS, KC_P1, KC_P2, KC_P3, BP_LABK, BP_RABK,
+ _______, KC_CUT, KC_LEFT, KC_DOWN, KC_RGHT, KC_PSCR,TG(_RAISE), _______, KC_PAST, KC_P0, KC_PDOT, KC_PCMM, BP_LPRN, BP_RPRN,
+ _______, _______, _______, _______, _______, _______, _______, _______
+),
+[_RAISE] = LAYOUT(
+ KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_PPLS, KC_P7, KC_P8, KC_P9, BP_EQL, BP_HASH,
+ KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PMNS, KC_P4, KC_P5, KC_P6, BP_PERC, BP_CIRC,
+ _______, KC_COPY, KC_PSTE2, KC_UP, KC_HOME, KC_END, KC_PSLS, KC_P1, KC_P2, KC_P3, BP_LABK, BP_RABK,
+ _______, KC_CUT, KC_LEFT, KC_DOWN, KC_RGHT, KC_PSCR,TG(_LOWER), _______, KC_PAST, KC_P0, KC_PDOT, KC_PCMM, BP_LPRN, BP_RPRN,
+ _______, _______, _______, _______, _______, _______, _______, _______
+),
+
+/* ADJUST
+ * ,-----------------------------------------. ,-----------------------------------------.
+ * | | | | | | | | ScLck| Ins | Pause| | | |
+ * |------+------+------+------+------+------| |------+------+------+------+------+------|
+ * | | | | | | | | NUML | | | | | |
+ * |------+------+------+------+------+------| |------+------+------+------+------+------|
+ * | | | | | | |-------. ,-------| | |RGB ON| HUE+ | SAT+ | VAL+ |
+ * |------+------+------+------+------+------| | | |------+------+------+------+------+------|
+ * | | | | | | |-------| |-------| | | MODE | HUE- | SAT- | VAL- |
+ * `-----------------------------------------/ / \ \-----------------------------------------'
+ * | LAlt | LGUI |LOWER | /Space / \Enter \ |RAISE |BackSP| RGUI |
+ * | | | |/ / \ \ | | | |
+ * `----------------------------' '------''--------------------'
+ */
+ [_ADJUST] = LAYOUT(
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_SLCK, KC_INS, KC_PAUSE, XXXXXXX, XXXXXXX, XXXXXXX,
+ XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, KC_NLCK, 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, XXXXXXX, XXXXXXX, RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD,
+ _______, _______, _______, _______, _______, _______, _______, _______
+ )
+};
+
+layer_state_t layer_state_set_user(layer_state_t state) {
+ state = update_tri_layer_state(state, _RAISE, _LOWER, _ADJUST);
+ return state;
+}
+
+//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_270;
+ } else {
+ return OLED_ROTATION_0;
+ }
+}
+
+void render_lily58_logo(void) {
+ static const char PROGMEM lily58_logo[] = {
+ // 'logo', 128x32px
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0xc0, 0x40, 0x40, 0xc0, 0x80, 0x80, 0x80, 0x00, 0x00,
+ 0x80, 0xe0, 0x70, 0x3c, 0x0e, 0x06, 0x0e, 0x3c, 0x70, 0xe0, 0x80, 0x00, 0x00, 0xc0, 0xc0, 0x00,
+ 0xc0, 0xc0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x00, 0x00, 0x80,
+ 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x80, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x80, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0xc0, 0xc0, 0xc0, 0xc0, 0xc0, 0x80, 0x80, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xfc, 0xc0, 0x80, 0x80, 0x80, 0x81, 0x83, 0x83,
+ 0x07, 0x07, 0x0c, 0x18, 0x70, 0xe0, 0x80, 0x00, 0x00, 0x01, 0xff, 0xfc, 0x80, 0xb6, 0xb6, 0x80,
+ 0xb0, 0xb0, 0x00, 0x36, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0xf1, 0x00, 0x00, 0x00, 0x00, 0xff,
+ 0xff, 0x00, 0x00, 0x00, 0x30, 0xf0, 0xf0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xf0, 0xf0,
+ 0x30, 0x00, 0x00, 0x7f, 0xff, 0xff, 0xe1, 0x71, 0x71, 0xf1, 0xf1, 0xe1, 0xc1, 0x81, 0x00, 0x00,
+ 0x00, 0x00, 0x0c, 0x3f, 0xff, 0xf3, 0xe1, 0xc1, 0xc1, 0x81, 0x81, 0xc3, 0xff, 0x7f, 0x1c, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x20, 0x70, 0x78, 0xdc, 0xcc, 0x86, 0x06, 0x03, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x03, 0x02, 0x06, 0x84, 0xe1, 0xfb, 0x38, 0x1c, 0x0c, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x03, 0x03, 0x06, 0x86, 0xcc, 0xdc, 0x78, 0x70, 0x20, 0x00, 0xff, 0xff, 0x80, 0x80,
+ 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0xff,
+ 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x03, 0x1f, 0x7e, 0xf8, 0xe0, 0xf0, 0x7e, 0x1f, 0x03, 0x00,
+ 0x00, 0x00, 0x00, 0xe0, 0xe0, 0xc0, 0xc0, 0x80, 0x80, 0x80, 0xc0, 0xe1, 0xff, 0x7f, 0x3f, 0x00,
+ 0x00, 0x00, 0x3e, 0xff, 0xff, 0xc1, 0xc0, 0x80, 0x81, 0x81, 0xc3, 0xc3, 0xff, 0xfe, 0x3c, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x06, 0x06, 0x06, 0x04, 0x04, 0x04, 0x04, 0x06,
+ 0x06, 0x02, 0x03, 0x01, 0x01, 0x00, 0x01, 0x01, 0x03, 0x02, 0x06, 0x06, 0x04, 0x04, 0x04, 0x04,
+ 0x06, 0x06, 0x06, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01,
+ 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x01, 0x01, 0x01, 0x00, 0x00, 0x60, 0x60, 0x70, 0x38, 0x1f, 0x0f, 0x03, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00
+};
+ oled_write_raw_P(lily58_logo, sizeof(lily58_logo));
+}
+
+
+# define KEYLOG_LEN 6
+char keylog_str[KEYLOG_LEN] = {};
+uint8_t keylogs_str_idx = 0;
+uint16_t log_timer = 0;
+
+const char code_to_name[60] = {
+ ' ', ' ', ' ', ' ', 'a', 'k', 'x', 'i', 'p', 'e',
+ ',', 'c', 'd', 't', 's', 'r', 'q', ' ', 'l', 'j',
+ 'b', 'o', 'u', 'e', 'v', '.', 'e', 'y', '^', 'a',
+ ' ', ' ', ' ', '(', ')', '@', '+', '-', '/', '*',
+ 'R', 'E', 'B', 'T', '_', '-', '=', '[', ']', '\\',
+ '#', ';', '\'', '`', ',', '.', '/', ' ', ' ', ' '};
+
+void add_keylog(uint16_t keycode) {
+ if ((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) {
+ keycode = keycode & 0xFF;
+ }
+
+ for (uint8_t i = KEYLOG_LEN - 1; i > 0; i--) {
+ keylog_str[i] = keylog_str[i - 1];
+ }
+ if (keycode < 60) {
+ keylog_str[0] = code_to_name[keycode];
+ }
+ keylog_str[KEYLOG_LEN - 1] = 0;
+
+ log_timer = timer_read();
+}
+
+void update_log(void) {
+ if (timer_elapsed(log_timer) > 750) {
+ add_keylog(0);
+ }
+}
+
+void render_keylogger_status(void) {
+ oled_write_P(PSTR("KLogr"), false);
+ oled_write(keylog_str, false);
+}
+
+void render_default_layer_state(void) {
+ oled_write_P(PSTR("Layer"), false);
+ oled_write_P(PSTR(" "), false);
+ switch (get_highest_layer(layer_state)) {
+ case _BEPO:
+ oled_write_P(PSTR("BEPO"), false);
+ break;
+ case _LOWER:
+ oled_write_ln_P(PSTR("LOW"), false);
+ break;
+ case _RAISE:
+ oled_write_P(PSTR("HIGH"), false);
+ break;
+ case _ADJUST:
+ oled_write_ln_P(PSTR("ADJ"), false);
+ break;
+ default:
+ oled_write_ln_P(PSTR("Undefined"), false);
+ }
+}
+
+void render_keylock_status(led_t led_state) {
+ oled_write_ln_P(PSTR("Lock"), false);
+ oled_write_P(PSTR(" "), false);
+ oled_write_P(PSTR("N"), led_state.num_lock);
+ oled_write_P(PSTR("C"), led_state.caps_lock);
+ oled_write_ln_P(PSTR("S"), led_state.scroll_lock);
+}
+
+void render_mod_status(uint8_t modifiers) {
+ oled_write_ln_P(PSTR("Mods"), false);
+ oled_write_P(PSTR(" "), false);
+ oled_write_P(PSTR("S"), (modifiers & MOD_MASK_SHIFT));
+ oled_write_P(PSTR("C"), (modifiers & MOD_MASK_CTRL));
+ oled_write_P(PSTR("A"), (modifiers & MOD_MASK_ALT));
+ oled_write_P(PSTR("G"), (modifiers & MOD_MASK_GUI));
+}
+
+void render_status_main(void) {
+ // Show keyboard layout
+ render_default_layer_state();
+ // Add a empty line
+ oled_write_P(PSTR("-----"), false);
+ // Show host keyboard led status
+ render_keylock_status(host_keyboard_led_state());
+ // Add a empty line
+ oled_write_P(PSTR("-----"), false);
+ // Show modifier status
+ render_mod_status(get_mods());
+ // Add a empty line
+ oled_write_P(PSTR("-----"), false);
+ render_keylogger_status();
+}
+
+bool oled_task_user(void) {
+ update_log();
+ if (is_keyboard_master()) {
+ render_status_main(); // Renders the current keyboard state (layer, lock, caps, scroll, etc)
+ } else {
+ render_lily58_logo();
+ }
+ return false;
+}
+
+bool process_record_user(uint16_t keycode, keyrecord_t *record) {
+ if (record->event.pressed) {
+ add_keylog(keycode);
+ }
+ //return true;
+
+//intercepting hold/tap to change hold function
+ switch (keycode) {
+ case MT(KC_CAPS, KC_ESC):
+ if (!record->tap.count && record->event.pressed) {
+ tap_code(KC_CAPS); // Intercept hold function to send Caps Lock
+ return false;
+ }
+ return true; // Return true for normal processing of tap keycode
+ case MT(BP_CCED, BP_C):
+ if (!record->tap.count && record->event.pressed) {
+ tap_code(BP_CCED); // Intercept hold function to send ç
+ return false;
+ }
+ return true; // Return true for normal processing of tap keycode
+ }
+ return true;
+}
+#endif // OLED_ENABLE
+
+
+// Rotary encoder related code
+#ifdef ENCODER_ENABLE
+bool encoder_update_user(uint8_t index, bool clockwise) {
+ if (index == 0) { // Encoder on master side
+ if(IS_LAYER_ON(_RAISE)) { // on Raise layer
+ // Cursor control
+ if (clockwise) {
+ tap_code(KC_MNXT);
+ } else {
+ tap_code(KC_MPRV);
+ }
+ }
+ else {
+ if (clockwise) {
+ tap_code(KC_VOLD);
+ } else {
+ tap_code(KC_VOLU);
+ }
+ }
+ }
+ else if (index == 1) { // Encoder on slave side
+ if(IS_LAYER_ON(_LOWER)) { // on Lower layer
+ //
+ if (clockwise) {
+ tap_code(KC_RIGHT);
+ } else {
+ tap_code(KC_LEFT);
+ }
+ }
+ else {
+ if (clockwise) {
+ tap_code(KC_DOWN);
+ } else {
+ tap_code(KC_UP);
+ }
+ }
+ }
+ return false;
+}
+#endif
+
+//layer led modification
+// Light LEDs 6 to 9 and 12 to 15 red when caps lock is active. Hard to ignore!
+const rgblight_segment_t PROGMEM my_capslock_layer[] = RGBLIGHT_LAYER_SEGMENTS(
+ {0, 6, HSV_RED}, // Light 6 LEDs, starting with LED 0
+ {35, 6, HSV_RED} // Light 6 LEDs, starting with LED 35
+);
+// Now define the array of layers. Later layers take precedence
+const rgblight_segment_t* const PROGMEM my_rgb_layers[] = RGBLIGHT_LAYERS_LIST(
+ my_capslock_layer
+);
+void keyboard_post_init_user(void) {
+ // Enable the LED layers
+ rgblight_layers = my_rgb_layers;
+}
+bool led_update_user(led_t led_state) {
+ rgblight_set_layer_state(0, led_state.caps_lock);
+ return true;
+}