Eric Gebhart user space and keymaps (#17487)

Co-authored-by: Drashna Jaelre <drashna@live.com>
This commit is contained in:
Eric Gebhart
2022-11-12 00:09:41 +01:00
committed by GitHub
parent 49a78b8114
commit 050472a4d0
147 changed files with 13177 additions and 4102 deletions

View File

@@ -0,0 +1,106 @@
#pragma once
/*
Copyright 2018-2022 Eric Gebhart <e.a.gebhart@gmail.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/>.
*/
// Language macros to change the names of things to
// match the value of LANG_IS, and EDGE_COLS.
// it would be nice to have consistency, but there isn't.
// Keys need a prefix, layer chunks need a different suffix,
// defines that are are opposite, of keys.
//
// In order to change layer and other names to match lang.
// foo --> foo_bp or foo.
// A new language just needs entries to match so
// that it will create the proper names when LANG_IS
// set to the appropriate values.
// sonly the pfx and sfx functions need additions for
// another language.
// The rest is making sure there are keymap chunks
// defined as needed.
#define COMMA ,
#define CONCATENATE(a, ...) a ## __VA_ARGS__
#define CAT(a, ...) CONCATENATE(a, __VA_ARGS__)
// We need another one with a different name.
// The macros are painted blue otherwise.
// Cat gets used at a low level, around keys, or layers basically.
// Cat 2 is used for thumb cluster choices, any of which can contain
// a number of CATS down at the bottom. -- nested macros of the same
// name get painted blue. So here we are. :-). look in edge_keys.h
// for THUMBS
#define CONCATENATE2(a, ...) a ## __VA_ARGS__
#define CAT2(a, ...) CONCATENATE2(a, __VA_ARGS__)
#define CONCATENATE3(a, ...) a ## __VA_ARGS__
#define CAT3(a, ...) CONCATENATE3(a, __VA_ARGS__)
#define EMPTY()
#define DEFER(id) id EMPTY()
#define OBSTRUCT(...) __VA_ARGS__ DEFER(EMPTY)()
#define EXPAND(...) __VA_ARGS__
// Give the right keycode prefix by LANG_IS
#define LANG_PFX CAT(LANG_IS, KC)
#define COMBOKC CB
#define COMBO2KC CB2
#define BEPOKC BP
#define ENKC KC
#define US_INTKC US
// Give the right symbol suffix by LANG_IS
#define LANG_SFX CAT(CAT(LANG_IS, _), SFX)
#define LOCALE_LAYERS_SFX _LL // for counting the base layers.
#define COMBO_SFX _CB
#define COMBO2_SFX _CB2
#define BEPO_SFX _BP
#define EN_SFX _EN
#define US_INT_SFX _EN
// Give the right map chunk suffix by LANG_IS
#define LANG_MAPSFX CAT(CAT(LANG_IS, _), MAPSFX)
#define COMBO_MAPSFX _CB___
#define COMBO2_MAPSFX _CB2___
#define BEPO_MAPSFX _BP___
#define EN_MAPSFX _EN___
#define US_INT_MAPSFX _EN___
// These use the mapping above to get their job done.
// In order to create keycode names to match lang.
// A --> BP_A or KC_A,US_A
#define LANG_KC(NAME) CAT(LANG_PFX, NAME)
// _SYMB -> _SYMB_EN
// _SYMB -> _SYMB_BP
#define LANG_N(NAME) CAT(NAME, LANG_SFX)
// In order to map chunk names to match lang.
// MAP_CHUNK(___15_BOTTOM) --> ___15_BOTTOM_EN___ or ___15_BOTTOM_BP___
#define MAP_CHUNK(NAME) CAT3(NAME, LANG_MAPSFX)
// for the oled layer map switch
#ifdef SECOND_LOCALE
#define LCASE(NAME) \
case CAT2(NAME, _EN): \
case CAT2(NAME, _BP):
#else
#define LCASE(NAME) \
case CAT2(NAME, _EN):
#endif

View File

@@ -0,0 +1,78 @@
#pragma once
/*
Copyright 2018-2022 Eric Gebhart <e.a.gebhart@gmail.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/>.
*/
#define CONCATENATEKC(a, ...) a ## __VA_ARGS__
#define CATKC(a, ...) CONCATENATEKC(a, __VA_ARGS__)
#define LKC(NAME) CATKC(LANG_PFX, NAME)
// NONE, DV = dvorak, BK=Beakl, BK2=Beakl27, BKW=Beaklwi.
// Give the right keycode prefix by Alt target _IS
#define ALT_TARGET_IS NONE
#define TARGET_PFX CATKC(ALT_TARGET_IS, KC)
#define NONEKC
#define DVKC _DV
#define BKKC _BK
#define BKWKC _BKW
#define BK2KC _BK2
#define HDKC _HD
#define HD_ELANKC _HD_E
#define HD_DASHKC _HD_D
#define CONCATENATETKC(a, ...) a ## __VA_ARGS__
#define CATTKC(a, ...) CONCATENATETKC(a, __VA_ARGS__)
// depending on the value of ALT_TARGET_IS and LANG_IS.
// TL_COMM -> TLKC(_COMM)
// TLKC(_COMM) -> _BK_COMM, _DV_COMM, _BK2_COMM, _BK_COMM, _HD_COMM...
#define TLKC(NAME) CATTKC(TARGET_PFX, NAME)
#define LANG_ROW(K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A) \
LKC(K01), LKC(K02), LKC(K03), LKC(K04), LKC(K05), \
LKC(K06), LKC(K07), LKC(K08), LKC(K09), LKC(K0A) \
#define LANG_ROW12(K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C) \
LKC(K01), LKC(K02), LKC(K03), LKC(K04), LKC(K05), LKC(K06), \
LKC(K07), LKC(K08), LKC(K09), LKC(K0A), LKC(K0B), LKC(K0C) \
// takes a 3x10
#define LANG_MAP(K01, K02, K03, K04, K05, \
K06, K07, K08, K09, K0A, \
K11, K12, K13, K14, K15, \
K16, K17, K18, K19, K1A, \
K21, K22, K23, K24, K25, \
K26, K27, K28, K29, K2A) \
LKC(K01), LKC(K02), LKC(K03), LKC(K04), LKC(K05), \
LKC(K06), LKC(K07), LKC(K08), LKC(K09), LKC(K0A), \
LKC(K11), LKC(K12), LKC(K13), LKC(K14), LKC(K15), \
LKC(K16), LKC(K17), LKC(K18), LKC(K19), LKC(K1A), \
LKC(K21), LKC(K22), LKC(K23), LKC(K24), LKC(K25), \
LKC(K26), LKC(K27), LKC(K28), LKC(K29), LKC(K2A)
// takes a 3x12
#define LANG_MAP6(K01, K02, K03, K04, K05, K06, \
K07, K08, K09, K0A, K0B, K0C, \
K11, K12, K13, K14, K15, K16, \
K17, K18, K19, K1A, K1B, K1C, \
K21, K22, K23, K24, K25, K26, \
K27, K28, K29, K2A, K2B, K2C) \
LKC(K01), LKC(K02), LKC(K03), LKC(K04), LKC(K05), LKC(K06), \
LKC(K07), LKC(K08), LKC(K09), LKC(K0A), LKC(K0B), LKC(K0C), \
LKC(K11), LKC(K12), LKC(K13), LKC(K14), LKC(K15), LKC(K16), \
LKC(K18), LKC(K18), LKC(K19), LKC(K1A), LKC(K1B), LKC(K1C), \
LKC(K21), LKC(K22), LKC(K23), LKC(K24), LKC(K25), LKC(K26), \
LKC(K27), LKC(K28), LKC(K29), LKC(K2A), LKC(K2B), LKC(K2C)

