diff options
author | innovaker <66737976+innovaker@users.noreply.github.com> | 2020-12-02 16:41:57 +0000 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2020-12-14 12:41:25 -0500 |
commit | bac1f17cf6ce225876dc7b6b2a809bcd98010391 (patch) | |
tree | 9783743b31fdadd66d1b3c9e5a3e14dc661ec313 /app/src/behaviors | |
parent | a4652fa25da83ae036613157fb566eb1ce1426fe (diff) |
refactor(app): replace Zephyr integer types with C99 integer types
u8_t → uint8_t
u16_t → uint16_t
u32_t → uint32_t
u64_t → uint64_t
s8_t → int8_t
s16_t → int16_t
s32_t → int32_t
s64_t → int64_t
Prerequisite for #223
See: https://github.com/zephyrproject-rtos/zephyr/releases/tag/zephyr-v2.4.0
PR: #467
Diffstat (limited to 'app/src/behaviors')
-rw-r--r-- | app/src/behaviors/behavior_hold_tap.c | 18 | ||||
-rw-r--r-- | app/src/behaviors/behavior_sensor_rotate_key_press.c | 4 | ||||
-rw-r--r-- | app/src/behaviors/behavior_sticky_key.c | 26 |
3 files changed, 25 insertions, 23 deletions
diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 1dc665d..50a9606 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -49,11 +49,11 @@ struct behavior_hold_tap_config { // this data is specific for each hold-tap struct active_hold_tap { - s32_t position; + int32_t position; // todo: move these params into the config->behaviors->tap and - u32_t param_hold; - u32_t param_tap; - s64_t timestamp; + uint32_t param_hold; + uint32_t param_tap; + int64_t timestamp; bool is_decided; bool is_hold; const struct behavior_hold_tap_config *config; @@ -81,7 +81,7 @@ static int capture_event(const struct zmk_event_header *event) { return -ENOMEM; } -static struct position_state_changed *find_captured_keydown_event(u32_t position) { +static struct position_state_changed *find_captured_keydown_event(uint32_t position) { struct position_state_changed *last_match = NULL; for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_CAPTURED_EVENTS; i++) { const struct zmk_event_header *eh = captured_events[i]; @@ -155,7 +155,7 @@ static void release_captured_events() { } } -static struct active_hold_tap *find_hold_tap(u32_t position) { +static struct active_hold_tap *find_hold_tap(uint32_t position) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { if (active_hold_taps[i].position == position) { return &active_hold_taps[i]; @@ -164,8 +164,8 @@ static struct active_hold_tap *find_hold_tap(u32_t position) { return NULL; } -static struct active_hold_tap *store_hold_tap(u32_t position, u32_t param_hold, u32_t param_tap, - s64_t timestamp, +static struct active_hold_tap *store_hold_tap(uint32_t position, uint32_t param_hold, + uint32_t param_tap, int64_t timestamp, const struct behavior_hold_tap_config *config) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { if (active_hold_taps[i].position != ZMK_BHV_HOLD_TAP_POSITION_NOT_USED) { @@ -326,7 +326,7 @@ static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding, // if this behavior was queued we have to adjust the timer to only // wait for the remaining time. - s32_t tapping_term_ms_left = (hold_tap->timestamp + cfg->tapping_term_ms) - k_uptime_get(); + int32_t tapping_term_ms_left = (hold_tap->timestamp + cfg->tapping_term_ms) - k_uptime_get(); if (tapping_term_ms_left > 0) { k_delayed_work_submit(&hold_tap->work, K_MSEC(tapping_term_ms_left)); } diff --git a/app/src/behaviors/behavior_sensor_rotate_key_press.c b/app/src/behaviors/behavior_sensor_rotate_key_press.c index 199ece2..85af24a 100644 --- a/app/src/behaviors/behavior_sensor_rotate_key_press.c +++ b/app/src/behaviors/behavior_sensor_rotate_key_press.c @@ -19,10 +19,10 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static int behavior_sensor_rotate_key_press_init(struct device *dev) { return 0; }; static int on_sensor_binding_triggered(struct zmk_behavior_binding *binding, struct device *sensor, - s64_t timestamp) { + int64_t timestamp) { struct sensor_value value; int err; - u32_t keycode; + uint32_t keycode; LOG_DBG("inc keycode 0x%02X dec keycode 0x%02X", binding->param1, binding->param2); err = sensor_channel_get(sensor, SENSOR_CHAN_ROTATION, &value); diff --git a/app/src/behaviors/behavior_sticky_key.c b/app/src/behaviors/behavior_sticky_key.c index 3ea5868..b676e16 100644 --- a/app/src/behaviors/behavior_sticky_key.c +++ b/app/src/behaviors/behavior_sticky_key.c @@ -29,28 +29,29 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #define ZMK_BHV_STICKY_KEY_POSITION_NOT_USED ULONG_MAX struct behavior_sticky_key_config { - u32_t release_after_ms; + uint32_t release_after_ms; struct zmk_behavior_binding behavior; }; struct active_sticky_key { - u32_t position; - u32_t param1; - u32_t param2; + uint32_t position; + uint32_t param1; + uint32_t param2; const struct behavior_sticky_key_config *config; // timer data. bool timer_started; - s64_t release_at; + int64_t release_at; struct k_delayed_work release_timer; bool timer_is_cancelled; // usage page and keycode for the key that is being modified by this sticky key - u8_t modified_key_usage_page; - u32_t modified_key_keycode; + uint8_t modified_key_usage_page; + uint32_t modified_key_keycode; }; struct active_sticky_key active_sticky_keys[ZMK_BHV_STICKY_KEY_MAX_HELD] = {}; -static struct active_sticky_key *store_sticky_key(u32_t position, u32_t param1, u32_t param2, +static struct active_sticky_key *store_sticky_key(uint32_t position, uint32_t param1, + uint32_t param2, const struct behavior_sticky_key_config *config) { for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) { if (active_sticky_keys[i].position != ZMK_BHV_STICKY_KEY_POSITION_NOT_USED || @@ -75,7 +76,7 @@ static void clear_sticky_key(struct active_sticky_key *sticky_key) { sticky_key->position = ZMK_BHV_STICKY_KEY_POSITION_NOT_USED; } -static struct active_sticky_key *find_sticky_key(u32_t position) { +static struct active_sticky_key *find_sticky_key(uint32_t position) { for (int i = 0; i < ZMK_BHV_STICKY_KEY_MAX_HELD; i++) { if (active_sticky_keys[i].position == position && !active_sticky_keys[i].timer_is_cancelled) { @@ -85,7 +86,8 @@ static struct active_sticky_key *find_sticky_key(u32_t position) { return NULL; } -static inline int press_sticky_key_behavior(struct active_sticky_key *sticky_key, s64_t timestamp) { +static inline int press_sticky_key_behavior(struct active_sticky_key *sticky_key, + int64_t timestamp) { struct zmk_behavior_binding binding = { .behavior_dev = sticky_key->config->behavior.behavior_dev, .param1 = sticky_key->param1, @@ -99,7 +101,7 @@ static inline int press_sticky_key_behavior(struct active_sticky_key *sticky_key } static inline int release_sticky_key_behavior(struct active_sticky_key *sticky_key, - s64_t timestamp) { + int64_t timestamp) { struct zmk_behavior_binding binding = { .behavior_dev = sticky_key->config->behavior.behavior_dev, .param1 = sticky_key->param1, @@ -162,7 +164,7 @@ static int on_sticky_key_binding_released(struct zmk_behavior_binding *binding, sticky_key->timer_started = true; sticky_key->release_at = event.timestamp + sticky_key->config->release_after_ms; // adjust timer in case this behavior was queued by a hold-tap - s32_t ms_left = sticky_key->release_at - k_uptime_get(); + int32_t ms_left = sticky_key->release_at - k_uptime_get(); if (ms_left > 0) { k_delayed_work_submit(&sticky_key->release_timer, K_MSEC(ms_left)); } |