[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>
This commit is contained in:
parent
83c7c66e8c
commit
dd763f2988
12 changed files with 372 additions and 0 deletions
8
users/rupa/config.h
Normal file
8
users/rupa/config.h
Normal file
|
@ -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
|
72
users/rupa/process_records.c
Executable file
72
users/rupa/process_records.c
Executable file
|
@ -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);
|
||||
}
|
21
users/rupa/process_records.h
Executable file
21
users/rupa/process_records.h
Executable file
|
@ -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);
|
3
users/rupa/rules.mk
Normal file
3
users/rupa/rules.mk
Normal file
|
@ -0,0 +1,3 @@
|
|||
SRC += rupa.c \
|
||||
process_records.c \
|
||||
unicode.c
|
49
users/rupa/rupa.c
Executable file
49
users/rupa/rupa.c
Executable file
|
@ -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;
|
||||
}
|
54
users/rupa/rupa.h
Executable file
54
users/rupa/rupa.h
Executable file
|
@ -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)
|
42
users/rupa/unicode.c
Executable file
42
users/rupa/unicode.c
Executable file
|
@ -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
|
43
users/rupa/unicode.h
Executable file
43
users/rupa/unicode.h
Executable file
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue