[Keymap] Unicode and cursor sync - drashna keymap (#15328)

master
Drashna Jaelre 2021-11-28 23:41:59 -08:00 committed by GitHub
parent 4ee33f1ffd
commit 5b5b36421a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 459 additions and 98 deletions

View File

@ -51,3 +51,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define NO_ACTION_FUNCTION
#define OLED_DISPLAY_128X64
#define POINTING_DEVICE_TASK_THROTTLE
#define POINTING_DEVICE_RIGHT

View File

@ -6,7 +6,7 @@ BOOTLOADER = stm32-dfu
KEYBOARD_SHARED_EP = yes
CONSOLE_ENABLE = yes
MOUSE_SHARED_EP = no
MOUSE_SHARED_EP = yes
EEPROM_DRIVER = spi
WS2812_DRIVER = pwm

View File

@ -19,3 +19,4 @@
#define TRACKBALL_DPI_OPTIONS { 1200, 1800, 2600, 3400 }
#define DEBOUNCE 45
#define ENCODER_DEFAULT_POS 0x3

View File

@ -125,7 +125,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______, _______
),
[_ADJUST] = LAYOUT_5x6_right_wrapper(
KC_MAKE, ___________________BLANK___________________, _________________ADJUST_R1_________________, KC_RST,
KC_MAKE, KC_WIDE,KC_AUSSIE,KC_SCRIPT,KC_ZALGO,KC_NOMODE, KC_NOMODE,KC_BLOCKS,KC_REGIONAL,_______,_______, KC_RST,
VRSN, _________________ADJUST_L1_________________, _________________ADJUST_R1_________________, EEP_RST,
KEYLOCK, _________________ADJUST_L2_________________, _________________ADJUST_R2_________________, TG_MODS,
UC_MOD, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, KC_MPLY,
@ -407,9 +407,9 @@ void oled_driver_render_logo_left(void) {
render_kitty();
oled_set_cursor(6, 0);
oled_write_P(PSTR(" Tractyl "), true);
oled_write_P(PSTR(" Tractyl "), false);
oled_set_cursor(6, 1);
oled_write_P(PSTR(" Manuform "), true);
oled_write_P(PSTR(" Manuform "), false);
oled_set_cursor(6, 2);
# if defined(WPM_ENABLE)
render_wpm(1);

View File

@ -17,7 +17,7 @@ SWAP_HANDS_ENABLE = yes
POINTING_DEVICE_ENABLE = yes
POINTING_DEVICE_DRIVER = pmw3360
MOUSE_SHARED_EP = no
MOUSE_SHARED_EP = yes
SPLIT_KEYBOARD = yes

View File

@ -14,19 +14,29 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tractyl_manuform.h"
#include QMK_KEYBOARD_H
#include "pointing_device.h"
#include "transactions.h"
#include <string.h>
#ifdef MOUSEKEY_ENABLE
# include "mousekey.h"
#endif
// typedef struct {
// uint16_t device_cpi;
// } kb_config_data_t;
kb_config_data_t kb_config;
kb_mouse_report_t sync_mouse_report;
static report_mouse_t shared_mouse_report;
extern const pointing_device_driver_t pointing_device_driver;
void kb_pointer_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
if (target2initiator_buffer_size == sizeof(sync_mouse_report)) {
memcpy(target2initiator_buffer, &sync_mouse_report, sizeof(sync_mouse_report));
}
sync_mouse_report.x = 0;
sync_mouse_report.y = 0;
shared_mouse_report = pointing_device_driver.get_report(shared_mouse_report);
memcpy(target2initiator_buffer, &shared_mouse_report, sizeof(report_mouse_t));
shared_mouse_report.x = 0;
shared_mouse_report.y = 0;
shared_mouse_report.h = 0;
shared_mouse_report.v = 0;
}
void kb_config_sync_handler(uint8_t initiator2target_buffer_size, const void* initiator2target_buffer, uint8_t target2initiator_buffer_size, void* target2initiator_buffer) {
@ -38,12 +48,15 @@ void kb_config_sync_handler(uint8_t initiator2target_buffer_size, const void* in
// Check if the state values are different
if (cpi != kb_config.device_cpi) {
cpi = kb_config.device_cpi;
if (!is_keyboard_left()) {
pointing_device_set_cpi(cpi);
}
}
}
void keyboard_pre_init_sync(void) {
memset(&kb_config, 0, sizeof(kb_config));
memset(&sync_mouse_report, 0, sizeof(sync_mouse_report));
memset(&shared_mouse_report, 0, sizeof(shared_mouse_report));
}
void keyboard_post_init_sync(void) {
@ -84,3 +97,83 @@ void trackball_set_cpi(uint16_t cpi) {
pointing_device_set_cpi(cpi);
}
}
void pointing_device_task(void) {
if (!is_keyboard_master()) {
return;
}
#if defined(POINTING_DEVICE_TASK_THROTTLE)
static uint32_t last_exec = 0;
if (timer_elapsed32(last_exec) < 1) {
return;
}
last_exec = timer_read32();
#endif
report_mouse_t local_report = pointing_device_get_report();
// Gather report info
#ifdef POINTING_DEVICE_MOTION_PIN
if (!readPin(POINTING_DEVICE_MOTION_PIN))
#endif
#if defined(POINTING_DEVICE_COMBINED)
local_report = pointing_device_driver.get_report(local_report);
transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &shared_mouse_report);
local_report.x = local_report.x | shared_mouse_report.x;
local_report.y = local_report.y | shared_mouse_report.y;
local_report.h = local_report.h | shared_mouse_report.h;
local_report.v = local_report.v | shared_mouse_report.v;
#elif defined(POINTING_DEVICE_LEFT)
if (is_keyboard_left()) {
local_report = pointing_device_driver.get_report(local_report);
} else {
transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &local_report);
}
#elif defined(POINTING_DEVICE_RIGHT)
if (!is_keyboard_left()) {
local_report = pointing_device_driver.get_report(local_report);
} else {
transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(report_mouse_t), &local_report);
}
#else
# error "You need to define the side(s) the pointing device is on. POINTING_DEVICE_COMBINED / POINTING_DEVICE_LEFT / POINTING_DEVICE_RIGHT"
#endif
// Support rotation of the sensor data
#if defined(POINTING_DEVICE_ROTATION_90) || defined(POINTING_DEVICE_ROTATION_180) || defined(POINTING_DEVICE_ROTATION_270)
int8_t x = local_report.x, y = local_report.y;
# if defined(POINTING_DEVICE_ROTATION_90)
local_report.x = y;
local_report.y = -x;
# elif defined(POINTING_DEVICE_ROTATION_180)
local_report.x = -x;
local_report.y = -y;
# elif defined(POINTING_DEVICE_ROTATION_270)
local_report.x = -y;
local_report.y = x;
# else
# error "How the heck did you get here?!"
# endif
#endif
// Support Inverting the X and Y Axises
#if defined(POINTING_DEVICE_INVERT_X)
local_report.x = -local_report.x;
#endif
#if defined(POINTING_DEVICE_INVERT_Y)
local_report.y = -local_report.y;
#endif
// allow kb to intercept and modify report
local_report = pointing_device_task_kb(local_report);
// combine with mouse report to ensure that the combined is sent correctly
#ifdef MOUSEKEY_ENABLE
report_mouse_t mousekey_report = mousekey_get_report();
local_report.buttons = local_report.buttons | mousekey_report.buttons;
#endif
#if defined(POINTING_DEVICE_COMBINED)
local_report.buttons = local_report.buttons | shared_mouse_report.buttons;
#endif
pointing_device_set_report(local_report);
pointing_device_send();
}

