2021-12-30 10:17:34 +06:00
|
|
|
// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2017-11-18 01:59:54 +06:00
|
|
|
|
2017-11-07 11:11:08 +06:00
|
|
|
#include "drashna.h"
|
|
|
|
|
2018-05-02 21:39:46 +06:00
|
|
|
userspace_config_t userspace_config;
|
|
|
|
|
2019-07-23 09:22:33 +06:00
|
|
|
bool mod_key_press_timer(uint16_t code, uint16_t mod_code, bool pressed) {
|
2019-05-07 11:34:09 +06:00
|
|
|
static uint16_t this_timer;
|
2019-07-23 09:22:33 +06:00
|
|
|
if (pressed) {
|
|
|
|
this_timer = timer_read();
|
2019-05-07 11:34:09 +06:00
|
|
|
} else {
|
2019-07-23 09:22:33 +06:00
|
|
|
if (timer_elapsed(this_timer) < TAPPING_TERM) {
|
2019-05-07 11:34:09 +06:00
|
|
|
tap_code(code);
|
|
|
|
} else {
|
|
|
|
register_code(mod_code);
|
|
|
|
tap_code(code);
|
|
|
|
unregister_code(mod_code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2018-07-17 07:04:32 +06:00
|
|
|
}
|
|
|
|
|
2019-07-23 09:22:33 +06:00
|
|
|
bool mod_key_press(uint16_t code, uint16_t mod_code, bool pressed, uint16_t this_timer) {
|
|
|
|
if (pressed) {
|
|
|
|
this_timer = timer_read();
|
2019-05-07 11:34:09 +06:00
|
|
|
} else {
|
2019-07-23 09:22:33 +06:00
|
|
|
if (timer_elapsed(this_timer) < TAPPING_TERM) {
|
2019-05-07 11:34:09 +06:00
|
|
|
tap_code(code);
|
|
|
|
} else {
|
|
|
|
register_code(mod_code);
|
|
|
|
tap_code(code);
|
|
|
|
unregister_code(mod_code);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
2018-07-17 07:04:32 +06:00
|
|
|
}
|
2017-11-18 01:59:54 +06:00
|
|
|
|
2019-10-17 02:11:22 +06:00
|
|
|
bool hasAllBitsInMask(uint8_t value, uint8_t mask) {
|
|
|
|
value &= 0xF;
|
|
|
|
mask &= 0xF;
|
|
|
|
|
|
|
|
return (value & mask) == mask;
|
|
|
|
}
|
2021-08-22 02:34:44 +06:00
|
|
|
|
2021-12-30 10:17:34 +06:00
|
|
|
void tap_code16_nomods(uint8_t kc) {
|
|
|
|
uint8_t temp_mod = get_mods();
|
|
|
|
clear_mods();
|
|
|
|
clear_oneshot_mods();
|
|
|
|
tap_code16(kc);
|
|
|
|
set_mods(temp_mod);
|
2021-11-10 20:10:00 +06:00
|
|
|
}
|