Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

userspace and keymap for rupa #9786

Merged
merged 8 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions keyboards/tada68/keymaps/rupa/config.h
Original file line number Diff line number Diff line change
@@ -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
45 changes: 45 additions & 0 deletions keyboards/tada68/keymaps/rupa/keymap.c
Original file line number Diff line number Diff line change
@@ -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
),
};
21 changes: 21 additions & 0 deletions keyboards/tada68/keymaps/rupa/readme.md
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 4 additions & 0 deletions keyboards/tada68/keymaps/rupa/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
BOOTLOADER = caterina

UNICODEMAP_ENABLE = yes
CONSOLE_ENABLE = yes
8 changes: 8 additions & 0 deletions users/rupa/config.h
Original file line number Diff line number Diff line change
@@ -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
56 changes: 56 additions & 0 deletions users/rupa/process_records.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#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:
rupa marked this conversation as resolved.
Show resolved Hide resolved
if (is_pressed && translator != NULL) {
return script_mode_translate(translator, is_shifted, keycode);
}
return true;
}
return process_record_keymap(keycode, record);
drashna marked this conversation as resolved.
Show resolved Hide resolved
}
4 changes: 4 additions & 0 deletions users/rupa/process_records.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#pragma once
#include "rupa.h"

bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
3 changes: 3 additions & 0 deletions users/rupa/rules.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SRC += rupa.c \
process_records.c \
unicode.c
32 changes: 32 additions & 0 deletions users/rupa/rupa.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#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;
}
37 changes: 37 additions & 0 deletions users/rupa/rupa.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#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)
25 changes: 25 additions & 0 deletions users/rupa/unicode.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#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
26 changes: 26 additions & 0 deletions users/rupa/unicode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#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