diff options
author | Pete Johanson <peter@peterjohanson.com> | 2020-06-25 14:39:08 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-25 14:39:08 -0400 |
commit | c457d9880d31bf638272495be1891adf172bcaee (patch) | |
tree | 51d57bfea704c616ef9357bfba9bffcaf113d062 /app/src/behaviors/behavior_reset.c | |
parent | b1cab32c66d19d453b89fcec6f4211367e45827a (diff) | |
parent | f2f9d4502122a332aa6f35ac87d9f6b5e3ff7335 (diff) |
Merge pull request #32 from petejohanson/core/refactor-keymap-to-behaviors
Refactor keymap to behaviors
Diffstat (limited to 'app/src/behaviors/behavior_reset.c')
-rw-r--r-- | app/src/behaviors/behavior_reset.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/app/src/behaviors/behavior_reset.c b/app/src/behaviors/behavior_reset.c new file mode 100644 index 0000000..44cbc21 --- /dev/null +++ b/app/src/behaviors/behavior_reset.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2020 Peter Johanson <peter@peterjohanson.com> + * + * 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 { }; +struct behavior_reset_data { }; + +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) +{ + // TODO: Correct magic code for going into DFU? + // See https://github.com/adafruit/Adafruit_nRF52_Bootloader/blob/d6b28e66053eea467166f44875e3c7ec741cb471/src/main.c#L107 + sys_reboot(0); + return 0; +} + +static const struct behavior_driver_api behavior_reset_driver_api = { + .binding_pressed = on_keymap_binding_pressed, +}; + + +static const struct behavior_reset_config behavior_reset_config = {}; + +static struct behavior_reset_data behavior_reset_data; + +DEVICE_AND_API_INIT(behavior_reset, DT_INST_LABEL(0), behavior_reset_init, + &behavior_reset_data, + &behavior_reset_config, + APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, + &behavior_reset_driver_api);
\ No newline at end of file |