diff options
-rw-r--r-- | keyboards/primekb/prime_e/keymaps/milestogo/config.h | 41 | ||||
-rw-r--r-- | keyboards/primekb/prime_e/keymaps/milestogo/keymap.c | 150 | ||||
-rw-r--r-- | keyboards/primekb/prime_e/keymaps/milestogo/readme.md | 2 | ||||
-rw-r--r-- | keyboards/primekb/prime_e/keymaps/milestogo/rules.mk | 1 | ||||
-rw-r--r-- | users/miles2go/babblePaste.c | 130 | ||||
-rw-r--r-- | users/miles2go/babblePaste.h | 50 | ||||
-rw-r--r-- | users/miles2go/babblePaste.md | 71 | ||||
-rw-r--r-- | users/miles2go/babl_chromeos.c | 2 | ||||
-rw-r--r-- | users/miles2go/babl_emacs.c | 1 | ||||
-rw-r--r-- | users/miles2go/babl_kitty.c | 153 | ||||
-rw-r--r-- | users/miles2go/babl_nano.c | 77 | ||||
-rw-r--r-- | users/miles2go/babl_vi.c | 1 | ||||
-rw-r--r-- | users/miles2go/config.h | 8 | ||||
-rw-r--r-- | users/miles2go/milestogo.c | 29 | ||||
-rw-r--r-- | users/miles2go/milestogo.h | 343 | ||||
-rw-r--r-- | users/miles2go/readme.md | 2 | ||||
-rw-r--r-- | users/miles2go/rules.mk | 2 |
17 files changed, 842 insertions, 221 deletions
diff --git a/keyboards/primekb/prime_e/keymaps/milestogo/config.h b/keyboards/primekb/prime_e/keymaps/milestogo/config.h new file mode 100644 index 0000000000..24a42bb185 --- /dev/null +++ b/keyboards/primekb/prime_e/keymaps/milestogo/config.h @@ -0,0 +1,41 @@ +/* +Copyright 2019 Holten Campbell + +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 + + +#undef MATRIX_ROWS +#undef MATRIX_COLS +#undef MATRIX_ROW_PINS +#undef MATRIX_COL_PINS + +/* key matrix size */ +#define MATRIX_ROWS 5 +#define MATRIX_COLS 15 + +/* Keyboard Matrix Assignments */ +#define MATRIX_ROW_PINS { E6, C7, B5, B4, C6 } +#define MATRIX_COL_PINS { F0, F1, F4, F5, F6, F7, D6, D4, D5, D3, D2, D1, D0, B6, D7} +#define UNUSED_PINS + +// Babble config +#define USE_BABBLEPASTE +#define BABL_MODSWAP +#define BABL_READMUX +#define BABL_KITTY +#define BABL_MAC +#define BABL_LINUX diff --git a/keyboards/primekb/prime_e/keymaps/milestogo/keymap.c b/keyboards/primekb/prime_e/keymaps/milestogo/keymap.c new file mode 100644 index 0000000000..ced250e51f --- /dev/null +++ b/keyboards/primekb/prime_e/keymaps/milestogo/keymap.c @@ -0,0 +1,150 @@ +/* Copyright 2018 Holten Campbell + * + * 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 QMK_KEYBOARD_H +#include "milestogo.h" + +/* customized matrix needs to be updated in local config.h +#define MATRIX_ROWS 5 +#define MATRIX_COLS 15 +#define MATRIX_ROW_PINS { E6, C7, B5, B4, C6 } +#define MATRIX_COL_PINS { F0, F1, F4, F5, F6, F7, D6, D4, D5, D3, D2, D1, D0, B6, D7} +*/ + +#define LAYOUT_wrap_m2primee(...) LAYOUT_m2primee(__VA_ARGS__) +#define LAYOUT_wrap_m2primee_trns(...) LAYOUT_m2primee_trns(__VA_ARGS__) + +// clang-format off +#define LAYOUT_m2primee(\ + K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, \ + K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K112,\ + K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, \ + K300, K301, K303, K304, K306, K308, K311, K312, \ + K413, K414 )\ + {\ + {K000, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, KC_NO, KC_NO},\ + {K100, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, KC_NO, K112, KC_NO, KC_NO},\ + {K200, K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211, K212, KC_NO, KC_NO}, \ + {K300, K301, KC_NO, K303, K304, KC_NO, K306, KC_NO, K308, KC_NO, KC_NO, K311, K312, KC_NO, KC_NO}, \ + {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, K413, K414 } \ + } + +#define LAYOUT_m2primee_trns(\ + K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, \ + K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, K112, \ + K201, K202, K203, K204, K205, K206, K207, K208, K209, K210, K211) \ + {\ + {KC_TRNS, K001, K002, K003, K004, K005, K006, K007, K008, K009, K010, K011, K012, KC_NO, KC_NO}, \ + {KC_TRNS, K101, K102, K103, K104, K105, K106, K107, K108, K109, K110, KC_NO, K112, KC_NO, KC_NO}, \ + {KC_LSFT, K201, K202, K203, K204, K205, KC_TRNS, K207, K208, K209, K210, K211, KC_TRNS, KC_NO, KC_NO}, \ + {KC_LALT, KC_TRNS, KC_NO, KC_TRNS, KC_TRNS, KC_NO, KC_TRNS, KC_NO, KC_TRNS, KC_NO, KC_NO, KC_TRNS, KC_RSFT, KC_NO, KC_NO}, \ + {KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, KC_NO, B_1ME, KC_ENTER } \ + } + + +const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_QWERTY] = LAYOUT_wrap_m2primee(\ +KC_TAB, _________________QWERTY_L1_________________, _________________QWERTY_R1_________________, KC_MINS, KC_EQL, +LT(_MOV,KC_ESC), _________________QWERTY_L2_________________, _________________QWERTY_R2_________________, KC_QUOT, +KC_LSFT, _________________QWERTY_L3_________________, MO(_SYM), _________________QWERTY_R3_________________, KC_RSFT, +B_2ME, KC_LALT, LT(_NUM, KC_DEL), KC_BSPC, KC_SPC, LT(_NUM, KC_ESC), B_2ME, KC_RALT, +B_1ME, KC_ENTER), + + [_NUM] = LAYOUT_wrap_m2primee(\ +KC_TRNS, __________40_______NUM_L1__________________, __________40_______NUM_R1__________________, KC_VOLD, KC_VOLU, +KC_TRNS, __________40_______NUM_L2__________________, __________40_______NUM_R2__________________, KC_ENT, +KC_TRNS, __________40_______NUM_L3__________________, KC_TRNS, __________40_______NUM_R3__________________, KC_TRNS, +KC_TRNS, KC_TRNS, KC_LSFT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, +KC_TRNS, KC_TRNS), + + [_CDH] = LAYOUT_wrap_m2primee_trns(\ +______________COLEMAK_MOD_DH_L1____________, ______________COLEMAK_MOD_DH_R1____________, KC_TRNS, KC_TRNS, +______________COLEMAK_MOD_DH_L2____________, ______________COLEMAK_MOD_DH_R2____________, KC_QUOT, +______________COLEMAK_MOD_DH_L3____________, KC_TRNS, ______________COLEMAK_MOD_DH_R3____________), + + [_SYM] = LAYOUT_wrap_m2primee_trns(\ +___________________SYM_L1__________________, ___________________SYM_R1__________________, KC_TRNS, KC_TRNS, +___________________SYM_L2__________________, ___________________SYM_R2__________________, KC_TRNS, +___________________SYM_L3__________________, KC_TRNS, ___________________SYM_R3__________________), + + [_MOV] = LAYOUT_wrap_m2primee_trns(\ +__________40_______MOV_L1__________________, __________40_______MOV_R1__________________, KC_TRNS, KC_CDH, +__________40_______MOV_L2__________________, __________40_______MOV_R2__________________, KC_TRNS, +__________40_______MOV_L3__________________, KC_TRNS, __________40_______MOV_R3__________________), + + [_DMOV] = LAYOUT_wrap_m2primee_trns(\ +____________40__DELMOV_L1__________________, ____________40__DELMOV_R1__________________ , KC_TRNS, KC_CDH, +____________40__DELMOV_L2__________________, ____________40__DELMOV_R2__________________ , KC_TRNS, +____________40__DELMOV_L3__________________, KC_TRNS, ____________40__DELMOV_R3__________________ ), +}; + +// clang-format on + +void matrix_init_user(void) { + // set CapsLock LED to output and high by default, drop low when on. + setPinOutput(B1); + writePinHigh(B1); + // set NumLock LED to output and low + setPinOutput(B2); + writePinLow(B2); + // set ScrollLock LED to output and low + setPinOutput(B3); + writePinLow(B3); + + backlight_enable(); + backlight_level(2); +} + +bool led_update_kb(led_t led_state) { +#ifndef USE_BABBLEPASTE + // if we aren't using the LEDs to show bablepaste options, use them to show standard keyboard stuff + writePin(B1, led_state.caps_lock); + writePin(B2, led_state.num_lock); + writePin(B3, led_state.scroll_lock); +#endif + return true; +} + +void babble_modeswitch_kb(uint8_t mode) { +#ifdef USE_BABBLEPASTE + switch (mode) { + case (BABL_READMUX_MODE): + writePinHigh(B3); + writePinLow(B2); + backlight_level(1); + break; + case (BABL_LINUX_MODE): + writePinHigh(B2); + writePinLow(B3); + backlight_level(2); + break; + case (BABL_MAC_MODE): // backlight on, indicator leds off + writePinLow(B3); + writePinLow(B2); + backlight_level(4); + break; + } + + // call the user function + babble_modeswitch_user(mode); +#endif +} + +// function for layer indicator LED +layer_state_t layer_state_set_user(layer_state_t state) { + // Turn on top LED if we are in colemak, off for qwerty. + writePin(B1, layer_state_cmp(state, _CDH)); + return state; +} diff --git a/keyboards/primekb/prime_e/keymaps/milestogo/readme.md b/keyboards/primekb/prime_e/keymaps/milestogo/readme.md new file mode 100644 index 0000000000..c74eda3ea3 --- /dev/null +++ b/keyboards/primekb/prime_e/keymaps/milestogo/readme.md @@ -0,0 +1,2 @@ +# Modified keymap for Prime_E +My PrimeE has two added thumb switches, so it uses a slightly different keymap.
\ No newline at end of file diff --git a/keyboards/primekb/prime_e/keymaps/milestogo/rules.mk b/keyboards/primekb/prime_e/keymaps/milestogo/rules.mk new file mode 100644 index 0000000000..81d9ace791 --- /dev/null +++ b/keyboards/primekb/prime_e/keymaps/milestogo/rules.mk @@ -0,0 +1 @@ +USER_NAME := miles2go diff --git a/users/miles2go/babblePaste.c b/users/miles2go/babblePaste.c index 2a32024cd2..cd032882bf 100644 --- a/users/miles2go/babblePaste.c +++ b/users/miles2go/babblePaste.c @@ -12,13 +12,14 @@ and https://github.com/qmk/qmk_firmware/blob/master/keyboards/planck/keymaps/jee #ifdef USE_BABBLEPASTE # include "babblePaste.h" -// small function that we might also want to call from a keymap. - // GLOBAL variable to determine mode. Sets startup default if no eeppom uint8_t babble_mode = 0; -// function to tell the user that the mode has changed -__attribute__((weak)) void babble_led_user(void) {} +// functions to tell the user that the mode has changed +__attribute__((weak)) void babble_modeswitch_user(uint8_t mode) {} +__attribute__((weak)) void babble_modeswitch_kb(uint8_t mode) { babble_modeswitch_user( mode); } + + void set_babble_mode(uint8_t id) { babble_mode = id; } @@ -27,6 +28,7 @@ void babble_mode_increment() { if (babble_mode >= BABL_MODEMAX) { babble_mode = 0; } + babble_modeswitch_kb(babble_mode); } void babble_mode_decrement() { @@ -35,21 +37,97 @@ void babble_mode_decrement() { } else { babble_mode = BABL_MODEMAX - 1; } + babble_modeswitch_kb(babble_mode); } /* this function runs the appropriate babblepaste macro, given the global babble_mode and a keycode defined in the babble_keycodes enum. -This could be made faster by splitting into two functions sorted by keycode range +This could be made faster by splitting into functions sorted by keycode range But that makes for a *lot* of ifdefs. */ -bool babblePaste(uint16_t keycode) { - // handle the OS/mode switching first +bool babblePaste(uint16_t keycode, bool is_pressed ) { + // handle keys that have up & down behavior first, then OS/mode switching, then macros + +// This is the key used for cut & paste (Propeller on Mac, Control elsewhere) +# ifdef BABL_MODSWAP + // WARNING, this assumes you have BABL_MAC_MODE defined. + if (keycode == BABL_PRIMARY_OS_MOD ) { + if (babble_mode == BABL_MAC_MODE) { + if (is_pressed) { + register_code(KC_LGUI); + } else { + unregister_code(KC_LGUI); + } + } else { // everybody else + + if (is_pressed) { + register_code(KC_LCTL); + } else { + unregister_code(KC_LCTL); + } + } + } + +// This is the os key not used in cut & paste. (CTRL on mac, GUI elsewhere) + if (keycode == BABL_SECONDARY_OS_MOD ) { + if (babble_mode == BABL_MAC_MODE) { + if (is_pressed) { + register_code(KC_LCTL); + } else { + unregister_code(KC_LCTL); + } + + } else { // everybody else + if (is_pressed) { + register_code(KC_LGUI); + } else { + unregister_code(KC_LGUI); + } + } + } + +// This is the alt key in most OSes. Mostly useful if you want to do hyper on one OS, Meh on another. + if (keycode == BABL_TERTIARY_OS_MOD ) { + if (babble_mode == BABL_MAC_MODE) { + if (is_pressed) { + register_code(KC_LALT); + } else { + unregister_code(KC_LALT); + } + } else { // everybody else + + if (is_pressed) { + register_code(KC_LALT); + } else { + unregister_code(KC_LALT); + } + } + } + +# endif + +// below here we are only running macros - don't serve any key up events. + if (is_pressed == 0 ) { + return true; + } + +// handle increment functions. + +if (keycode == BABL_MODE_INCREMENT) { + babble_mode_increment(); + return true; +} + +if (keycode == BABL_MODE_DECREMENT) { + babble_mode_decrement(); + return true; +} # ifdef BABL_MAC if (keycode == BABL_DO_MAC) { set_babble_mode(BABL_MAC_MODE); - babble_led_user(); + babble_modeswitch_kb(babble_mode); return true; } @@ -61,7 +139,7 @@ bool babblePaste(uint16_t keycode) { # ifdef BABL_VI if (keycode == BABL_DO_VI) { set_babble_mode(BABL_VI_MODE); - babble_led_user(); + babble_modeswitch_kb(babble_mode); return true; } if (babble_mode == BABL_VI_MODE) { @@ -71,7 +149,7 @@ bool babblePaste(uint16_t keycode) { # ifdef BABL_WINDOWS if (keycode == BABL_DO_WINDOWS) { set_babble_mode(BABL_WINDOWS_MODE); - babble_led_user(); + babble_modeswitch_kb(babble_mode); return true; } if (babble_mode == BABL_WINDOWS_MODE) { @@ -81,7 +159,7 @@ bool babblePaste(uint16_t keycode) { # ifdef BABL_LINUX if (keycode == BABL_DO_LINUX) { set_babble_mode(BABL_LINUX_MODE); - babble_led_user(); + babble_modeswitch_kb(babble_mode); return true; } if (babble_mode == BABL_LINUX_MODE) { @@ -91,27 +169,47 @@ bool babblePaste(uint16_t keycode) { # ifdef BABL_EMACS if (keycode == BABL_DO_EMACS) { set_babble_mode(BABL_EMACS_MODE); - babble_led_user(); + babble_modeswitch_kb(babble_mode); return true; } if (babble_mode == BABL_EMACS_MODE) { babblePaste_emacs(keycode); } # endif -# ifdef BABL_CHROME +# ifdef BABL_NANO + if (keycode == BABL_DO_NANO) { + set_babble_mode(BABL_NANO_MODE); + babble_modeswitch_kb(babble_mode); + return true; + } + if (babble_mode == BABL_NANO_MODE) { + babblePaste_nano(keycode); + } +# endif +# ifdef BABL_KITTY + if (keycode == BABL_DO_KITTY) { + set_babble_mode(BABL_KITTY_MODE); + babble_modeswitch_kb(babble_mode); + return true; + } + if (babble_mode == BABL_KITTY_MODE) { + babblePaste_kitty(keycode); + } +# endif +# ifdef BABL_CHROMEOS if (keycode == BABL_DO_CHROMEOS) { set_babble_mode(BABL_CHROMEOS_MODE); - babble_led_user(); + babble_modeswitch_kb(babble_mode); return true; } if (babble_mode == BABL_CHROMEOS_MODE) { - babblePaste_readmux(keycode); + babblePaste_chromeos(keycode); } # endif # ifdef BABL_READMUX if (keycode == BABL_DO_READMUX) { set_babble_mode(BABL_READMUX_MODE); - babble_led_user(); + babble_modeswitch_kb(babble_mode); return true; } if (babble_mode == BABL_READMUX_MODE) { diff --git a/users/miles2go/babblePaste.h b/users/miles2go/babblePaste.h index 606640227c..8fc233e8d4 100644 --- a/users/miles2go/babblePaste.h +++ b/users/miles2go/babblePaste.h @@ -16,7 +16,8 @@ and jeebak & algernon's keymap void set_babble_mode(uint8_t id); void babble_mode_increment(void); void babble_mode_decrement(void); -void babble_led_user(void); +void babble_modeswitch_user(uint8_t mode); +void babble_modeswitch_kb(uint8_t mode); // manually re-order these if you want to set the order or default. enum babble_modes { @@ -32,19 +33,24 @@ enum babble_modes { # ifdef BABL_VI BABL_VI_MODE, # endif -# ifdef BABL_LINUX - BABL_LINUX_MODE, -# endif # ifdef BABL_EMACS BABL_EMACS_MODE, # endif +# ifdef BABL_NANO + BABL_NANO_MODE, +# endif +# ifdef BABL_KITTY + BABL_KITTY_MODE, +# endif # ifdef BABL_CHROMEOS BABL_CHROMEOS_MODE, # endif +# ifdef BABL_LINUX + BABL_LINUX_MODE, +# endif BABL_MODEMAX }; -// void babble_led_user( uint8_t id) /// Hacks to make it easier to create sendstring macros @@ -79,6 +85,13 @@ enum babble_modes { enum babble_keycodes { FIRST = BABBLE_START, + BABL_MODE_INCREMENT, + BABL_MODE_DECREMENT, +# ifdef BABL_MODSWAP + BABL_PRIMARY_OS_MOD, + BABL_SECONDARY_OS_MOD, + BABL_TERTIARY_OS_MOD, +# endif # ifdef BABL_MOVE // Movement macros // left & right @@ -171,6 +184,7 @@ enum babble_keycodes { # endif // BABL_APP_CELLS # ifdef BABL_APP_EDITOR BABL_APP_MULTI_SELECT, /* www.sublimetext.com/docs/2/multiple_selection_with_the_keyboard.html */ + BABL_APP_SET_MARK, // set editor mark # endif // BABL_APP_EDITOR # ifdef BABL_APP_WINDOWSPLITTING // These aren't useful on most oses. @@ -197,6 +211,12 @@ enum babble_keycodes { # ifdef BABL_EMACS BABL_DO_EMACS, # endif +# ifdef BABL_NANO + BABL_DO_NANO, +# endif +# ifdef BABL_KITTY + BABL_DO_KITTY, +# endif # ifdef BABL_VI BABL_DO_VI, # endif @@ -210,7 +230,7 @@ enum babble_keycodes { }; // primary function. -bool babblePaste(uint16_t keycode); +bool babblePaste(uint16_t keycode, bool is_pressed); /****************************************************/ /* All per-os includes and short mode switch macros*/ @@ -230,6 +250,14 @@ bool babblePaste_linux(uint16_t keycode); # define B_EMACS BABL_DO_EMACS bool babblePaste_emacs(uint16_t keycode); # endif +# ifdef BABL_NANO +# define B_NANO BABL_DO_NANO +bool babblePaste_nano(uint16_t keycode); +# endif +# ifdef BABL_KITTY +# define B_KITTY BABL_DO_KITTY +bool babblePaste_kitty(uint16_t keycode); +# endif # ifdef BABL_VI # define B_VI BABL_DO_VI bool babblePaste_vi(uint16_t keycode); @@ -243,12 +271,17 @@ bool babblePaste_readmux(uint16_t keycode); bool babblePaste_chromeos(uint16_t keycode); # endif -# define BABL_INC babble_mode_increment(); -# define BABL_DEC babble_mode_decrement(); /**************************************************** ** All keyboard macros for Babble Actions *****************************************************/ +# define B_INC BABL_MODE_INCREMENT +# define B_DEC BABL_MODE_DECREMENT +# ifdef BABL_MODSWAP +# define B_1ME BABL_PRIMARY_OS_MOD +# define B_2ME BABL_SECONDARY_OS_MOD +# define B_3ME BABL_TERTIARY_OS_MOD +# endif # ifdef BABL_MOVE # define B_L1C BABL_GO_LEFT_1C @@ -334,6 +367,7 @@ bool babblePaste_chromeos(uint16_t keycode); # endif // BABL_APP_CELLS # ifdef BABL_APP_EDITOR # define B_MSEL BABL_APP_MULTI_SELECT +# define B_MARK BABL_APP_SET_MARK /* www.sublimetext.com/docs/2/multiple_selection_with_the_keyboard.html */ # endif // BABL_APP_EDITOR # ifdef BABL_APP_WINDOWSPLITTING diff --git a/users/miles2go/babblePaste.md b/users/miles2go/babblePaste.md index cc1c31bd0d..4f68cc4ae8 100644 --- a/users/miles2go/babblePaste.md +++ b/users/miles2go/babblePaste.md @@ -26,6 +26,7 @@ To switch modes, run the switch_babble_mode() function, or a pre defined BABL_DO #define BABL_MAC #define BABL_LINUX #define BABL_EMACS + #define BABL_NANO #define BABL_CHROMEOS //// These enable subsets of babble macros. Disable options to save space @@ -56,22 +57,22 @@ To switch modes, run the switch_babble_mode() function, or a pre defined BABL_DO Add the following to your keymap in process_record_user, before the main switch statement. ``` - #ifdef USE_BABBLEPASTE - if( keycode > BABBLE_START && keycode < BABBLE_END_RANGE ) { - if (record->event.pressed) { // is there a case where this isn't desired? - babblePaste ( keycode ); - } else{ - return true; - } +#ifdef USE_BABBLEPASTE + if (keycode > BABBLE_START && keycode < BABBLE_END_RANGE) { + if (record->event.pressed) { + babblePaste(keycode, 1); + } else { + babblePaste(keycode, 0); } - #endif + } +#endif ``` #### Add makefile rules Update your rules.mk to include the modes you want. - `SRC += babblePaste.c babl_windows.c babl_mac.c babl_vi.c babl_readmux.c babl_chromeos.c babl_emacs.c babl_linux.c` + `SRC += babblePaste.c babl_windows.c babl_mac.c babl_nano babl_vi.c babl_readmux.c babl_chromeos.c babl_emacs.c babl_linux.c` #### Custom Keycodes @@ -97,9 +98,18 @@ See the full list in babblePaste.h, or the list below B_LNX // switch to linux B_VI // switch to Vi mode B_EMAX // switch mode to emacs + B_NANO // switch mode to emacs B_READ // switch to readline /tmux mode B_CROM // switch to chromeos mode. - + + // Swap meaning of modifier key in most ergonomic location based on babble + // mode. Eg Thumb gets CTL on Win/Linux, pinky gets Windows key. Reverse for + // OS X. See first line in babblepaste function. + #define B_1ME BABL_PRIMARY_OS_MOD + #define B_2ME BABL_SECONDARY_OS_MOD + #define B_3ME BABL_TERTIARY_OS_MOD + +// Macros #define B_L1C BABL_GO_LEFT_1C #define B_R1C BABL_GO_RIGHT_1C #define B_L1W BABL_GO_LEFT_WORD @@ -137,6 +147,10 @@ See the full list in babblePaste.h, or the list below #define B_PAPP BABL_SWITCH_APP_LAST // previous #define B_CAPP BABL_CLOSE_APP #define B_HELP BABL_HELP + #define B_HELP BABL_HELP + #define B_LOCK BABL_LOCK + #define B_SCAP BABL_SCREENCAPTURE + #define B_KEYB BABL_SWITCH_KEYBOARD_LAYOUT #define B_NTAB BABL_BROWSER_NEW_TAB #define B_CTAB BABL_BROWSER_CLOSE_TAB @@ -151,9 +165,10 @@ See the full list in babblePaste.h, or the list below #define B_BDEV BABL_BROWSER_DEV_TOOLS // hard one to remember #define B_BRLD BABL_BROWSER_RELOAD #define B_BFULL BABL_BROWSER_FULLSCREEN - #define B_ZIN BABL_BROWSER_ZOOM_IN + #define B_ZIN BABL_BROWSER_ZOOM_IN #define B_ZOUT BABL_BROWSER_ZOOM_OUT + #define B_SAVE BABL_APP_SAVE #define B_PASTV BABL_APP_PASTE_VALUES #define B_CALN BABL_APP_CENTER_ALIGN #define B_CFMT BABL_APP_CLEAR_FORMATTING @@ -167,6 +182,7 @@ See the full list in babblePaste.h, or the list below #define B_SELR BABL_SELECT_ROW #define B_MSEL BABL_APP_MULTI_SELECT + #define B_MARK BABL_APP_SET_MARK #define B_VSPLIT BABL_SPLIT_FRAME_VERT #define B_VUNSPT BABL_UNSPLIT_FRAME_VERT #define B_HSPLIT BABL_SPLIT_FRAME_HORIZONTAL @@ -175,27 +191,48 @@ See the full list in babblePaste.h, or the list below #define B_PRVFM BABL_PREV_FRAME ``` +####Add babblepaste functions to your keyboard or userspace +Functions babble_led_user() and babble_led_kb() are called when babble mode is changed. +``` +void babble_modeswitch_kb(uint8_t mode){ + #ifdef USE_BABBLEPASTE + writePinLow(B3); writePinLow(B2); + switch(mode) { + case(BABL_LINUX_MODE): + writePinHigh(B2); + backlight_level(1); + break; + case(BABL_MAC_MODE): + writePinHigh(B3); + backlight_level(4); + break; + } + // call the user function + babble_modeswitch_user(mode); + #endif +``` + + ## Development FAQs **Todos** -eeprom store state of babble_mode? or update docs so that people can change the order of the enum in -babblespace.h? +eeprom store state of babble_mode? or update docs so that people can change the order of the enum in babblespace.h? **You have huge ifdef stanzas instead of functions** This fails gracefully if you don't have all options defined. Patch if you can think how to use fewer defines. -** Why not an array of arrays as a lookup instead of a function?** +**Why not an array of arrays as a lookup instead of a function?** This would allow you to store the lookup table in PROGMEM. True, but that takes more pre-processor skill than I have, and may be less portable to ARM or other flash mappings. -** Have you tested every key on every platform?** +**Have you tested every key on every platform?** No. Be careful, submit a patch. -** Why not update Apps at the same global level as the OS? ** +**Why not change apps App babble modes at the same global level as the OS?** This is only a good thing if it doesn't confuse the user. If you can show state of OS vs App, it's probably a good thing. -** Can the OS tell the keyboard what mode to use? ** +**Can the OS tell the keyboard what mode to use?** The keyboard side is easy to do with virtser_recv & a function that updates babble_mode. It still needs a PC side app to track where the keyboard focus is. One could use a keyboard macro to launch an app & switch modes for that app. diff --git a/users/miles2go/babl_chromeos.c b/users/miles2go/babl_chromeos.c index a0c461f24e..fd644fc5c5 100644 --- a/users/miles2go/babl_chromeos.c +++ b/users/miles2go/babl_chromeos.c @@ -14,7 +14,7 @@ https://support.google.com/docs/answer/181110?co=GENIE.Platform%3DDesktop&hl=en # ifdef BABL_CHROMEOS -bool babblepaste_chromeos(uint16_t keycode) { +bool babblePaste_chromeos(uint16_t keycode) { # ifdef BABL_MOVE BABLM(BABL_GO_LEFT_1C, SS_TAP(X_LEFT)); BABLM(BABL_GO_RIGHT_1C, SS_TAP(X_RIGHT)); diff --git a/users/miles2go/babl_emacs.c b/users/miles2go/babl_emacs.c index 201da0d1a3..87560b6eb8 100644 --- a/users/miles2go/babl_emacs.c +++ b/users/miles2go/babl_emacs.c @@ -69,6 +69,7 @@ bool babblePaste_emacs(uint16_t keycode) { # ifdef BABL_APP BABLM(BABL_APP_SAVE, SS_LCTL("x") SS_LCTL("s")); + BABLM(BABL_APP_SET_MARK, IMCTL(X_SPACE)); /// BABLM( BABL_APP_MULTI_SELECT, SS_LCTRL("x") "rt" ); // arguably BABLM(BABL_SPLIT_FRAME_VERT, SS_LCTRL("x") "3"); BABLM(BABL_UNSPLIT_FRAME_VERT, SS_LCTRL("u") SS_LCTRL("x") "0"); diff --git a/users/miles2go/babl_kitty.c b/users/miles2go/babl_kitty.c new file mode 100644 index 0000000000..44fd87e5ed --- /dev/null +++ b/users/miles2go/babl_kitty.c @@ -0,0 +1,153 @@ +/* Keyboard mappings for Kitty terminal +https://sw.kovidgoyal.net/kitty/index.html# + + A library to output the right key shortcut in any common app. +Given a global variable babble_mode to show the environment and a +key that calls the paste macro, do the right type of paste. +Setting the context is done by another macro, or TBD interaction with the host. + +Huge thanks to https://en.wikipedia.org/wiki/Table_of_keyboard_shortcuts +and +https://github.com/qmk/qmk_firmware/blob/master/keyboards/planck/keymaps/jeebak/keymap.c +*/ + +#include QMK_KEYBOARD_H + +// #define TAB_MEANS TAB +/* #define TAB_MEANS_TAB to keep the meaning of "tab" and "window" used in kitty documentation. . + * Leaving tab undefined will mean that each babble window command applies to a tab, + * and each babble tab command applies to a window inside the kitty OS window. + */ +//#define TAB_MEANS_TAB + +#ifdef USE_BABBLEPASTE +# include "babblePaste.h" + +# ifdef BABL_KITTY + +bool babblePaste_kitty(uint16_t keycode) { +# ifdef BABL_MOVE + BABLM(BABL_GO_LEFT_1C, SS_TAP(X_LEFT)); + BABLM(BABL_GO_RIGHT_1C, SS_TAP(X_RIGHT)); + BABLM(BABL_GO_LEFT_WORD, IMCTL(X_LEFT)); + BABLM(BABL_GO_RIGHT_WORD, IMCTL(X_RIGHT)); + BABLM(BABL_GO_START_LINE, SS_TAP(X_HOME)); + BABLM(BABL_GO_END_LINE, SS_TAP(X_END)); + BABLM(BABL_GO_START_DOC, OMSFT(IMCTL(X_HOME))); + BABLM(BABL_GO_END_DOC, OMSFT(IMCTL(X_END))); + // leaving these for command line editing. + BABLM(BABL_GO_NEXT_LINE, SS_TAP(X_DOWN)); + BABLM(BABL_GO_PREV_LINE, SS_TAP(X_UP)); + // These are for kitty scrolling by one line + // BABLM(BABL_GO_NEXT_LINE, OMSFT(IMCTL(X_DOWN))); + // BABLM(BABL_GO_PREV_LINE, OMSFT(IMCTL(X_UP))); + // passthrough + BABLM(BABL_PGDN, OMSFT(IMCTL(X_PGDOWN))); // kitty pagedown + BABLM(BABL_PGUP, OMSFT(IMCTL(X_PGUP))); // kitty pageup + // passthrough to commanrd line/shell. + BABLM(BABL_DEL_RIGHT_1C, SS_LCTL("d")); + BABLM(BABL_DEL_LEFT_WORD, SS_LCTL("w")); // meta-DEL instead? + BABLM(BABL_DEL_RIGHT_WORD, SS_LALT("d")); + BABLM(BABL_DEL_TO_LINE_END, SS_LCTL("k")); + BABLM(BABL_DEL_TO_LINE_START, SS_LCTL("u")); + BABLM(BABL_GO_PARA_START, IMCTL(X_UP)); + BABLM(BABL_GO_PARA_END, IMCTL(X_DOWN)); + BABLM(BABL_MODE, "Kitty! "); +# endif +# ifdef BABL_OSKEYS + // cut isn't real, undo/redo are passthrough. + BABLM(BABL_UNDO, SS_LCTL("z")); + BABLM(BABL_REDO, SS_LCTL("y")); + BABLM(BABL_CUT, OMSFT(IMCTL(X_X))); + BABLM(BABL_COPY, OMSFT(IMCTL(X_C))); + BABLM(BABL_PASTE, OMSFT(IMCTL(X_V))); + BABLM(BABL_SELECT_ALL, SS_LCTL("a")); + BABLM(BABL_FIND, SS_LCTL("f")); // passthrough. + // BABLM(BABL_CLOSE_APP, IMALT(X_F4)); // gnome. + // BABLM(BABL_HELP, SS_TAP(X_F1)); // script to pop open kitty web page? + // 2 passthrough. + BABLM(BABL_FIND_NEXT, SS_LCTL("g")); // Gnome*/ + BABLM(BABL_FIND_PREV, OMSFT(IMCTL(X_G))); // Gnome*/ + // BABLM(BABL_FIND_NEXT (SS_LALT(X_F3)) ); //KDE */ + /* BABLM( BABL_FIND_REPLACE , (SS_LCTL("r")) ); // KDE */ + // BABLM(BABL_FIND_REPLACE, SS_LCTL("h")); // Gnome*/ + BABLM(BABL_RUNAPP, OMSFT(IMCTL(X_O))); // pass current selection to program. + BABLM(BABL_SWITCH_APP_NEXT, IMGUI(X_TAB)); + // BABLM(BABL_SWITCH_APP_LAST, OMSFT(IMALT(X_TAB))); + BABLM(BABL_WINDOW_NEXT, IMGUI(X_GRAVE)); // next OS window of kitty. + BABLM(BABL_WINDOW_PREV, OMSFT(IMGUI(X_GRAVE))); // NA? +# ifdef TAB_MEANS_TAB + BABLM(BABL_WINDOW_NEW, OMSFT(IMCTL(X_ENTER))); // a window is a window +# else + BABLM(BABL_WINDOW_NEW, OMSFT(IMCTL(X_T))); // a window is a tab +# endif + // KITTY - missing close window. + // BABLM( BABL_HELP, (SS_TAP(X_F1)) ); // NA? + // BABLM(BABL_LOCK, OMCTL(IMALT(X_L))); // NA passthrough + // BABLM(BABL_SCREENCAPTURE, IMSFT(X_PSCREEN)); // NA passthrough +# endif +# ifdef BABL_BROWSER + +# ifdef TAB_MEANS_TAB + // option A - do tab when I say tab. + BABLM(BABL_BROWSER_NEW_TAB, OMSFT(IMCTL(X_T))); + BABLM(BABL_BROWSER_CLOSE_TAB, OMSFT(IMCTL(X_Q))); + BABLM(BABL_BROWSER_NEXT_TAB, OMSFT(IMCTL(X_RIGHT))); + BABLM(BABL_BROWSER_PREV_TAB, OMSFT(IMCTL(X_LEFT))); + // ok, this is a bit of a stretch, overloading meaning of forwards/backwards + BABLM(BABL_BROWSER_FORWARD, OMSFT(IMCTL(X_DOT))); // move current kitty tab forwards + BABLM(BABL_BROWSER_BACK, OMSFT(IMCTL(X_COMMA))); // move current kitty tab back + // requires kitty config of "map ctrl+shift+f7 detach_window" + BABLM(BABL_BROWSER_REOPEN_LAST_TAB, IMCTL(X_F7)); // pop current frame into a window +# else // tab means window/frame. + // option B - do Kitty window (frame) when I say tab + BABLM(BABL_BROWSER_NEW_TAB, OMSFT(IMCTL(X_ENTER))); + BABLM(BABL_BROWSER_NEXT_TAB, OMSFT(IMCTL(X_LBRC))); + BABLM(BABL_BROWSER_PREV_TAB, OMSFT(IMCTL(X_RBRC))); + // ok, this is a bit of a stretch, overloading meaning of forwards/backwards + BABLM(BABL_BROWSER_FORWARD, OMSFT(IMCTL(X_F))); + BABLM(BABL_BROWSER_BACK, OMSFT(IMCTL(X_B))); + // kitty - questionable mental model - reopen current frame as a window + // requires kitty config of "map ctrl+shift+f6 detach_frame" + BABLM(BABL_BROWSER_REOPEN_LAST_TAB, IMCTL(X_F6)); // pop current frame into a window +# endif // tab means tab + + // BABLM(BABL_BROWSER_FIND, SS_LCTL("f")); + BABLM(BABL_BROWSER_BOOKMARK, SS_LCTL(SS_LSFT(SS_LALT("t")))); // bookmark == set tab title. + BABLM(BABL_BROWSER_DEV_TOOLS, OMSFT(IMCTL(X_F2))); // edit kitty config. + BABLM(BABL_BROWSER_RELOAD, OMSFT(IMCTL(X_DEL))); // re |