Callum style layout improvements and my layout changes (#16174)
This commit is contained in:

committed by
GitHub

parent
846e9d4c53
commit
f100de88e5
@@ -17,7 +17,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
|
||||
#define UNICODE_SELECTED_MODES UC_MAC, UC_LNX
|
||||
#define UNICODE_SELECTED_MODES UC_LNX
|
||||
|
||||
#define MOUSEKEY_INTERVAL 12
|
||||
#define MOUSEKEY_MAX_SPEED 6
|
||||
@@ -30,3 +30,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#define MOUSEKEY_WHEEL_INTERVAL 50
|
||||
// The default is 40
|
||||
#define MOUSEKEY_WHEEL_TIME_TO_MAX 100
|
||||
|
||||
#define FLOW_COUNT 6
|
||||
#define FLOW_LAYERS_COUNT 5
|
||||
|
336
keyboards/a_dux/keymaps/daliusd/flow.c
Normal file
336
keyboards/a_dux/keymaps/daliusd/flow.c
Normal file
File diff suppressed because it is too large
Load Diff
27
keyboards/a_dux/keymaps/daliusd/flow.h
Normal file
27
keyboards/a_dux/keymaps/daliusd/flow.h
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
Copyright 2022 Dalius Dobravolskas <dalius.dobravolskas@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/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
bool update_flow(
|
||||
uint16_t keycode,
|
||||
bool pressed,
|
||||
keypos_t key_position
|
||||
);
|
||||
|
||||
void flow_matrix_scan(void);
|
File diff suppressed because it is too large
Load Diff
@@ -1,195 +0,0 @@
|
||||
/* Copyright 2021 @daliusd
|
||||
*
|
||||
* 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 "print.h"
|
||||
#include "oneshot.h"
|
||||
|
||||
void update_oneshot(
|
||||
oneshot_state *state,
|
||||
uint16_t mod,
|
||||
uint16_t trigger,
|
||||
uint16_t keycode,
|
||||
keyrecord_t *record
|
||||
) {
|
||||
if (keycode == trigger) {
|
||||
if (record->event.pressed) {
|
||||
// Trigger keydown
|
||||
if (*state == os_up_unqueued) {
|
||||
register_code(mod);
|
||||
}
|
||||
*state = os_down_unused;
|
||||
dprintf("trigger down (on?), mod: %d, ? -> os_down_unused\n", mod);
|
||||
} else {
|
||||
// Trigger keyup
|
||||
switch (*state) {
|
||||
case os_down_unused:
|
||||
// If we didn't use the mod while trigger was held, queue it.
|
||||
*state = os_up_queued;
|
||||
dprintf("trigger up, mod: %d, os_down_unused -> os_up_queued\n", mod);
|
||||
break;
|
||||
case os_down_used:
|
||||
// If we did use the mod while trigger was held, unregister it.
|
||||
*state = os_up_unqueued;
|
||||
unregister_code(mod);
|
||||
dprintf("trigger up (off), mod: %d, os_down_used -> os_up_unqueued\n", mod);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (record->event.pressed) {
|
||||
if (is_oneshot_cancel_key(keycode) && *state != os_up_unqueued) {
|
||||
// Cancel oneshot on designated cancel keydown.
|
||||
*state = os_up_unqueued;
|
||||
unregister_code(mod);
|
||||
dprintf("cancel (off), mod: %d, ? -> os_up_unqueued\n", mod);
|
||||
}
|
||||
if (!is_oneshot_ignored_key(keycode)) {
|
||||
switch (*state) {
|
||||
case os_up_queued:
|
||||
*state = os_up_queued_used;
|
||||
dprintf("key up (off), mod: %d, os_up_queued -> os_up_queued_used\n", mod);
|
||||
break;
|
||||
case os_up_queued_used:
|
||||
*state = os_up_unqueued;
|
||||
unregister_code(mod);
|
||||
dprintf("key up (off), mod: %d, os_up_queued_used -> os_up_unqueued\n", mod);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!is_oneshot_ignored_key(keycode)) {
|
||||
// On non-ignored keyup, consider the oneshot used.
|
||||
switch (*state) {
|
||||
case os_down_unused:
|
||||
*state = os_down_used;
|
||||
dprintf("key up, mod: %d, os_down_unused -> os_down_used\n", mod);
|
||||
break;
|
||||
case os_up_queued:
|
||||
*state = os_up_unqueued;
|
||||
unregister_code(mod);
|
||||
dprintf("key up (off), mod: %d, os_up_queued -> os_up_unqueued\n", mod);
|
||||
break;
|
||||
case os_up_queued_used:
|
||||
*state = os_up_unqueued;
|
||||
unregister_code(mod);
|
||||
dprintf("key up (off), mod: %d, os_up_queued_used -> os_up_unqueued\n", mod);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool update_oneshot_layer(
|
||||
oneshot_state *state,
|
||||
uint16_t layer,
|
||||
uint16_t trigger,
|
||||
uint16_t keycode,
|
||||
keyrecord_t *record
|
||||
) {
|
||||
if (keycode == trigger) {
|
||||
if (record->event.pressed) {
|
||||
// Trigger keydown
|
||||
if (*state == os_up_unqueued) {
|
||||
layer_on(layer);
|
||||
}
|
||||
*state = os_down_unused;
|
||||
dprintf("trigger down (on?), layer: %d, ? -> os_down_unused\n", layer);
|
||||
return false;
|
||||
} else {
|
||||
// Trigger keyup
|
||||
switch (*state) {
|
||||
case os_down_unused:
|
||||
// If we didn't use the layer while trigger was held, queue it.
|
||||
*state = os_up_queued;
|
||||
dprintf("trigger up, layer: %d, os_down_unused -> os_up_queued\n", layer);
|
||||
return false;
|
||||
case os_down_used:
|
||||
// If we did use the layer while trigger was held, turn off it.
|
||||
*state = os_up_unqueued;
|
||||
layer_off(layer);
|
||||
dprintf("trigger up (off), layer: %d, os_down_used -> os_up_unqueued\n", layer);
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (record->event.pressed) {
|
||||
if (is_oneshot_layer_cancel_key(keycode) && *state != os_up_unqueued) {
|
||||
// Cancel oneshot layer on designated cancel keydown.
|
||||
*state = os_up_unqueued;
|
||||
layer_off(layer);
|
||||
dprintf("cancel (off), layer: %d, ? -> os_up_unqueued\n", layer);
|
||||
return false;
|
||||
}
|
||||
uint8_t key_layer = read_source_layers_cache(record->event.key);
|
||||
if (key_layer == layer) {
|
||||
// On non-ignored keyup, consider the oneshot used.
|
||||
switch (*state) {
|
||||
case os_down_unused:
|
||||
*state = os_down_used;
|
||||
dprintf("key down, layer: %d, os_down_unused -> os_down_used\n", layer);
|
||||
return true;
|
||||
case os_up_queued:
|
||||
if (is_oneshot_mod_key(keycode)) {
|
||||
*state = os_up_unqueued;
|
||||
layer_off(layer);
|
||||
dprintf("key down, layer: %d, os_up_queued -> os_up_unqueued\n", layer);
|
||||
return false;
|
||||
} else {
|
||||
*state = os_up_queued_used;
|
||||
dprintf("key down, layer: %d, os_up_queued -> os_up_queued_used\n", layer);
|
||||
}
|
||||
return true;
|
||||
case os_up_queued_used:
|
||||
*state = os_up_unqueued;
|
||||
layer_off(layer);
|
||||
dprintf("key down (off), layer: %d, os_up_queued_used -> os_up_unqueued\n", layer);
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Ignore key ups from other layers
|
||||
uint8_t key_layer = read_source_layers_cache(record->event.key);
|
||||
if (key_layer == layer) {
|
||||
// On non-ignored keyup, consider the oneshot used.
|
||||
switch (*state) {
|
||||
case os_up_queued:
|
||||
*state = os_up_unqueued;
|
||||
layer_off(layer);
|
||||
dprintf("key up (off), layer: %d, os_up_queued -> os_up_unqueued\n", layer);
|
||||
return true;
|
||||
case os_up_queued_used:
|
||||
*state = os_up_unqueued;
|
||||
layer_off(layer);
|
||||
dprintf("key up (off), layer: %d, os_up_queued_used -> os_up_unqueued\n", layer);
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
@@ -1,65 +0,0 @@
|
||||
/* Copyright 2021 @daliusd
|
||||
*
|
||||
* 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
|
||||
|
||||
#include QMK_KEYBOARD_H
|
||||
|
||||
// Represents the four states a oneshot key can be in
|
||||
typedef enum {
|
||||
os_up_unqueued,
|
||||
os_up_queued,
|
||||
os_up_queued_used,
|
||||
os_down_unused,
|
||||
os_down_used,
|
||||
} oneshot_state;
|
||||
|
||||
// Custom oneshot mod implementation that doesn't rely on timers. If a mod is
|
||||
// used while it is held it will be unregistered on keyup as normal, otherwise
|
||||
// it will be queued and only released after the next non-mod keyup.
|
||||
void update_oneshot(
|
||||
oneshot_state *state,
|
||||
uint16_t mod,
|
||||
uint16_t trigger,
|
||||
uint16_t keycode,
|
||||
keyrecord_t *record
|
||||
);
|
||||
|
||||
// Oneshot implementation for layers
|
||||
bool update_oneshot_layer(
|
||||
oneshot_state *state,
|
||||
uint16_t layer,
|
||||
uint16_t trigger,
|
||||
uint16_t keycode,
|
||||
keyrecord_t *record
|
||||
);
|
||||
|
||||
// To be implemented by the consumer. Layers one shot implementation needs to
|
||||
// know which keys are used as oneshot mods
|
||||
bool is_oneshot_mod_key(
|
||||
uint16_t keycode
|
||||
);
|
||||
|
||||
// To be implemented by the consumer. Defines keys to cancel oneshot mods.
|
||||
bool is_oneshot_cancel_key(uint16_t keycode);
|
||||
|
||||
// To be implemented by the consumer. Defines keys to cancel oneshot layers.
|
||||
bool is_oneshot_layer_cancel_key(uint16_t keycode);
|
||||
|
||||
// To be implemented by the consumer. Defines keys to ignore when determining
|
||||
// whether a oneshot mod has been used. Setting this to modifiers and layer
|
||||
// change keys allows stacking multiple oneshot modifiers, and carrying them
|
||||
// between layers.
|
||||
bool is_oneshot_ignored_key(uint16_t keycode);
|
File diff suppressed because it is too large
Load Diff
@@ -2,4 +2,4 @@ UNICODE_ENABLE = no
|
||||
UNICODEMAP_ENABLE = yes
|
||||
#CONSOLE_ENABLE = yes
|
||||
|
||||
SRC += oneshot.c
|
||||
SRC += flow.c
|
||||
|
Reference in New Issue
Block a user