get rid of trans logic complete
parent
bd74409688
commit
f5c1169af3
39
src/main.c
39
src/main.c
|
@ -60,7 +60,6 @@ static bool (*kb_is_pressed)[KB_ROWS][KB_COLUMNS] = &_kb_is_pressed;
|
||||||
static bool _kb_was_pressed[KB_ROWS][KB_COLUMNS];
|
static bool _kb_was_pressed[KB_ROWS][KB_COLUMNS];
|
||||||
static bool (*kb_was_pressed)[KB_ROWS][KB_COLUMNS] = &_kb_was_pressed;
|
static bool (*kb_was_pressed)[KB_ROWS][KB_COLUMNS] = &_kb_was_pressed;
|
||||||
|
|
||||||
static bool kb_was_transparent[KB_ROWS][KB_COLUMNS];
|
|
||||||
static layer layers_pressed[KB_ROWS][KB_COLUMNS];
|
static layer layers_pressed[KB_ROWS][KB_COLUMNS];
|
||||||
|
|
||||||
static layer current_layer;
|
static layer current_layer;
|
||||||
|
@ -68,8 +67,7 @@ static layer layer_offset;
|
||||||
static u8 current_row;
|
static u8 current_row;
|
||||||
static u8 current_col;
|
static u8 current_col;
|
||||||
static bool current_is_pressed;
|
static bool current_is_pressed;
|
||||||
static bool non_trans_key_pressed;
|
static bool sticky_done;
|
||||||
static bool trans_key_pressed;
|
|
||||||
|
|
||||||
static bool layers_active[KB_LAYERS];
|
static bool layers_active[KB_LAYERS];
|
||||||
static StickyState layers_sticky[KB_LAYERS];
|
static StickyState layers_sticky[KB_LAYERS];
|
||||||
|
@ -113,10 +111,8 @@ void main_key_loop() {
|
||||||
if (current_is_pressed) {
|
if (current_is_pressed) {
|
||||||
current_layer = layers_top;
|
current_layer = layers_top;
|
||||||
layers_pressed[row][col] = current_layer;
|
layers_pressed[row][col] = current_layer;
|
||||||
trans_key_pressed = false;
|
|
||||||
} else {
|
} else {
|
||||||
current_layer = layers_pressed[row][col];
|
current_layer = layers_pressed[row][col];
|
||||||
trans_key_pressed = kb_was_transparent[row][col];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// set remaining vars, and "execute" key
|
// set remaining vars, and "execute" key
|
||||||
|
@ -124,7 +120,6 @@ void main_key_loop() {
|
||||||
current_col = col;
|
current_col = col;
|
||||||
layer_offset = 0;
|
layer_offset = 0;
|
||||||
exec_key();
|
exec_key();
|
||||||
kb_was_transparent[row][col] = trans_key_pressed;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +145,7 @@ void exec_key(void) {
|
||||||
// FIXME
|
// FIXME
|
||||||
// If the current layer is in the sticky once up state and a key defined
|
// If the current layer is in the sticky once up state and a key defined
|
||||||
// for this layer (a non-transparent key) was pressed, pop the layer
|
// for this layer (a non-transparent key) was pressed, pop the layer
|
||||||
if (layer_top_sticky() == StickyOnceUp && non_trans_key_pressed) {
|
if (layer_top_sticky() == StickyOnceUp && sticky_done) {
|
||||||
layer_disable_top();
|
layer_disable_top();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,7 +369,6 @@ void _kbfun_mediakey_press_release(bool press, keycode key) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// basic keyfuncs
|
// basic keyfuncs
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -383,16 +377,29 @@ keycode current_keycode() { return kb_keycode(current_layer, current_row
|
||||||
keyfunc current_keyfunc_press() { return kb_keyfunc_press(current_layer, current_row, current_col); }
|
keyfunc current_keyfunc_press() { return kb_keyfunc_press(current_layer, current_row, current_col); }
|
||||||
keyfunc current_keycode_release() { return kb_keyfunc_release(current_layer, current_row, current_col); }
|
keyfunc current_keycode_release() { return kb_keyfunc_release(current_layer, current_row, current_col); }
|
||||||
|
|
||||||
|
bool key_is_modifier(keycode key) {
|
||||||
|
switch (key) {
|
||||||
|
case KEY_LeftControl: return true;
|
||||||
|
case KEY_LeftShift: return true;
|
||||||
|
case KEY_LeftAlt: return true;
|
||||||
|
case KEY_LeftGUI: return true;
|
||||||
|
case KEY_RightControl: return true;
|
||||||
|
case KEY_RightShift: return true;
|
||||||
|
case KEY_RightAlt: return true;
|
||||||
|
case KEY_RightGUI: return true;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// normal key
|
// normal key
|
||||||
void kbfun_press_release() {
|
void kbfun_press_release() {
|
||||||
if (!trans_key_pressed) {
|
sticky_done = ! key_is_modifier(current_keycode());
|
||||||
non_trans_key_pressed = true;
|
|
||||||
}
|
|
||||||
_kbfun_press_release(current_is_pressed, current_keycode());
|
_kbfun_press_release(current_is_pressed, current_keycode());
|
||||||
}
|
}
|
||||||
|
|
||||||
// media key
|
// media key
|
||||||
void kbfun_mediakey_press_release() {
|
void kbfun_mediakey_press_release() {
|
||||||
|
sticky_done = true;
|
||||||
keycode key = current_keycode();
|
keycode key = current_keycode();
|
||||||
_kbfun_mediakey_press_release(current_is_pressed, key);
|
_kbfun_mediakey_press_release(current_is_pressed, key);
|
||||||
}
|
}
|
||||||
|
@ -431,17 +438,15 @@ void kbfun_layer_sticky() {
|
||||||
debug_printf("sticky %d down!\n", l);
|
debug_printf("sticky %d down!\n", l);
|
||||||
|
|
||||||
// this should be the only place we care about this flag being cleared
|
// this should be the only place we care about this flag being cleared
|
||||||
non_trans_key_pressed = false;
|
sticky_done = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (layer_sticky(l) == StickyOnceDown) {
|
if (layer_sticky(l) == StickyOnceDown) {
|
||||||
// When releasing this sticky key, pop the layer always
|
// When releasing this sticky key, pop the layer always
|
||||||
layer_disable(l);
|
layer_disable(l);
|
||||||
|
|
||||||
if (!non_trans_key_pressed) {
|
if (!sticky_done) {
|
||||||
// If no key defined for this layer (a non-transparent key)
|
// re-enable the sticky key if we didn't actually use it yet
|
||||||
// was pressed, push the layer again, but in the
|
|
||||||
// StickyOnceUp state
|
|
||||||
layer_enable(l, StickyOnceUp);
|
layer_enable(l, StickyOnceUp);
|
||||||
debug_printf("sticky %d still down!\n", l);
|
debug_printf("sticky %d still down!\n", l);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ void kbfun_control_press_release();
|
||||||
void kbfun_shift_press_release();
|
void kbfun_shift_press_release();
|
||||||
void kbfun_mediakey_press_release();
|
void kbfun_mediakey_press_release();
|
||||||
void kbfun_press_release();
|
void kbfun_press_release();
|
||||||
|
bool key_is_modifier(keycode key);
|
||||||
keyfunc current_keycode_release();
|
keyfunc current_keycode_release();
|
||||||
keyfunc current_keyfunc_press();
|
keyfunc current_keyfunc_press();
|
||||||
keycode current_keycode();
|
keycode current_keycode();
|
||||||
|
|
Loading…
Reference in New Issue