Eric Gebhart user space and keymaps (#17487)
Co-authored-by: Drashna Jaelre <drashna@live.com>
This commit is contained in:
parent
49a78b8114
commit
050472a4d0
147 changed files with 13177 additions and 4102 deletions
99
users/ericgebhart/extensions/alt_shift.c
Normal file
99
users/ericgebhart/extensions/alt_shift.c
Normal file
|
@ -0,0 +1,99 @@
|
|||
#include USERSPACE_H
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
bool shift_for_two(uint16_t keycode, keyrecord_t *record){
|
||||
uint16_t mod_state = get_mods();
|
||||
|
||||
bool is_shifted = (get_mods() & MOD_MASK_SHIFT) ||
|
||||
(get_oneshot_mods() & MOD_MASK_SHIFT);
|
||||
|
||||
if(record ->event.pressed) {
|
||||
// If shifted, double these common punctuation marks.
|
||||
if(is_shifted){
|
||||
// clear shift temporarily
|
||||
del_mods(MOD_MASK_SHIFT);
|
||||
del_oneshot_mods(MOD_MASK_SHIFT);
|
||||
|
||||
tap_code16(keycode);
|
||||
tap_code16(keycode);
|
||||
|
||||
// restore previous shift state
|
||||
set_mods(mod_state);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool shift_for_three(uint16_t keycode, keyrecord_t *record){
|
||||
uint16_t mod_state = get_mods();
|
||||
|
||||
bool is_shifted = (get_mods() & MOD_MASK_SHIFT) ||
|
||||
(get_oneshot_mods() & MOD_MASK_SHIFT);
|
||||
|
||||
if(record ->event.pressed) {
|
||||
// If shifted, double these common punctuation marks.
|
||||
if(is_shifted){
|
||||
// clear shift temporarily
|
||||
del_mods(MOD_MASK_SHIFT);
|
||||
del_oneshot_mods(MOD_MASK_SHIFT);
|
||||
|
||||
tap_code16(keycode);
|
||||
tap_code16(keycode);
|
||||
tap_code16(keycode);
|
||||
|
||||
// restore previous shift state
|
||||
set_mods(mod_state);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool override_shift(uint16_t keycode,
|
||||
uint16_t shift_keycode,
|
||||
keyrecord_t *record
|
||||
) {
|
||||
|
||||
bool is_shifted = (get_mods() & MOD_MASK_SHIFT) ||
|
||||
(get_oneshot_mods() & MOD_MASK_SHIFT);
|
||||
|
||||
if (record->event.pressed) {
|
||||
if (is_shifted) {
|
||||
uint8_t mod_state = get_mods();
|
||||
del_mods(MOD_MASK_SHIFT);
|
||||
del_oneshot_mods(MOD_MASK_SHIFT);
|
||||
|
||||
tap_code16(shift_keycode);
|
||||
|
||||
set_mods(mod_state);
|
||||
} else {
|
||||
//tap_code16(keycode);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// macros for use in alt_shift.defs.
|
||||
#define ALT_SHIFT(KCKEY, KC01) \
|
||||
case KCKEY: \
|
||||
return override_shift(KCKEY, KC01, record); \
|
||||
break;
|
||||
|
||||
#define SHIFT_FOR_2(KCKEY) \
|
||||
case KCKEY: \
|
||||
return shift_for_two(KCKEY, record); \
|
||||
break;
|
||||
|
||||
#define SHIFT_FOR_3(KCKEY) \
|
||||
case KCKEY: \
|
||||
return shift_for_three(KCKEY, record); \
|
||||
break;
|
||||
|
||||
bool process_alt_shift_user(uint16_t keycode, keyrecord_t *record) {
|
||||
switch(keycode){
|
||||
#include "alt_shift.def"
|
||||
}
|
||||
return true;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue