combo with layers
parent
e20ccf838d
commit
11b79bcc8c
40
src/main.c
40
src/main.c
|
@ -22,6 +22,8 @@
|
|||
// types and forward declarations
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#define array_length(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
typedef uint8_t u8;
|
||||
typedef uint16_t u16;
|
||||
|
||||
|
@ -71,6 +73,15 @@ static bool layer_sticky_done;
|
|||
static u8 mod_sticky;
|
||||
static bool mod_sticky_done;
|
||||
|
||||
static const keyfunc _kb_layer_funcs[] = { // TODO ugh
|
||||
&kbfun_layer_press_release,
|
||||
&kbfun_layer_sticky,
|
||||
&kbfun_shift_layer_press_release,
|
||||
&kbfun_control_layer_press_release,
|
||||
&kbfun_alt_layer_press_release,
|
||||
&kbfun_win_layer_press_release,
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int main() {
|
||||
|
@ -215,8 +226,10 @@ void layer_disable(layer l) {
|
|||
}
|
||||
|
||||
bool is_layer_keyfunc(keyfunc f) {
|
||||
if (f == &kbfun_layer_press_release || f == &kbfun_layer_sticky) {
|
||||
return true;
|
||||
for (int i=0; i<array_length(_kb_layer_funcs); i++) {
|
||||
if (f == _kb_layer_funcs[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -283,6 +296,7 @@ void _kbfun_mediakey_press_release(bool press, keycode key) {
|
|||
}
|
||||
|
||||
void _kbfun_modifier_press_release(bool press, keycode key) {
|
||||
debug_printf("mod: %d/%d\n", key, press);
|
||||
if (press) {
|
||||
keyboard_modifier_keys |= (1<<key);
|
||||
} else {
|
||||
|
@ -347,6 +361,8 @@ void kbfun_modifier_press_release() {
|
|||
|
||||
// layer key
|
||||
void kbfun_layer_press_release() {
|
||||
debug_printf("layer: %d/%d\n", current_keycode, current_is_pressed);
|
||||
|
||||
layer_sticky_done = true; // don't disable sticky mods!
|
||||
|
||||
if (current_is_pressed) {
|
||||
|
@ -405,15 +421,25 @@ void kbfun_modifier_sticky() {
|
|||
// combo keyfuncs
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void _kbfun_combo_press_release(keycode combo_key) {
|
||||
void _kbfun_combo_normal_press_release(keycode combo_key) {
|
||||
_kbfun_modifier_press_release(current_is_pressed, combo_key);
|
||||
kbfun_normal_press_release();
|
||||
}
|
||||
|
||||
void kbfun_shift_press_release() { _kbfun_combo_press_release(MOD_KEY_LeftShift); } // +shift
|
||||
void kbfun_control_press_release() { _kbfun_combo_press_release(MOD_KEY_LeftControl); } // +control
|
||||
void kbfun_alt_press_release() { _kbfun_combo_press_release(MOD_KEY_LeftAlt); } // +alt
|
||||
void kbfun_win_press_release() { _kbfun_combo_press_release(MOD_KEY_LeftGUI); } // +win
|
||||
void _kbfun_combo_layer_press_release(keycode combo_key) {
|
||||
kbfun_layer_press_release();
|
||||
_kbfun_modifier_press_release(current_is_pressed, combo_key);
|
||||
}
|
||||
|
||||
void kbfun_shift_press_release() { _kbfun_combo_normal_press_release(MOD_KEY_LeftShift); } // +shift
|
||||
void kbfun_control_press_release() { _kbfun_combo_normal_press_release(MOD_KEY_LeftControl); } // +control
|
||||
void kbfun_alt_press_release() { _kbfun_combo_normal_press_release(MOD_KEY_LeftAlt); } // +alt
|
||||
void kbfun_win_press_release() { _kbfun_combo_normal_press_release(MOD_KEY_LeftGUI); } // +win
|
||||
|
||||
void kbfun_shift_layer_press_release() { _kbfun_combo_layer_press_release(MOD_KEY_LeftShift); } // +shift + layer
|
||||
void kbfun_control_layer_press_release() { _kbfun_combo_layer_press_release(MOD_KEY_LeftControl); } // +control + layer
|
||||
void kbfun_alt_layer_press_release() { _kbfun_combo_layer_press_release(MOD_KEY_LeftAlt); } // +alt + layer
|
||||
void kbfun_win_layer_press_release() { _kbfun_combo_layer_press_release(MOD_KEY_LeftGUI); } // +win + layer
|
||||
|
||||
// capslock
|
||||
void kbfun_capslock_press_release() {
|
||||
|
|
11
src/main.h
11
src/main.h
|
@ -4,7 +4,8 @@ void kbfun_win_press_release();
|
|||
void kbfun_alt_press_release();
|
||||
void kbfun_control_press_release();
|
||||
void kbfun_shift_press_release();
|
||||
void _kbfun_combo_press_release(keycode combo_key);
|
||||
void _kbfun_combo_layer_press_release(keycode combo_key);
|
||||
void _kbfun_combo_normal_press_release(keycode combo_key);
|
||||
void kbfun_modifier_sticky();
|
||||
void kbfun_modifier_press_release();
|
||||
void kbfun_mediakey_press_release();
|
||||
|
@ -19,8 +20,6 @@ void _kbfun_normal_press_release(bool press,keycode key);
|
|||
keyfunc kb_keyfunc_release(layer l,u8 row,u8 col);
|
||||
keyfunc kb_keyfunc_press(layer l,u8 row,u8 col);
|
||||
void layer_enable_upto(layer max_layer);
|
||||
void kbfun_layer_sticky();
|
||||
void kbfun_layer_press_release();
|
||||
bool is_layer_keyfunc(keyfunc f);
|
||||
void layer_enable(layer l);
|
||||
layer highest_active_layer(layer offset);
|
||||
|
@ -32,3 +31,9 @@ void init_sticky();
|
|||
void init_layers();
|
||||
void init_hw();
|
||||
int main();
|
||||
void kbfun_win_layer_press_release();
|
||||
void kbfun_alt_layer_press_release();
|
||||
void kbfun_control_layer_press_release();
|
||||
void kbfun_shift_layer_press_release();
|
||||
void kbfun_layer_sticky();
|
||||
void kbfun_layer_press_release();
|
||||
|
|
Loading…
Reference in New Issue