View File

@ -99,20 +99,8 @@ void pointing_device_init_kb(void) {
}
report_mouse_t pointing_device_task_kb(report_mouse_t mouse_report) {
if (is_keyboard_left()) {
if (is_keyboard_master()) {
transaction_rpc_recv(RPC_ID_POINTER_STATE_SYNC, sizeof(sync_mouse_report), &sync_mouse_report);
mouse_report.x = sync_mouse_report.x;
mouse_report.y = sync_mouse_report.y;
pointing_device_task_user(mouse_report);
}
} else {
if (is_keyboard_master()) {
pointing_device_task_user(mouse_report);
} else {
sync_mouse_report.x = mouse_report.x;
sync_mouse_report.y = mouse_report.y;
}
mouse_report = pointing_device_task_user(mouse_report);
}
return mouse_report;
}

View File

@ -43,15 +43,6 @@ typedef struct {
uint16_t device_cpi;
} kb_config_data_t;
__attribute__((aligned(16))) typedef struct {
int8_t x;
int8_t y;
} kb_mouse_report_t;
extern kb_mouse_report_t sync_mouse_report;
void process_mouse(void);
void process_mouse_user(report_mouse_t* mouse_report, int8_t x, int8_t y);
void trackball_set_cpi(uint16_t cpi);
void matrix_init_sub_kb(void);
void matrix_scan_sub_kb(void);

