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