Merge remote-tracking branch 'qmk/master' into merge-2023-06-03
This commit is contained in:
@@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "host.h"
|
||||
#include "keycode.h"
|
||||
#include "keyboard.h"
|
||||
#include "keymap.h"
|
||||
#include "mousekey.h"
|
||||
#include "programmable_button.h"
|
||||
#include "command.h"
|
||||
@@ -31,6 +30,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#include "wait.h"
|
||||
#include "qmk_settings.h"
|
||||
#include "keycode_config.h"
|
||||
#include "debug.h"
|
||||
#include "quantum.h"
|
||||
|
||||
#ifdef BACKLIGHT_ENABLE
|
||||
# include "backlight.h"
|
||||
@@ -40,6 +41,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
# include "pointing_device.h"
|
||||
#endif
|
||||
|
||||
#if defined(ENCODER_ENABLE) && defined(ENCODER_MAP_ENABLE) && defined(SWAP_HANDS_ENABLE)
|
||||
# include "encoder.h"
|
||||
#endif
|
||||
|
||||
int tp_buttons;
|
||||
|
||||
#if defined(RETRO_TAPPING) || defined(RETRO_TAPPING_PER_KEY) || (defined(AUTO_SHIFT_ENABLE) && defined(RETRO_SHIFT))
|
||||
@@ -62,10 +67,6 @@ __attribute__((weak)) bool get_retro_tapping(uint16_t keycode, keyrecord_t *reco
|
||||
}
|
||||
#endif
|
||||
|
||||
__attribute__((weak)) bool pre_process_record_quantum(keyrecord_t *record) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** \brief Called to execute an action.
|
||||
*
|
||||
* FIXME: Needs documentation.
|
||||
@@ -162,6 +163,18 @@ void set_swap_hands_state(size_t index, uint8_t *swap_state, bool on) {
|
||||
}
|
||||
}
|
||||
|
||||
void swap_hands_on(void) {
|
||||
swap_hands = true;
|
||||
}
|
||||
|
||||
void swap_hands_off(void) {
|
||||
swap_hands = false;
|
||||
}
|
||||
|
||||
void swap_hands_toggle(void) {
|
||||
swap_hands = !swap_hands;
|
||||
}
|
||||
|
||||
bool is_swap_hands_on(void) {
|
||||
return swap_hands;
|
||||
}
|
||||
@@ -172,7 +185,7 @@ bool is_swap_hands_on(void) {
|
||||
*/
|
||||
void process_hand_swap(keyevent_t *event) {
|
||||
keypos_t pos = event->key;
|
||||
if (pos.row < MATRIX_ROWS && pos.col < MATRIX_COLS) {
|
||||
if (IS_KEYEVENT(*event) && pos.row < MATRIX_ROWS && pos.col < MATRIX_COLS) {
|
||||
static uint8_t matrix_swap_state[((MATRIX_ROWS * MATRIX_COLS) + (CHAR_BIT)-1) / (CHAR_BIT)];
|
||||
size_t index = (size_t)(pos.row * MATRIX_COLS) + pos.col;
|
||||
bool do_swap = should_swap_hands(index, matrix_swap_state, event->pressed);
|
||||
@@ -185,7 +198,7 @@ void process_hand_swap(keyevent_t *event) {
|
||||
}
|
||||
}
|
||||
# ifdef ENCODER_MAP_ENABLE
|
||||
else if (pos.row == KEYLOC_ENCODER_CW || pos.row == KEYLOC_ENCODER_CCW) {
|
||||
else if (IS_ENCODEREVENT(*event) && (pos.row == KEYLOC_ENCODER_CW || pos.row == KEYLOC_ENCODER_CCW)) {
|
||||
static uint8_t encoder_swap_state[((NUM_ENCODERS) + (CHAR_BIT)-1) / (CHAR_BIT)];
|
||||
size_t index = pos.col;
|
||||
bool do_swap = should_swap_hands(index, encoder_swap_state, event->pressed);
|
||||
@@ -227,6 +240,10 @@ __attribute__((weak)) void post_process_record_quantum(keyrecord_t *record) {}
|
||||
* FIXME: Needs documentation.
|
||||
*/
|
||||
void process_record_tap_hint(keyrecord_t *record) {
|
||||
if (!IS_KEYEVENT(record->event)) {
|
||||
return;
|
||||
}
|
||||
|
||||
action_t action = layer_switch_get_action(record->event.key);
|
||||
|
||||
switch (action.kind.id) {
|
||||
@@ -269,7 +286,7 @@ void process_record(keyrecord_t *record) {
|
||||
}
|
||||
|
||||
void process_record_handler(keyrecord_t *record) {
|
||||
#ifdef COMBO_ENABLE
|
||||
#if defined(COMBO_ENABLE) || defined(REPEAT_KEY_ENABLE)
|
||||
action_t action;
|
||||
if (record->keycode) {
|
||||
action = action_for_keycode(record->keycode);
|
||||
@@ -436,37 +453,28 @@ void process_action(keyrecord_t *record, action_t action) {
|
||||
} else {
|
||||
if (event.pressed) {
|
||||
if (tap_count == 0) {
|
||||
// Not a tap, but a hold: register the held mod
|
||||
ac_dprintf("MODS_TAP: Oneshot: 0\n");
|
||||
register_mods(mods | get_oneshot_mods());
|
||||
register_mods(mods);
|
||||
} else if (tap_count == 1) {
|
||||
ac_dprintf("MODS_TAP: Oneshot: start\n");
|
||||
set_oneshot_mods(mods | get_oneshot_mods());
|
||||
add_oneshot_mods(mods);
|
||||
} else if (QS_oneshot_tap_toggle > 1 && tap_count == QS_oneshot_tap_toggle) {
|
||||
ac_dprintf("MODS_TAP: Toggling oneshot");
|
||||
register_mods(mods);
|
||||
clear_oneshot_mods();
|
||||
set_oneshot_locked_mods(mods | get_oneshot_locked_mods());
|
||||
} else {
|
||||
register_mods(mods | get_oneshot_mods());
|
||||
del_oneshot_mods(mods);
|
||||
add_oneshot_locked_mods(mods);
|
||||
}
|
||||
} else {
|
||||
if (tap_count == 0) {
|
||||
clear_oneshot_mods();
|
||||
// Release hold: unregister the held mod and its variants
|
||||
unregister_mods(mods);
|
||||
} else if (tap_count == 1) {
|
||||
// Retain Oneshot mods
|
||||
if (QS_oneshot_tap_toggle > 1) {
|
||||
if (mods & get_mods()) {
|
||||
unregister_mods(mods);
|
||||
clear_oneshot_mods();
|
||||
set_oneshot_locked_mods(~mods & get_oneshot_locked_mods());
|
||||
}
|
||||
}
|
||||
} else if (QS_oneshot_tap_toggle > 1 && tap_count == QS_oneshot_tap_toggle) {
|
||||
// Toggle Oneshot Layer
|
||||
} else {
|
||||
del_oneshot_mods(mods);
|
||||
del_oneshot_locked_mods(mods);
|
||||
} else if (QS_oneshot_tap_toggle > 1 && tap_count == 1 && (mods & get_mods())) {
|
||||
unregister_mods(mods);
|
||||
clear_oneshot_mods();
|
||||
del_oneshot_mods(mods);
|
||||
del_oneshot_locked_mods(mods);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -486,7 +494,7 @@ if (QS_oneshot_tap_toggle > 1) {
|
||||
default:
|
||||
if (event.pressed) {
|
||||
if (tap_count > 0) {
|
||||
# if !defined(IGNORE_MOD_TAP_INTERRUPT) || defined(HOLD_ON_OTHER_KEY_PRESS_PER_KEY)
|
||||
# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
|
||||
if (
|
||||
# ifdef HOLD_ON_OTHER_KEY_PRESS_PER_KEY
|
||||
get_hold_on_other_key_press(get_event_keycode(record->event, false), record) &&
|
||||
@@ -1098,7 +1106,7 @@ bool is_tap_record(keyrecord_t *record) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef COMBO_ENABLE
|
||||
#if defined(COMBO_ENABLE) || defined(REPEAT_KEY_ENABLE)
|
||||
action_t action;
|
||||
if (record->keycode) {
|
||||
action = action_for_keycode(record->keycode);
|
||||
|
||||
Reference in New Issue
Block a user