View File

@ -16,10 +16,6 @@
#include "drashna.h"
#ifndef UNICODE_ENABLE
# define UC(x) KC_NO
#endif
enum more_custom_keycodes { KC_SWAP_NUM = NEW_SAFE_RANGE };
// clang-format off
@ -32,10 +28,10 @@ enum more_custom_keycodes { KC_SWAP_NUM = NEW_SAFE_RANGE };
) \
LAYOUT_moonlander_wrapper( \
KC_ESC, ________________NUMBER_LEFT________________, UC_FLIP, UC_TABL, ________________NUMBER_RIGHT_______________, KC_MINS, \
KC_TAB, K01, K02, K03, K04, K05, TG_DBLO,TG_DBLO, K06, K07, K08, K09, K0A, KC_BSLS, \
KC_C1R3, K11, K12, K13, K14, K15, TG_GAME,TG_GAME, K16, K17, K18, K19, K1A, RALT_T(K1B), \
KC_TAB, K01, K02, K03, K04, K05, TG_DBLO, TG_DBLO, K06, K07, K08, K09, K0A, KC_BSLS, \
KC_C1R3, K11, K12, K13, K14, K15, TG_GAME, TG_GAME, K16, K17, K18, K19, K1A, RALT_T(K1B), \
KC_MLSF, CTL_T(K21), K22, K23, K24, K25, K26, K27, K28, K29, RCTL_T(K2A),KC_MRSF, \
KC_GRV, OS_MEH, OS_HYPR, KC_LBRC, KC_RBRC, KC_NO, KC_DEL, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, UC(0x2E2E), \
KC_GRV, OS_MEH, OS_HYPR, KC_LBRC, KC_RBRC, UC_CLUE, KC_DEL, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, UC_IRNY, \
KC_SPC, BK_LWER, OS_LALT, OS_RGUI, DL_RAIS, KC_ENT \
)
@ -110,10 +106,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
),
[_ADJUST] = LAYOUT_moonlander_wrapper(
KC_MAKE, _________________FUNC_LEFT_________________, UC_MOD, KC_NUKE, _________________ADJUST_R1_________________, KC_RST,
KC_MAKE, KC_WIDE,KC_AUSSIE,KC_SCRIPT,KC_ZALGO,KC_NOMODE,_______, KC_NUKE,KC_NOMODE,KC_BLOCKS,KC_REGIONAL,_______,_______, KC_RST,
VRSN, _________________ADJUST_L1_________________, TG(_DIABLOII), _______, _________________ADJUST_R1_________________, EEP_RST,
_______, _________________ADJUST_L2_________________, _______, _______, _________________ADJUST_R2_________________, RGB_IDL,
KEYLOCK, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, TG_MODS,
KEYLOCK, _________________ADJUST_L2_________________, _______, _______, _________________ADJUST_R2_________________, RGB_IDL,
UC_MOD, _________________ADJUST_L3_________________, _________________ADJUST_R3_________________, TG_MODS,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PAUS,
_______, _______, _______, _______, _______, _______
),

View File

@ -23,7 +23,6 @@ ifeq ($(strip $(KEYBOARD)), crkbd/rev1)
OLED_ENABLE = yes
RGB_MATRIX_ENABLE = yes
HAPTIC_ENABLE = no
BOOTLOADER = qmk-dfu
endif
ifeq ($(strip $(CTPC)), yes)
@ -32,4 +31,7 @@ ifeq ($(strip $(CTPC)), yes)
SERIAL_DRIVER = usart
SWAP_HANDS_ENABLE = yes
WPM_ENABLE = yes
else
BOOTLOADER = qmk-hid
BOOTLOADER_SIZE = 512
endif

View File

