From dd763f2988f0804fc7a0ff03de5c2a1e5a29e450 Mon Sep 17 00:00:00 2001 From: rupa Date: Thu, 20 Aug 2020 20:07:09 -0400 Subject: [PATCH] [Keymap] userspace and keymap for rupa (#9786) * first iteration of my keymap * * move to userspace * "script" modes * keymap bling * OM and RUPA keys and tryin to micro-optimize in process_records.c * woops swap shifted rupas forgot to add codepoint for OM * Apply suggestions from code review Co-authored-by: Drashna Jaelre * add call to process_record_keymap, per review * fall through to process_record_keymap * license headers Co-authored-by: Drashna Jaelre --- keyboards/tada68/keymaps/rupa/config.h | 10 ++++ keyboards/tada68/keymaps/rupa/keymap.c | 45 ++++++++++++++++ keyboards/tada68/keymaps/rupa/readme.md | 21 ++++++++ keyboards/tada68/keymaps/rupa/rules.mk | 4 ++ users/rupa/config.h | 8 +++ users/rupa/process_records.c | 72 +++++++++++++++++++++++++ users/rupa/process_records.h | 21 ++++++++ users/rupa/rules.mk | 3 ++ users/rupa/rupa.c | 49 +++++++++++++++++ users/rupa/rupa.h | 54 +++++++++++++++++++ users/rupa/unicode.c | 42 +++++++++++++++ users/rupa/unicode.h | 43 +++++++++++++++ 12 files changed, 372 insertions(+) create mode 100644 keyboards/tada68/keymaps/rupa/config.h create mode 100755 keyboards/tada68/keymaps/rupa/keymap.c create mode 100755 keyboards/tada68/keymaps/rupa/readme.md create mode 100644 keyboards/tada68/keymaps/rupa/rules.mk create mode 100644 users/rupa/config.h create mode 100755 users/rupa/process_records.c create mode 100755 users/rupa/process_records.h create mode 100644 users/rupa/rules.mk create mode 100755 users/rupa/rupa.c create mode 100755 users/rupa/rupa.h create mode 100755 users/rupa/unicode.c create mode 100755 users/rupa/unicode.h diff --git a/keyboards/tada68/keymaps/rupa/config.h b/keyboards/tada68/keymaps/rupa/config.h new file mode 100644 index 0000000000..ddbf0ab667 --- /dev/null +++ b/keyboards/tada68/keymaps/rupa/config.h @@ -0,0 +1,10 @@ +#pragma once + +#define GRAVE_ESC_ALT_OVERRIDE + +/* disable features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +#define NO_ACTION_MACRO +#define NO_ACTION_FUNCTION diff --git a/keyboards/tada68/keymaps/rupa/keymap.c b/keyboards/tada68/keymaps/rupa/keymap.c new file mode 100755 index 0000000000..3a8a550561 --- /dev/null +++ b/keyboards/tada68/keymaps/rupa/keymap.c @@ -0,0 +1,45 @@ +#include "rupa.h" + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + /* Keymap _QWERTY: (Base Layer) Default Layer + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬───┐ + * │Esc│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ Backsp│~ `│ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┤ + * │ Tab │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ [ │ ] │ \ │Del│ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤ + * │ Fn │ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ Enter │PgU│ + * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤ + * │ Shift │ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │ Shift│ ↑ │PgD│ + * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴──┬┴──┬┴──┬───┼───┼───┤ + * │Ctrl│Alt │Gui │ Space │Fn │Alt│Ctl│ ← │ ↓ │ → │ + * └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┴───┘ + */ + [_QWERTY] = LAYOUT_65_ansi( + KC_GESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_GRV, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_DEL, + RAISE, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN, + KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, RAISE, KC_RALT, KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT + ), + + /* Keymap _RAISE: Function Layer + * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬───┐ + * │LOD│F1 │F2 │F3 │F4 │F5 │F6 │F7 │F8 │F9 │F10│F11│F12│ Del │Hme│ + * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┤ + * │ │VSN│U_s│U_f│U_m│ │ │uni│ │ ॐ │ │♩ ♪│♫ ♬│★ ☆ │Ins│ + * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤ + * │ │ │ │ │ │ │ │ │ │ │ │ │ ✓ │End│ + * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤ + * │ RShift │ ⸮ │Rup│Brt│Bls│Blt│ │Mut│V- │V+ │‽ ☭│ McL│M↑ │McR│ + * ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴──┬┴──┬┴──┬───┼───┼───┤ + * │RCtl│RAlt│RGui│ │ │ │CAP│M← │M↓ │M→ │ + * └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┴───┘ + */ + [_RAISE] = LAYOUT_65_ansi( + LOD, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_HOME, + _______, VRSN, U_SCRPT, U_FRACT, U_MONOS, _______, _______, UC_MOD, _______, X(OM), _______, XP(M4,M8), XP(M8B,M16), XP(STB, STW), KC_INS, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, X(CHEK), KC_END, + OS_RSFT, X(IRNY), RUPA, BL_BRTG, BL_STEP, BL_TOGG, _______, KC_MUTE, KC_VOLD, KC_VOLU, XP(IBNG,HAS), KC_BTN1, KC_MS_U, KC_BTN2, + OS_RCTL, OS_RALT, OS_RGUI, _______, _______, _______, KC_CAPS, KC_MS_L, KC_MS_D, KC_MS_R + ), +}; diff --git a/keyboards/tada68/keymaps/rupa/readme.md b/keyboards/tada68/keymaps/rupa/readme.md new file mode 100755 index 0000000000..77629131a0 --- /dev/null +++ b/keyboards/tada68/keymaps/rupa/readme.md @@ -0,0 +1,21 @@ +# rupa's TADA68 layout + +i've swapped the lufa-ms bootloader for caterina + +most everything is in my userspace dir + +console mode is on, and there's barely any room left! + +* win/alt -> alt/cmd +* alt/fn -> fn/alt +* grave escape, with alt override +* caps is another fn key, CAPS on fn-rctl + +fn layer: + * no wasd arrows + * rotate mute/vol + * backlight -> breathing, step, toggle + * swap home and ins + * unicode chars sprinkled around + * script mode! + * (one-shot) right versions of shift/ctl/alt/gui (not working quite right yet) diff --git a/keyboards/tada68/keymaps/rupa/rules.mk b/keyboards/tada68/keymaps/rupa/rules.mk new file mode 100644 index 0000000000..df6f5674b5 --- /dev/null +++ b/keyboards/tada68/keymaps/rupa/rules.mk @@ -0,0 +1,4 @@ +BOOTLOADER = caterina + +UNICODEMAP_ENABLE = yes +CONSOLE_ENABLE = yes diff --git a/users/rupa/config.h b/users/rupa/config.h new file mode 100644 index 0000000000..9024052042 --- /dev/null +++ b/users/rupa/config.h @@ -0,0 +1,8 @@ +#pragma once + +#define UNICODE_SELECTED_MODES UC_MAC, UC_LNX + +#define ONESHOT_TAP_TOGGLE 5 +#define ONESHOT_TIMEOUT 5000 + +#define TAP_CODE_DELAY 5 //DEFAULT: 100 diff --git a/users/rupa/process_records.c b/users/rupa/process_records.c new file mode 100755 index 0000000000..2d72310100 --- /dev/null +++ b/users/rupa/process_records.c @@ -0,0 +1,72 @@ +/* +Copyright 2020 rupa @rupa + +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 "rupa.h" + +font_t *translator = NULL; + +__attribute__((weak)) +bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { + return true; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + bool is_shifted = get_mods()&MOD_MASK_SHIFT; + bool is_pressed = record->event.pressed; + + switch(keycode) { + case VRSN: + if (is_pressed) { + send_string_with_delay_P(PSTR( + "# " QMK_KEYBOARD "/" QMK_KEYMAP ":" QMK_VERSION " " QMK_BUILDDATE "\n" + ), TAP_CODE_DELAY); + } + return false; + + case LOD: + case RUPA: + if (is_pressed) { + if (keycode == LOD) { + send_unicode_string((is_shifted ? "¯\\_(ツ)_/¯" : "ಠ_ಠ")); + } else if (keycode == RUPA) { + send_unicode_string((is_shifted ? "Śrīrūpa" : "rūpa")); + } + } + return false; + + // script modes + case U_FRACT: + case U_MONOS: + case U_SCRPT: + if (is_pressed) { + if (keycode == U_SCRPT) { + translator = (translator == &script_bold ? NULL : &script_bold); + } else if (keycode == U_FRACT) { + translator = (translator == &fraktu_bold ? NULL : &fraktu_bold); + } else if (keycode == U_MONOS) { + translator = (translator == &monosp_bold ? NULL : &monosp_bold); + } + } + return true; + + default: + if (is_pressed && translator != NULL) { + return script_mode_translate(translator, is_shifted, keycode); + } + } + return process_record_keymap(keycode, record); +} diff --git a/users/rupa/process_records.h b/users/rupa/process_records.h new file mode 100755 index 0000000000..7c7fe491be --- /dev/null +++ b/users/rupa/process_records.h @@ -0,0 +1,21 @@ +/* +Copyright 2020 rupa @rupa + +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 "rupa.h" + +bool process_record_keymap(uint16_t keycode, keyrecord_t *record); diff --git a/users/rupa/rules.mk b/users/rupa/rules.mk new file mode 100644 index 0000000000..c4f147d913 --- /dev/null +++ b/users/rupa/rules.mk @@ -0,0 +1,3 @@ +SRC += rupa.c \ + process_records.c \ + unicode.c diff --git a/users/rupa/rupa.c b/users/rupa/rupa.c new file mode 100755 index 0000000000..60fec3caf0 --- /dev/null +++ b/users/rupa/rupa.c @@ -0,0 +1,49 @@ +/* +Copyright 2020 rupa @rupa + +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 +#include "rupa.h" + +// https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols +font_t script_bold = {0x1D4D0, 0x1D4EA, 0x1D7CE}; // with bold numbers +font_t fraktu_bold = {0x1D56C, 0x1D586, 0x1D7D8}; // with doublestruck numbers +font_t monosp_bold = {0x1D670, 0x1D68A, 0x1D7F6}; + +// Maps A-Z, a-z, and 0-9 to other unicode ranges. We also map space to EN +// SPACE for some reason :) +uint32_t map_alnum(font_t *f, bool is_shifted, uint32_t keycode) { + switch (keycode) { + case KC_SPACE: + return (is_shifted ? 0 : 0x2002); // EN SPACE + case KC_0: + return (is_shifted ? 0 : f->zero_glyph); + case KC_A ... KC_Z: + return (is_shifted ? f->upper_alpha : f->lower_alpha) + keycode - KC_A; + case KC_1 ... KC_9: + return (is_shifted ? 0 : f->zero_glyph + keycode - KC_1 + 1); + default: + return 0; + } +} + +bool script_mode_translate(font_t *translator, bool is_shifted, uint32_t keycode) { + uint32_t translated = map_alnum(translator, is_shifted, keycode); + if (translated == 0) return true; + dprintf("script_mode_translate: %u => %d\n", keycode, translated); + register_unicode(translated); + return false; +} diff --git a/users/rupa/rupa.h b/users/rupa/rupa.h new file mode 100755 index 0000000000..9be3a2d62f --- /dev/null +++ b/users/rupa/rupa.h @@ -0,0 +1,54 @@ +/* +Copyright 2020 rupa @rupa + +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 QMK_KEYBOARD_H +#include "version.h" +#include "process_records.h" +#include "unicode.h" + +enum userspace_layers { + _QWERTY = 0, + _RAISE, +}; + +enum userspace_custom_keycodes { + VRSN = SAFE_RANGE, + LOD, + RUPA, + U_FRACT, + U_MONOS, + U_SCRPT, +}; + +typedef struct font_t { + uint32_t upper_alpha; + uint32_t lower_alpha; + uint32_t zero_glyph; +} font_t; + +font_t fraktu_bold; +font_t monosp_bold; +font_t script_bold; + +bool script_mode_translate(font_t *translator, bool is_shifted, uint32_t keycode); + +#define RAISE MO(_RAISE) +#define OS_RGUI OSM(MOD_RGUI) +#define OS_RALT OSM(MOD_RALT) +#define OS_RCTL OSM(MOD_RCTL) +#define OS_RSFT OSM(MOD_RSFT) diff --git a/users/rupa/unicode.c b/users/rupa/unicode.c new file mode 100755 index 0000000000..89a0d47665 --- /dev/null +++ b/users/rupa/unicode.c @@ -0,0 +1,42 @@ +/* +Copyright 2020 rupa @rupa + +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 "unicode.h" + +#if defined(UNICODEMAP_ENABLE) +const uint32_t PROGMEM unicode_map[] = { + [CHEK] = 0x2713, // ✓ + /* + [DI1] = 0x2680, // ⚀ + [DI2] = 0x2681, // ⚁ + [DI3] = 0x2682, // ⚂ + [DI4] = 0x2683, // ⚃ + [DI5] = 0x2684, // ⚄ + [DI6] = 0x2685, // ⚅ + */ + [HAS] = 0x262D, // ☭ + [IBNG] = 0x203D, // ‽ + [IRNY] = 0x2E2E, // ⸮ + [M4] = 0x2669, // ♩ + [M8] = 0x266A, // ♪ + [M8B] = 0x266B, // ♫ + [M16] = 0x266C, // ♬ + [OM] = 0x0950, // ॐ + [STB] = 0x2605, // ★ + [STW] = 0x2606, // ☆ +}; +#endif diff --git a/users/rupa/unicode.h b/users/rupa/unicode.h new file mode 100755 index 0000000000..0c067bd913 --- /dev/null +++ b/users/rupa/unicode.h @@ -0,0 +1,43 @@ +/* +Copyright 2020 rupa @rupa + +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 "rupa.h" + +#if defined(UNICODEMAP_ENABLE) +enum unicode_names { + CHEK, + /* + DI1, // ⚀ + DI2, // ⚁ + DI3, // ⚂ + DI4, // ⚃ + DI5, // ⚄ + DI6, // ⚅ + */ + HAS, // ☭ + IBNG, // ‽ + IRNY, // ⸮ + M4, // ♩ + M8, // ♪ + M8B, // ♫ + M16, // ♬ + OM, // ॐ + STB, // ★ + STW, // ☆ +}; +#endif