- Take original event timestamps into consideration so nested tap-holds have proper timing. - Add position and timestamp to keycode state changed event so the one-shot behavior can properly identify other keypresses and timings. - Add timestamp to position events received from peripheral
44 lines
No EOL
1.6 KiB
C
44 lines
No EOL
1.6 KiB
C
/*
|
|
* Copyright (c) 2020 The ZMK Contributors
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#define DT_DRV_COMPAT zmk_behavior_reset
|
|
|
|
#include <device.h>
|
|
#include <power/reboot.h>
|
|
#include <drivers/behavior.h>
|
|
#include <logging/log.h>
|
|
|
|
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
|
|
|
struct behavior_reset_config {
|
|
int type;
|
|
};
|
|
|
|
static int behavior_reset_init(struct device *dev) { return 0; };
|
|
|
|
static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1,
|
|
u32_t _param2, s64_t _timestamp) {
|
|
const struct behavior_reset_config *cfg = dev->config_info;
|
|
|
|
// TODO: Correct magic code for going into DFU?
|
|
// See
|
|
// https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107
|
|
sys_reboot(cfg->type);
|
|
return 0;
|
|
}
|
|
|
|
static const struct behavior_driver_api behavior_reset_driver_api = {
|
|
.binding_pressed = on_keymap_binding_pressed,
|
|
};
|
|
|
|
#define RST_INST(n) \
|
|
static const struct behavior_reset_config behavior_reset_config_##n = { \
|
|
.type = DT_INST_PROP(n, type)}; \
|
|
DEVICE_AND_API_INIT(behavior_reset_##n, DT_INST_LABEL(n), behavior_reset_init, NULL, \
|
|
&behavior_reset_config_##n, APPLICATION, \
|
|
CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_reset_driver_api);
|
|
|
|
DT_INST_FOREACH_STATUS_OKAY(RST_INST) |