@ -41,6 +41,15 @@
# endif
#endif
#if defined(WPM_ENABLE)
// # define WPM_LAUNCH_CONTROL
// # define WPM_ALLOW_COUNT_REGRESSOIN
// # define WPM_UNFILTERED
# define WPM_SAMPLE_SECONDS 6
# define WPM_SAMPLE_PERIODS 50
# define WPM_ESTIMATED_WORD_SIZE 6
#endif
#ifdef AUDIO_ENABLE
# define AUDIO_CLICKY
# define AUDIO_CLICKY_FREQ_RANDOMNESS 1.5f

View File

@ -15,6 +15,10 @@
*/
#include "drashna.h"
#ifdef CUSTOM_UNICODE_ENABLE
# include "process_unicode_common.h"
#endif
#include <string.h>
extern bool host_driver_disabled;
@ -59,7 +63,7 @@ void add_keylog(uint16_t keycode, keyrecord_t *record) {
return;
}
if (record->tap.count) {
keycode = keycode & 0xFF;
keycode &= 0xFF;
} else if (keycode > 0xFF) {
return;
}
@ -150,8 +154,10 @@ void render_keylock_status(uint8_t led_usb_state) {
oled_write_P(PSTR(OLED_RENDER_LOCK_NUML), led_usb_state & (1 << USB_LED_NUM_LOCK));
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_LOCK_CAPS), led_usb_state & (1 << USB_LED_CAPS_LOCK));
// oled_write_P(PSTR(" "), false);
// oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
#if defined(OLED_DISPLAY_128X64)
oled_write_P(PSTR(" "), false);
oled_write_P(PSTR(OLED_RENDER_LOCK_SCLK), led_usb_state & (1 << USB_LED_SCROLL_LOCK));
#endif
}
void render_matrix_scan_rate(void) {
@ -296,7 +302,7 @@ void render_user_status(void) {
oled_write_P(rgb_layer_status[userspace_config.rgb_layer_change], false);
static const char PROGMEM cat_mode[2][3] = {{0xF8, 0xF9, 0}, {0xF6, 0xF7, 0}};
oled_write_P(cat_mode[0], host_driver_disabled);
#if defined(UNICODE_ENABLE)
#if defined(CUSTOM_UNICODE_ENABLE)
static const char PROGMEM uc_mod_status[5][3] = {{0xEA, 0xEB, 0}, {0xEC, 0xED, 0}};
oled_write_P(uc_mod_status[get_unicode_input_mode() == UC_MAC], false);
#endif
@ -327,39 +333,28 @@ void oled_driver_render_logo(void) {
void render_wpm(uint8_t padding) {
#ifdef WPM_ENABLE
uint8_t n = get_current_wpm();
char wpm_counter[4];
wpm_counter[3] = '\0';
wpm_counter[2] = '0' + n % 10;
wpm_counter[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
wpm_counter[0] = n / 10 ? '0' + n / 10 : ' ';
oled_write_P(PSTR(OLED_RENDER_WPM_COUNTER), false);
if (padding) {
for (uint8_t n = padding; n > 0; n--) {
oled_write_P(PSTR(" "), false);
}
}
oled_write(wpm_counter, false);
oled_write(get_u8_str(get_current_wpm(), ' '), false);
#endif
}
#if defined(KEYBOARD_handwired_tractyl_manuform_5x6_right)
extern kb_config_data_t kb_config;
void render_pointing_dpi_status(uint8_t padding) {
char dpi_status[5];
uint16_t n = kb_config.device_cpi;
dpi_status[4] = '\0';
dpi_status[3] = '0' + n % 10;
dpi_status[2] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
dpi_status[1] = (n /= 10) % 10 ? '0' + (n) % 10 : (n / 10) % 10 ? '0' : ' ';
dpi_status[0] = n / 10 ? '0' + n / 10 : ' ';
oled_write_P(PSTR("DPI: "), false);
oled_write_P(PSTR("CPI:"), false);
if (padding) {
for (uint8_t n = padding; n > 0; n--) {
for (uint8_t n = padding - 1; n > 0; n--) {
oled_write_P(PSTR(" "), false);
}
}
oled_write(dpi_status, false);
oled_write(get_u16_str(kb_config.device_cpi, ' '), false);
}
#endif

View File

@ -39,6 +39,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *re
#endif
#ifdef RGBLIGHT_ENABLE
&& process_record_user_rgb_light(keycode, record)
#endif
#ifdef CUSTOM_UNICODE_ENABLE
&& process_record_unicode(keycode, record)
#endif
&& true)) {
return false;
@ -117,28 +120,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *re
}
}
break;
#ifdef UNICODE_ENABLE
case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻
if (record->event.pressed) {
send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
}
break;
case UC_TABL: // ┬─┬ノ( º _ ºノ)
if (record->event.pressed) {
send_unicode_string("┬─┬ノ( º _ ºノ)");
}
break;
case UC_SHRG: // ¯\_(ツ)_/¯
if (record->event.pressed) {
send_unicode_string("¯\\_(ツ)_/¯");
}
break;
case UC_DISA: // ಠ_ಠ
if (record->event.pressed) {
send_unicode_string("ಠ_ಠ");
}
break;
#endif
case KC_RGB_T: // This allows me to use underglow as layer indication, or as normal
#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
if (record->event.pressed) {

View File

@ -46,13 +46,25 @@ enum userspace_custom_keycodes {
UC_TABL, // ┬─┬ノ( º _ ºノ)
UC_SHRG, // ¯\_(ツ)_/¯
UC_DISA, // ಠ_ಠ
UC_IRNY,
UC_CLUE,
KEYLOCK, // Locks keyboard by unmounting driver
KC_NOMODE,
KC_WIDE,
KC_SCRIPT,
KC_BLOCKS,
KC_REGIONAL,
KC_AUSSIE,
KC_ZALGO,
NEW_SAFE_RANGE // use "NEWPLACEHOLDER for keymap specific codes
};
bool process_record_secrets(uint16_t keycode, keyrecord_t *record);
bool process_record_keymap(uint16_t keycode, keyrecord_t *record);
void post_process_record_keymap(uint16_t keycode, keyrecord_t *record);
#ifdef CUSTOM_UNICODE_ENABLE
bool process_record_unicode(uint16_t keycode, keyrecord_t *record);
#endif
#define LOWER MO(_LOWER)
#define RAISE MO(_RAISE)
@ -125,6 +137,3 @@ void post_process_record_keymap(uint16_t keycode, keyrecord_t *record);
#define ALT_APP ALT_T(KC_APP)
#define MG_NKRO MAGIC_TOGGLE_NKRO
#define UC_IRNY UC(0x2E2E)
#define UC_CLUE UC(0x203D)

View File

@ -18,8 +18,18 @@ ifneq ($(strip $(NO_SECRETS)), yes)
endif
endif
CUSTOM_UNICODE_ENABLE ?= yes
ifeq ($(strip $(CUSTOM_UNICODE_ENABLE)), yes)
UNICODE_ENABLE = no
UNICODEMAP_ENABLE = no
UCIS_ENABLE = no
UNICODE_COMMON = yes
OPT_DEFS += -DCUSTOM_UNICODE_ENABLE
SRC += unicoooode.c
endif
CUSTOM_TAP_DANCE ?= yes
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
ifeq ($(strip $(CUSTOM_TAP_DANCE)), yes)
ifeq ($(strip $(TAP_DANCE_ENABLE)), yes)
SRC += $(USER_PATH)/tap_dances.c
endif

View File

@ -18,7 +18,8 @@
#include "transactions.h"
#include <string.h>
#ifdef UNICODE_ENABLE
#ifdef CUSTOM_UNICODE_ENABLE
#include "process_unicode_common.h"
extern unicode_config_t unicode_config;
#endif
#ifdef AUDIO_ENABLE

View File

@ -0,0 +1,282 @@
/* Copyright 2020 @tzarc
* 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
*
* 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 "drashna.h"
#include "process_unicode_common.h"
uint16_t typing_mode;
void tap_code16_nomods(uint8_t kc) {
uint8_t temp_mod = get_mods();
clear_mods();
clear_oneshot_mods();
tap_code16(kc);
set_mods(temp_mod);
}
void tap_unicode_glyph_nomods(uint32_t glyph) {
uint8_t temp_mod = get_mods();
clear_mods();
clear_oneshot_mods();
register_unicode(glyph);
set_mods(temp_mod);
}
typedef uint32_t (*translator_function_t)(bool is_shifted, uint32_t keycode);
#define DEFINE_UNICODE_RANGE_TRANSLATOR(translator_name, lower_alpha, upper_alpha, zero_glyph, number_one, space_glyph) \
static inline uint32_t translator_name(bool is_shifted, uint32_t keycode) { \
switch (keycode) { \
case KC_A ... KC_Z: \
return (is_shifted ? upper_alpha : lower_alpha) + keycode - KC_A; \
case KC_0: \
return zero_glyph; \
case KC_1 ... KC_9: \
return (number_one + keycode - KC_1); \
case KC_SPACE: \
return space_glyph; \
} \
return keycode; \
}
#define DEFINE_UNICODE_LUT_TRANSLATOR(translator_name, ...) \
static inline uint32_t translator_name(bool is_shifted, uint32_t keycode) { \
static const uint32_t translation[] = {__VA_ARGS__}; \
uint32_t ret = keycode; \
if ((keycode - KC_A) < (sizeof(translation) / sizeof(uint32_t))) { \
ret = translation[keycode - KC_A]; \
} \
return ret; \
}
bool process_record_glyph_replacement(uint16_t keycode, keyrecord_t *record, translator_function_t translator) {
uint8_t temp_mod = get_mods();
uint8_t temp_osm = get_oneshot_mods();
bool is_shifted = (temp_mod | temp_osm) & MOD_MASK_SHIFT;
if (((temp_mod | temp_osm) & (MOD_MASK_CTRL | MOD_MASK_ALT | MOD_MASK_GUI)) == 0) {
if (KC_A <= keycode && keycode <= KC_Z) {
if (record->event.pressed) {
tap_unicode_glyph_nomods(translator(is_shifted, keycode));
}
return false;
} else if (KC_1 <= keycode && keycode <= KC_0) {
if (is_shifted) { // skip shifted numbers, so that we can still use symbols etc.
return process_record_keymap(keycode, record);
}
if (record->event.pressed) {
register_unicode(translator(is_shifted, keycode));
}
return false;
} else if (keycode == KC_SPACE) {
if (record->event.pressed) {
register_unicode(translator(is_shifted, keycode));
}
return false;
}
}
return true;
}
DEFINE_UNICODE_RANGE_TRANSLATOR(unicode_range_translator_wide, 0xFF41, 0xFF21, 0xFF10, 0xFF11, 0x2003);
DEFINE_UNICODE_RANGE_TRANSLATOR(unicode_range_translator_script, 0x1D4EA, 0x1D4D0, 0x1D7CE, 0x1D7C1, 0x2002);
DEFINE_UNICODE_RANGE_TRANSLATOR(unicode_range_translator_boxes, 0x1F170, 0x1F170, '0', '1', 0x2002);
DEFINE_UNICODE_RANGE_TRANSLATOR(unicode_range_translator_regional, 0x1F1E6, 0x1F1E6, '0', '1', 0x2003);
DEFINE_UNICODE_LUT_TRANSLATOR(unicode_lut_translator_aussie,
0x0250, // a
'q', // b
0x0254, // c
'p', // d
0x01DD, // e
0x025F, // f
0x0183, // g
0x0265, // h
0x1D09, // i
0x027E, // j
0x029E, // k
'l', // l
0x026F, // m
'u', // n
'o', // o
'd', // p
'b', // q
0x0279, // r
's', // s
0x0287, // t
'n', // u
0x028C, // v
0x028D, // w
0x2717, // x
0x028E, // y
'z', // z
0x0269, // 1
0x3139, // 2
0x0190, // 3
0x3123, // 4
0x03DB, // 5
'9', // 6
0x3125, // 7
'8', // 8
'6', // 9
'0' // 0
);
bool process_record_aussie(uint16_t keycode, keyrecord_t *record) {
bool is_shifted = (get_mods() | get_oneshot_mods()) & MOD_MASK_SHIFT;
if ((KC_A <= keycode) && (keycode <= KC_0)) {
if (record->event.pressed) {
if (!process_record_glyph_replacement(keycode, record, unicode_lut_translator_aussie)) {
tap_code16_nomods(KC_LEFT);
return false;
}
}
} else if (record->event.pressed && keycode == KC_SPACE) {
tap_code16_nomods(KC_SPACE);
tap_code16_nomods(KC_LEFT);
return false;
} else if (record->event.pressed && keycode == KC_ENTER) {
tap_code16_nomods(KC_END);
tap_code16_nomods(KC_ENTER);
return false;
} else if (record->event.pressed && keycode == KC_HOME) {
tap_code16_nomods(KC_END);
return false;
} else if (record->event.pressed && keycode == KC_END) {
tap_code16_nomods(KC_HOME);
return false;
} else if (record->event.pressed && keycode == KC_BSPC) {
tap_code16_nomods(KC_DELT);
return false;
} else if (record->event.pressed && keycode == KC_DELT) {
tap_code16_nomods(KC_BSPC);
return false;
} else if (record->event.pressed && keycode == KC_QUOT) {
tap_unicode_glyph_nomods(is_shifted ? 0x201E : 0x201A);
tap_code16_nomods(KC_LEFT);
return false;
} else if (record->event.pressed && keycode == KC_COMMA) {
tap_unicode_glyph_nomods(is_shifted ? '<' : 0x2018);
tap_code16_nomods(KC_LEFT);
return false;
} else if (record->event.pressed && keycode == KC_DOT) {
tap_unicode_glyph_nomods(is_shifted ? '>' : 0x02D9);
tap_code16_nomods(KC_LEFT);
return false;
} else if (record->event.pressed && keycode == KC_SLASH) {
tap_unicode_glyph_nomods(is_shifted ? 0x00BF : '/');
tap_code16_nomods(KC_LEFT);
return false;
}
return true;
}
bool process_record_zalgo(uint16_t keycode, keyrecord_t *record) {
if ((KC_A <= keycode) && (keycode <= KC_0)) {
if (record->event.pressed) {
tap_code16_nomods(keycode);
int number = (rand() % (8 + 1 - 2)) + 2;
for (int index = 0; index < number; index++) {
uint16_t hex = (rand() % (0x036F + 1 - 0x0300)) + 0x0300;
register_unicode(hex);
}
return false;
}
}
return true;
}
bool process_record_unicode(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case UC_FLIP: // (ノಠ痊ಠ)ノ彡┻━┻
if (record->event.pressed) {
send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻");
}
break;
case UC_TABL: // ┬─┬ノ( º _ ºノ)
if (record->event.pressed) {
send_unicode_string("┬─┬ノ( º _ ºノ)");
}
break;
case UC_SHRG: // ¯\_(ツ)_/¯
if (record->event.pressed) {
send_unicode_string("¯\\_(ツ)_/¯");
}
break;
case UC_DISA: // ಠ_ಠ
if (record->event.pressed) {
send_unicode_string("ಠ_ಠ");
}
break;
case UC_IRNY: // ⸮
if (record->event.pressed) {
register_unicode(0x2E2E);
}
break;
case UC_CLUE: // ‽
if (record->event.pressed) {
register_unicode(0x203D);
}
break;
case KC_NOMODE ... KC_ZALGO:
if (record->event.pressed) {
if (typing_mode != keycode) {
typing_mode = keycode;
} else {
typing_mode = 0;
}
}
break;
break;
}
if (((keycode >= QK_MOD_TAP && keycode <= QK_MOD_TAP_MAX) || (keycode >= QK_LAYER_TAP && keycode <= QK_LAYER_TAP_MAX)) && record->tap.count) {
keycode &= 0xFF;
}
if (typing_mode == KC_WIDE) {
if (((KC_A <= keycode) && (keycode <= KC_0)) || keycode == KC_SPACE) {
return process_record_glyph_replacement(keycode, record, unicode_range_translator_wide);
}
} else if (typing_mode == KC_SCRIPT) {
if (((KC_A <= keycode) && (keycode <= KC_0)) || keycode == KC_SPACE) {
return process_record_glyph_replacement(keycode, record, unicode_range_translator_script);
}
} else if (typing_mode == KC_BLOCKS) {
if (((KC_A <= keycode) && (keycode <= KC_0)) || keycode == KC_SPACE) {
return process_record_glyph_replacement(keycode, record, unicode_range_translator_boxes);
}
} else if (typing_mode == KC_REGIONAL) {
if (((KC_A <= keycode) && (keycode <= KC_0)) || keycode == KC_SPACE) {
if (!process_record_glyph_replacement(keycode, record, unicode_range_translator_regional)) {
wait_us(500);
tap_unicode_glyph_nomods(0x200C);
return false;
}
}
} else if (typing_mode == KC_AUSSIE) {
return process_record_aussie(keycode, record);
} else if (typing_mode == KC_ZALGO) {
return process_record_zalgo(keycode, record);
}
return true;
}