diff options
author | rupa <rupa@lrrr.us> | 2020-08-20 20:07:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-20 17:07:09 -0700 |
commit | dd763f2988f0804fc7a0ff03de5c2a1e5a29e450 (patch) | |
tree | 3cf79015d574a866ca0dcca86c15c79cd5abca80 /users/rupa | |
parent | 83c7c66e8caab77bfb97c937c371ceb165c58102 (diff) | |
download | qmk_firmware-dd763f2988f0804fc7a0ff03de5c2a1e5a29e450.tar.gz qmk_firmware-dd763f2988f0804fc7a0ff03de5c2a1e5a29e450.zip |
[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 <drashna@live.com>
* add call to process_record_keymap, per review
* fall through to process_record_keymap
* license headers
Co-authored-by: Drashna Jaelre <drashna@live.com>
Diffstat (limited to 'users/rupa')
-rw-r--r-- | users/rupa/config.h | 8 | ||||
-rwxr-xr-x | users/rupa/process_records.c | 72 | ||||
-rwxr-xr-x | users/rupa/process_records.h | 21 | ||||
-rw-r--r-- | users/rupa/rules.mk | 3 | ||||
-rwxr-xr-x | users/rupa/rupa.c | 49 | ||||
-rwxr-xr-x | users/rupa/rupa.h | 54 | ||||
-rwxr-xr-x | users/rupa/unicode.c | 42 | ||||
-rwxr-xr-x | users/rupa/unicode.h | 43 |
8 files changed, 292 insertions, 0 deletions
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@lrrr.us> @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 <http://www.gnu.org/licenses/>. +*/ + +#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@lrrr.us> @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 <http://www.gnu.org/licenses/>. +*/ + +#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@lrrr.us> @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 <http://www.gnu.org/licenses/>. +*/ + +#include <print.h> +#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@lrrr.us> @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 <http://www.gnu.org/licenses/>. +*/ + +#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@lrrr.us> @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 <http://www.gnu.org/licenses/>. +*/ + +#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@lrrr.us> @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 <http://www.gnu.org/licenses/>. +*/ + +#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 |