From 40badc4413d97226398302fb7a84c83c5c4f03a8 Mon Sep 17 00:00:00 2001 From: Sergi Meseguer Date: Sat, 16 Oct 2021 04:02:04 +0200 Subject: [Keymap] zigotica userspace (#14670) Co-authored-by: Drashna Jaelre Co-authored-by: Ryan --- keyboards/z12/keymaps/zigotica/config.h | 30 ++++++++ keyboards/z12/keymaps/zigotica/encoder.c | 114 ++++++++++++++++++++++++++++ keyboards/z12/keymaps/zigotica/encoder.h | 18 +++++ keyboards/z12/keymaps/zigotica/keymap.c | 126 +++++++++++++++++++++++++++++++ keyboards/z12/keymaps/zigotica/oled.c | 43 +++++++++++ keyboards/z12/keymaps/zigotica/oled.h | 18 +++++ keyboards/z12/keymaps/zigotica/rules.mk | 4 + 7 files changed, 353 insertions(+) create mode 100644 keyboards/z12/keymaps/zigotica/config.h create mode 100644 keyboards/z12/keymaps/zigotica/encoder.c create mode 100644 keyboards/z12/keymaps/zigotica/encoder.h create mode 100644 keyboards/z12/keymaps/zigotica/keymap.c create mode 100644 keyboards/z12/keymaps/zigotica/oled.c create mode 100644 keyboards/z12/keymaps/zigotica/oled.h create mode 100644 keyboards/z12/keymaps/zigotica/rules.mk (limited to 'keyboards/z12/keymaps/zigotica') diff --git a/keyboards/z12/keymaps/zigotica/config.h b/keyboards/z12/keymaps/zigotica/config.h new file mode 100644 index 0000000000..fbab76d5f0 --- /dev/null +++ b/keyboards/z12/keymaps/zigotica/config.h @@ -0,0 +1,30 @@ +/* Copyright 2020 Sergi Meseguer + +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 . +*/ + +#pragma once + +#include "config_common.h" + +#ifdef OLED_ENABLE + #define OLED_DISPLAY_128X32 +#endif + +// EC11 encoders' resolution. +// Reduce the value to 2 if you feel missing values: +#define ENCODER_RESOLUTION 4 + +// Allows correct registered values by rotary encoder: +#define TAP_CODE_DELAY 10 diff --git a/keyboards/z12/keymaps/zigotica/encoder.c b/keyboards/z12/keymaps/zigotica/encoder.c new file mode 100644 index 0000000000..49a3d859b6 --- /dev/null +++ b/keyboards/z12/keymaps/zigotica/encoder.c @@ -0,0 +1,114 @@ +/* Copyright 2020 Sergi Meseguer + +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 . +*/ + +#include "zigotica.h" + +bool encoder_update_user(uint8_t index, bool clockwise) { + switch(get_highest_layer(layer_state)){ + case _VIM: + if (index == 0) { // LEFT + // Cycle through buffers + if (clockwise) { + register_code(KC_ESC); + SEND_STRING(":bprevious"); + register_code(KC_ENT); + unregister_code(KC_ESC); + unregister_code(KC_ENT); + } else { + register_code(KC_ESC); + SEND_STRING(":bnext"); + register_code(KC_ENT); + unregister_code(KC_ESC); + unregister_code(KC_ENT); + } + } else { // RIGHT + // Scroll + if (clockwise) { + tap_code(KC_PGDN); + } else { + tap_code(KC_PGUP); + } + } + break; + case _BROWSER: + if (index == 0) { // LEFT + // Cycle through Tabs + if (clockwise) { + tap_code16(C(KC_TAB)); + /* register_code16(G(KC_RCBR)); */ + /* unregister_code16(G(KC_RCBR)); */ + } else { + tap_code16(S(C(KC_TAB))); + /* register_code16(G(KC_LCBR)); */ + /* unregister_code16(G(KC_LCBR)); */ + } + } else { // RIGHT + // Scroll up/down + if (clockwise) { + register_code(KC_WH_U); + unregister_code(KC_WH_U); + } else { + register_code(KC_WH_D); + unregister_code(KC_WH_D); + } + } + break; + case _FIGMA: + if (index == 0) { // LEFT + // Volume control. + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } else { // RIGHT + // Zoom in/out + if (clockwise) { + register_code(KC_LGUI); + register_code(KC_WH_D); + unregister_code(KC_WH_D); + unregister_code(KC_LGUI); + } else { + register_code(KC_LGUI); + register_code(KC_WH_U); + unregister_code(KC_WH_U); + unregister_code(KC_LGUI); + } + } + break; + case _TERMINAL: + default: + if (index == 0) { // LEFT + // Volume control. + if (clockwise) { + tap_code(KC_VOLU); + } else { + tap_code(KC_VOLD); + } + } else { // RIGHT + // Scroll + if (clockwise) { + tap_code(KC_PGDN); + } else { + tap_code(KC_PGUP); + } + } + break; + } + return false; +} + + diff --git a/keyboards/z12/keymaps/zigotica/encoder.h b/keyboards/z12/keymaps/zigotica/encoder.h new file mode 100644 index 0000000000..2422c68f28 --- /dev/null +++ b/keyboards/z12/keymaps/zigotica/encoder.h @@ -0,0 +1,18 @@ +/* Copyright 2020 Sergi Meseguer + +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 . +*/ + +#pragma once +#include "zigotica.h" diff --git a/keyboards/z12/keymaps/zigotica/keymap.c b/keyboards/z12/keymaps/zigotica/keymap.c new file mode 100644 index 0000000000..7e969de96e --- /dev/null +++ b/keyboards/z12/keymaps/zigotica/keymap.c @@ -0,0 +1,126 @@ +/* Copyright 2020 + Sergi Meseguer + +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 . +*/ + +#include "zigotica.h" + +// Custom Keycodes +#define MODE_1 TO(_TERMINAL) +#define MODE_2 TO(_FIGMA) +#define MODE_3 TO(_BROWSER) +#define MODE_4 TO(_VIM) + +enum custom_keycodes { + VIM_SIP = SAFE_RANGE +}; + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case VIM_SIP: + if (record->event.pressed) { + register_code(KC_ESC); + SEND_STRING(":Ag "); + } else { + // released + unregister_code(KC_ESC); + } + break; + } + return true; +}; + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +/* + * TERMINAL Layer + * + * ,-----------------------------. + * | | TERM | FIGM | | + * |-------+------+------+-------| + * | VOL | BROW | VIM | SCROLL| + * |-------+------+------+-------| + * |-------+-------+-------| + * | MEDIA | o | o | + * |-------+-------+-------| + * | o | o | o | + * |-------+-------+-------| + */ + [_TERMINAL] = LAYOUT( + MODE_1, MODE_2, + ZK_MEDIA, MODE_3, MODE_4, _______, + _______, _______, _______, + _______, _______, _______ + ), +/* + * VIM Layer + * + * ,-----------------------------. + * | | TERM | FIGM | | + * |-------+------+------+-------| + * |BUFFER | BROW | VIM | SCROLL| + * |-------+------+------+-------| + * |-------+-------+-------| + * |SEARCH | o | o | + * |-------+-------+-------| + * | o | o | o | + * |-------+-------+-------| + */ + [_VIM] = LAYOUT( + _______, _______, + _______, _______, _______, _______, + VIM_SIP, _______, _______, + _______, _______, _______ + ), +/* + * FIGMA Layer + * + * ,-----------------------------. + * | | TERM | FIGM | | + * |-------+------+------+-------| + * | VOL | BROW | VIM | ZOOM | + * |-------+------+------+-------| + * |-------+-------+-------| + * | ZOOM | GRIDS | FULL | + * |-------+-------+-------| + * | o | o | o | + * |-------+-------+-------| + */ + [_FIGMA] = LAYOUT( + _______, _______, + _______, _______, _______, _______, + LSFT(KC_1), LCTL(KC_G), LGUI(KC_BSLS), + _______, _______, _______ + ), +/* + * BROWSER Layer + * + * ,-----------------------------. + * | | TERM | FIGM | | + * |-------+------+------+-------| + * | TABS | BROW | VIM | SCROLL| + * |-------+------+------+-------| + * |-------+-------+-------| + * |SEARCH | BOOKM | DEVTL | + * |-------+-------+-------| + * | o | o | o | + * |-------+-------+-------| + */ + [_BROWSER] = LAYOUT( + _______, _______, + _______, _______, _______, _______, + G(KC_F), G(KC_D), G(A(KC_I)), + _______, _______, _______ + ), +}; diff --git a/keyboards/z12/keymaps/zigotica/oled.c b/keyboards/z12/keymaps/zigotica/oled.c new file mode 100644 index 0000000000..4b428a42b1 --- /dev/null +++ b/keyboards/z12/keymaps/zigotica/oled.c @@ -0,0 +1,43 @@ +/* Copyright 2020 Sergi Meseguer + +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 . +*/ + +#include "zigotica.h" + +static void render_status(void) { + oled_write_P(PSTR("z12 v1.0\n"), false); + oled_write_P(PSTR("Layer: "), false); + switch (get_highest_layer(layer_state)) { + case _VIM: + oled_write_P(PSTR("VIM\n\nBUFFER SCROLL"), false); + break; + case _FIGMA: + oled_write_P(PSTR("FIGMA\n\nVOLUME ZOOM"), false); + break; + case _BROWSER: + oled_write_P(PSTR("BROWSER\n\nTABS SCROLL"), false); + break; + case _TERMINAL: + oled_write_P(PSTR("TERMINAL\n\nVOLUME SCROLL"), false); + break; + default: + oled_write_P(PSTR("Undef\n"), false); + } +} + +void oled_task_user(void) { + render_status(); +} + diff --git a/keyboards/z12/keymaps/zigotica/oled.h b/keyboards/z12/keymaps/zigotica/oled.h new file mode 100644 index 0000000000..2422c68f28 --- /dev/null +++ b/keyboards/z12/keymaps/zigotica/oled.h @@ -0,0 +1,18 @@ +/* Copyright 2020 Sergi Meseguer + +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 . +*/ + +#pragma once +#include "zigotica.h" diff --git a/keyboards/z12/keymaps/zigotica/rules.mk b/keyboards/z12/keymaps/zigotica/rules.mk new file mode 100644 index 0000000000..02e37aa80b --- /dev/null +++ b/keyboards/z12/keymaps/zigotica/rules.mk @@ -0,0 +1,4 @@ +OLED_ENABLE = yes # Enables the use of OLED displays +RAW_ENABLE = yes +TAP_DANCE_ENABLE = yes +MOUSEKEY_ENABLE = yes -- cgit v1.2.3