View File

@@ -0,0 +1,27 @@
#pragma once
/*
Copyright 2018-2022 Eric Gebhart <e.a.gebhart@gmail.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/>.
*/
#define LOCALE_DEFAULT CAT(LOCALE_, DEFAULT_LANG)
#define LOCALE_TWO CAT(LOCALE_, SECOND_LOCALE)
enum locales {
LOCALE_DEFAULT = 0,
#ifdef SECOND_LOCALE
LOCALE_TWO,
#endif
LOCALES_END,
};

View File

@@ -0,0 +1,60 @@
/*
Copyright 2018-2022 Eric Gebhart <e.a.gebhart@gmail.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 "ericgebhart.h"
#include "locales.h"
bool process_locales(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_SET_BASE:
// set the current default base to eeprom.
if (record->event.pressed) {
set_single_persistent_default_layer(get_highest_layer(default_layer_state));
}
break;
// choose a different set of default layers based on locales.
case KC_NEXT_LOCALE:
// choose another locale and set the default base to the first layer.
if (!record->event.pressed) {
if (current_locale + 1 < LOCALES_END){
current_locale++;
}else{
current_locale = 0;
}
default_layer_set(1UL << LOCALE_LAYER_RANGE[0]);
}
return false;
break;
// choose a different base layer based on locales.
// simply iterates over the list and sets the default layer.
case KC_NEXT_BASE_LAYER:
if (!record->event.pressed) {
uint8_t current = get_highest_layer(default_layer_state);
if (current < LOCALE_LAYER_RANGE[1]){
current++;
}else{
current = LOCALE_LAYER_RANGE[0];
}
default_layer_set(1UL << current);
}
return false;
break;
}
return true;
}

View File

@@ -0,0 +1,42 @@
#pragma once
/*
Copyright 2022 Eric Gebhart <e.a.gebhart@gmail.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 "ericgebhart.h"
// Stuff we need for locale and layer switching
// there can be more but we need to know where they start and end.
// remember there's limitations on layers.
// Our locales. so it's easy to switch between them.
const uint16_t base_layer_count = BASE_NAME_COUNT - 1;
const uint16_t locale_layers[][2] = {
[LOCALE_DEFAULT] = {0, base_layer_count},
#ifdef SECOND_LOCALE
[LOCALE_TWO] = {BASE_NAME_COUNT, BASE_NAME_COUNT + base_layer_count},
#endif
};
uint32_t current_locale = LOCALE_DEFAULT;
#define LOCALE_LAYER_RANGE locale_layers[current_locale]
bool process_locales(uint16_t keycode, keyrecord_t *record);
#define PROCESS_LOCALES \
if (!process_locales(keycode, record)) { return false; }