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/keymap.c | |
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/keymap.c')
-rw-r--r-- | app/src/keymap.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/app/src/keymap.c b/app/src/keymap.c index 08115a1..0dc7c1a 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include <zmk/events/sensor-event.h> static zmk_keymap_layers_state _zmk_keymap_layer_state = 0; -static u8_t _zmk_keymap_layer_default = 0; +static uint8_t _zmk_keymap_layer_default = 0; #define DT_DRV_COMPAT zmk_keymap @@ -64,7 +64,7 @@ static u8_t _zmk_keymap_layer_default = 0; // When a behavior handles a key position "down" event, we record the layer state // here so that even if that layer is deactivated before the "up", event, we // still send the release event to the behavior in that layer also. -static u32_t zmk_keymap_active_behavior_layer[ZMK_KEYMAP_LEN]; +static uint32_t zmk_keymap_active_behavior_layer[ZMK_KEYMAP_LEN]; static struct zmk_behavior_binding zmk_keymap[ZMK_KEYMAP_LAYERS_LEN][ZMK_KEYMAP_LEN] = { DT_INST_FOREACH_CHILD(0, TRANSFORMED_LAYER)}; @@ -77,7 +77,7 @@ static struct zmk_behavior_binding zmk_sensor_keymap[ZMK_KEYMAP_LAYERS_LEN] #endif /* ZMK_KEYMAP_HAS_SENSORS */ -static inline int set_layer_state(u8_t layer, bool state) { +static inline int set_layer_state(uint8_t layer, bool state) { if (layer >= 32) { return -EINVAL; } @@ -86,16 +86,16 @@ static inline int set_layer_state(u8_t layer, bool state) { return 0; } -u8_t zmk_keymap_layer_default() { return _zmk_keymap_layer_default; } +uint8_t zmk_keymap_layer_default() { return _zmk_keymap_layer_default; } zmk_keymap_layers_state zmk_keymap_layer_state() { return _zmk_keymap_layer_state; } -bool zmk_keymap_layer_active(u8_t layer) { +bool zmk_keymap_layer_active(uint8_t layer) { return (_zmk_keymap_layer_state & (BIT(layer))) == (BIT(layer)); }; -u8_t zmk_keymap_highest_layer_active() { - for (u8_t layer = 31; layer > 0; layer--) { +uint8_t zmk_keymap_highest_layer_active() { + for (uint8_t layer = 31; layer > 0; layer--) { if (zmk_keymap_layer_active(layer)) { return layer; } @@ -103,11 +103,11 @@ u8_t zmk_keymap_highest_layer_active() { return zmk_keymap_layer_default(); } -int zmk_keymap_layer_activate(u8_t layer) { return set_layer_state(layer, true); }; +int zmk_keymap_layer_activate(uint8_t layer) { return set_layer_state(layer, true); }; -int zmk_keymap_layer_deactivate(u8_t layer) { return set_layer_state(layer, false); }; +int zmk_keymap_layer_deactivate(uint8_t layer) { return set_layer_state(layer, false); }; -int zmk_keymap_layer_toggle(u8_t layer) { +int zmk_keymap_layer_toggle(uint8_t layer) { if (zmk_keymap_layer_active(layer)) { return zmk_keymap_layer_deactivate(layer); } @@ -115,11 +115,11 @@ int zmk_keymap_layer_toggle(u8_t layer) { return zmk_keymap_layer_activate(layer); }; -bool is_active_layer(u8_t layer, zmk_keymap_layers_state layer_state) { +bool is_active_layer(uint8_t layer, zmk_keymap_layers_state layer_state) { return (layer_state & BIT(layer)) == BIT(layer) || layer == _zmk_keymap_layer_default; } -int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed, s64_t timestamp) { +int zmk_keymap_apply_position_state(int layer, uint32_t position, bool pressed, int64_t timestamp) { struct zmk_behavior_binding *binding = &zmk_keymap[layer][position]; struct device *behavior; struct zmk_behavior_binding_event event = { @@ -145,7 +145,7 @@ int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed, s64 } } -int zmk_keymap_position_state_changed(u32_t position, bool pressed, s64_t timestamp) { +int zmk_keymap_position_state_changed(uint32_t position, bool pressed, int64_t timestamp) { if (pressed) { zmk_keymap_active_behavior_layer[position] = _zmk_keymap_layer_state; } @@ -168,7 +168,7 @@ int zmk_keymap_position_state_changed(u32_t position, bool pressed, s64_t timest } #if ZMK_KEYMAP_HAS_SENSORS -int zmk_keymap_sensor_triggered(u8_t sensor_number, struct device *sensor, s64_t timestamp) { +int zmk_keymap_sensor_triggered(uint8_t sensor_number, struct device *sensor, int64_t timestamp) { for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= _zmk_keymap_layer_default; layer--) { if (((_zmk_keymap_layer_state & BIT(layer)) == BIT(layer) || layer == _zmk_keymap_layer_default) && |