From bac1f17cf6ce225876dc7b6b2a809bcd98010391 Mon Sep 17 00:00:00 2001 From: innovaker <66737976+innovaker@users.noreply.github.com> Date: Wed, 2 Dec 2020 16:41:57 +0000 Subject: [PATCH] refactor(app): replace Zephyr integer types with C99 integer types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- app/drivers/kscan/kscan_composite.c | 6 ++-- app/drivers/kscan/kscan_gpio_demux.c | 4 +-- app/drivers/kscan/kscan_gpio_direct.c | 12 +++---- app/drivers/kscan/kscan_gpio_matrix.c | 4 +-- app/drivers/kscan/kscan_mock.c | 8 ++--- app/drivers/sensor/ec11/ec11.c | 4 +-- app/drivers/sensor/ec11/ec11.h | 18 +++++----- app/drivers/sensor/ec11/ec11_trigger.c | 4 +-- app/include/drivers/behavior.h | 6 ++-- app/include/zmk/behavior.h | 8 ++--- app/include/zmk/ble.h | 2 +- app/include/zmk/endpoints.h | 2 +- app/include/zmk/event-manager.h | 2 +- .../zmk/events/battery-state-changed.h | 2 +- .../zmk/events/ble-active-profile-changed.h | 2 +- .../zmk/events/keycode-state-changed.h | 14 ++++---- app/include/zmk/events/layer-state-changed.h | 6 ++-- .../zmk/events/position-state-changed.h | 4 +-- app/include/zmk/events/sensor-event.h | 4 +-- app/include/zmk/hid.h | 18 +++++----- app/include/zmk/keymap.h | 16 ++++----- app/include/zmk/keys.h | 12 +++---- app/include/zmk/matrix_transform.h | 2 +- app/include/zmk/split/bluetooth/service.h | 4 +-- app/include/zmk/usb.h | 2 +- app/src/behaviors/behavior_hold_tap.c | 18 +++++----- .../behavior_sensor_rotate_key_press.c | 4 +-- app/src/behaviors/behavior_sticky_key.c | 26 +++++++------- app/src/ble.c | 20 +++++------ app/src/display/widgets/battery_status.c | 2 +- app/src/display/widgets/output_status.c | 2 +- app/src/endpoints.c | 6 ++-- app/src/event_manager.c | 8 ++--- app/src/ext_power_generic.c | 4 +-- app/src/hid_listener.c | 4 +-- app/src/hog.c | 34 +++++++++---------- app/src/keymap.c | 28 +++++++-------- app/src/kscan.c | 10 +++--- app/src/matrix_transform.c | 6 ++-- app/src/power.c | 6 ++-- app/src/rgb_underglow.c | 20 +++++------ app/src/sensors.c | 4 +-- app/src/split/bluetooth/central.c | 25 +++++++------- app/src/split/bluetooth/service.c | 16 ++++----- app/src/usb.c | 4 +-- 45 files changed, 208 insertions(+), 205 deletions(-) diff --git a/app/drivers/kscan/kscan_composite.c b/app/drivers/kscan/kscan_composite.c index f8e8d604..86ccaad8 100644 --- a/app/drivers/kscan/kscan_composite.c +++ b/app/drivers/kscan/kscan_composite.c @@ -17,8 +17,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct kscan_composite_child_config { char *label; - u8_t row_offset; - u8_t column_offset; + uint8_t row_offset; + uint8_t column_offset; }; #define CHILD_CONFIG(inst) \ @@ -55,7 +55,7 @@ static int kscan_composite_disable_callback(struct device *dev) { return 0; } -static void kscan_composite_child_callback(struct device *child_dev, u32_t row, u32_t column, +static void kscan_composite_child_callback(struct device *child_dev, uint32_t row, uint32_t column, bool pressed) { // TODO: Ideally we can get this passed into our callback! struct device *dev = device_get_binding(DT_INST_LABEL(0)); diff --git a/app/drivers/kscan/kscan_gpio_demux.c b/app/drivers/kscan/kscan_gpio_demux.c index 6113d7c4..44abca48 100644 --- a/app/drivers/kscan/kscan_gpio_demux.c +++ b/app/drivers/kscan/kscan_gpio_demux.c @@ -105,8 +105,8 @@ struct kscan_gpio_item_config { static bool read_state[INST_MATRIX_INPUTS(n)][INST_MATRIX_OUTPUTS(n)]; \ for (int o = 0; o < INST_MATRIX_OUTPUTS(n); o++) { \ /* Iterate over bits and set GPIOs accordingly */ \ - for (u8_t bit = 0; bit < INST_DEMUX_GPIOS(n); bit++) { \ - u8_t state = (o & (0b1 << bit)) >> bit; \ + for (uint8_t bit = 0; bit < INST_DEMUX_GPIOS(n); bit++) { \ + uint8_t state = (o & (0b1 << bit)) >> bit; \ struct device *out_dev = kscan_gpio_output_devices_##n(dev)[bit]; \ const struct kscan_gpio_item_config *out_cfg = \ &kscan_gpio_output_configs_##n(dev)[bit]; \ diff --git a/app/drivers/kscan/kscan_gpio_direct.c b/app/drivers/kscan/kscan_gpio_direct.c index 83271619..6df68cd2 100644 --- a/app/drivers/kscan/kscan_gpio_direct.c +++ b/app/drivers/kscan/kscan_gpio_direct.c @@ -27,8 +27,8 @@ union work_reference { }; struct kscan_gpio_config { - u8_t num_of_inputs; - u8_t debounce_period; + uint8_t num_of_inputs; + uint8_t debounce_period; struct kscan_gpio_item_config inputs[]; }; @@ -39,7 +39,7 @@ struct kscan_gpio_data { kscan_callback_t callback; union work_reference work; struct device *dev; - u32_t pin_state; + uint32_t pin_state; struct device *inputs[]; }; @@ -53,7 +53,7 @@ static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct devi return cfg->inputs; } -static void kscan_gpio_direct_queue_read(union work_reference *work, u8_t debounce_period) { +static void kscan_gpio_direct_queue_read(union work_reference *work, uint8_t debounce_period) { if (debounce_period > 0) { k_delayed_work_cancel(&work->delayed); k_delayed_work_submit(&work->delayed, K_MSEC(debounce_period)); @@ -67,7 +67,7 @@ static void kscan_gpio_direct_queue_read(union work_reference *work, u8_t deboun struct kscan_gpio_irq_callback { struct device *dev; union work_reference *work; - u8_t debounce_period; + uint8_t debounce_period; struct gpio_callback callback; }; @@ -140,7 +140,7 @@ static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t call static int kscan_gpio_read(struct device *dev) { struct kscan_gpio_data *data = dev->driver_data; const struct kscan_gpio_config *cfg = dev->config_info; - u32_t read_state = data->pin_state; + uint32_t read_state = data->pin_state; bool submit_follow_up_read = false; for (int i = 0; i < cfg->num_of_inputs; i++) { struct device *in_dev = kscan_gpio_input_devices(dev)[i]; diff --git a/app/drivers/kscan/kscan_gpio_matrix.c b/app/drivers/kscan/kscan_gpio_matrix.c index ec4fb39a..9887a286 100644 --- a/app/drivers/kscan/kscan_gpio_matrix.c +++ b/app/drivers/kscan/kscan_gpio_matrix.c @@ -123,8 +123,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ } \ static void kscan_gpio_set_matrix_state_##n( \ - bool state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)], u32_t input_index, \ - u32_t output_index, bool value) { \ + bool state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)], uint32_t input_index, \ + uint32_t output_index, bool value) { \ state[COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (output_index), \ (input_index))] \ [COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (input_index), \ diff --git a/app/drivers/kscan/kscan_mock.c b/app/drivers/kscan/kscan_mock.c index f1614f1f..b1454fec 100644 --- a/app/drivers/kscan/kscan_mock.c +++ b/app/drivers/kscan/kscan_mock.c @@ -18,7 +18,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct kscan_mock_data { kscan_callback_t callback; - u32_t event_index; + uint32_t event_index; struct k_delayed_work work; struct device *dev; }; @@ -45,14 +45,14 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) { #define MOCK_INST_INIT(n) \ struct kscan_mock_config_##n { \ - u32_t events[DT_INST_PROP_LEN(n, events)]; \ + uint32_t events[DT_INST_PROP_LEN(n, events)]; \ bool exit_after; \ }; \ static void kscan_mock_schedule_next_event_##n(struct device *dev) { \ struct kscan_mock_data *data = dev->driver_data; \ const struct kscan_mock_config_##n *cfg = dev->config_info; \ if (data->event_index < DT_INST_PROP_LEN(n, events)) { \ - u32_t ev = cfg->events[data->event_index]; \ + uint32_t ev = cfg->events[data->event_index]; \ LOG_DBG("delaying next keypress: %d", ZMK_MOCK_MSEC(ev)); \ k_delayed_work_submit(&data->work, K_MSEC(ZMK_MOCK_MSEC(ev))); \ } else if (cfg->exit_after) { \ @@ -63,7 +63,7 @@ static int kscan_mock_configure(struct device *dev, kscan_callback_t callback) { static void kscan_mock_work_handler_##n(struct k_work *work) { \ struct kscan_mock_data *data = CONTAINER_OF(work, struct kscan_mock_data, work); \ const struct kscan_mock_config_##n *cfg = data->dev->config_info; \ - u32_t ev = cfg->events[data->event_index]; \ + uint32_t ev = cfg->events[data->event_index]; \ LOG_DBG("ev %u row %d column %d state %d\n", ev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), \ ZMK_MOCK_IS_PRESS(ev)); \ data->callback(data->dev, ZMK_MOCK_ROW(ev), ZMK_MOCK_COL(ev), ZMK_MOCK_IS_PRESS(ev)); \ diff --git a/app/drivers/sensor/ec11/ec11.c b/app/drivers/sensor/ec11/ec11.c index 00d00905..bcdf8af8 100644 --- a/app/drivers/sensor/ec11/ec11.c +++ b/app/drivers/sensor/ec11/ec11.c @@ -29,8 +29,8 @@ static int ec11_get_ab_state(struct device *dev) { static int ec11_sample_fetch(struct device *dev, enum sensor_channel chan) { struct ec11_data *drv_data = dev->driver_data; const struct ec11_config *drv_cfg = dev->config_info; - u8_t val; - s8_t delta; + uint8_t val; + int8_t delta; __ASSERT_NO_MSG(chan == SENSOR_CHAN_ALL || chan == SENSOR_CHAN_ROTATION); diff --git a/app/drivers/sensor/ec11/ec11.h b/app/drivers/sensor/ec11/ec11.h index e62e7333..029f66b2 100644 --- a/app/drivers/sensor/ec11/ec11.h +++ b/app/drivers/sensor/ec11/ec11.h @@ -12,23 +12,23 @@ struct ec11_config { const char *a_label; - const u8_t a_pin; - const u8_t a_flags; + const uint8_t a_pin; + const uint8_t a_flags; const char *b_label; - const u8_t b_pin; - const u8_t b_flags; + const uint8_t b_pin; + const uint8_t b_flags; - const u8_t resolution; + const uint8_t resolution; }; struct ec11_data { struct device *a; struct device *b; - u8_t ab_state; - s8_t pulses; - s8_t ticks; - s8_t delta; + uint8_t ab_state; + int8_t pulses; + int8_t ticks; + int8_t delta; #ifdef CONFIG_EC11_TRIGGER struct gpio_callback a_gpio_cb; diff --git a/app/drivers/sensor/ec11/ec11_trigger.c b/app/drivers/sensor/ec11/ec11_trigger.c index 248ac320..c8b8ca1f 100644 --- a/app/drivers/sensor/ec11/ec11_trigger.c +++ b/app/drivers/sensor/ec11/ec11_trigger.c @@ -36,7 +36,7 @@ static inline void setup_int(struct device *dev, bool enable) { } } -static void ec11_a_gpio_callback(struct device *dev, struct gpio_callback *cb, u32_t pins) { +static void ec11_a_gpio_callback(struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, a_gpio_cb); LOG_DBG(""); @@ -50,7 +50,7 @@ static void ec11_a_gpio_callback(struct device *dev, struct gpio_callback *cb, u #endif } -static void ec11_b_gpio_callback(struct device *dev, struct gpio_callback *cb, u32_t pins) { +static void ec11_b_gpio_callback(struct device *dev, struct gpio_callback *cb, uint32_t pins) { struct ec11_data *drv_data = CONTAINER_OF(cb, struct ec11_data, b_gpio_cb); LOG_DBG(""); diff --git a/app/include/drivers/behavior.h b/app/include/drivers/behavior.h index 39561a2d..d90897d0 100644 --- a/app/include/drivers/behavior.h +++ b/app/include/drivers/behavior.h @@ -23,7 +23,7 @@ typedef int (*behavior_keymap_binding_callback_t)(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event); typedef int (*behavior_sensor_keymap_binding_callback_t)(struct zmk_behavior_binding *binding, - struct device *sensor, s64_t timestamp); + struct device *sensor, int64_t timestamp); __subsystem struct behavior_driver_api { behavior_keymap_binding_callback_t binding_pressed; @@ -92,11 +92,11 @@ static inline int z_impl_behavior_keymap_binding_released(struct zmk_behavior_bi * @retval Negative errno code if failure. */ __syscall int behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *binding, - struct device *sensor, s64_t timestamp); + struct device *sensor, int64_t timestamp); static inline int z_impl_behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *binding, - struct device *sensor, s64_t timestamp) { + struct device *sensor, int64_t timestamp) { struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api; diff --git a/app/include/zmk/behavior.h b/app/include/zmk/behavior.h index 428ae243..f00ea4f9 100644 --- a/app/include/zmk/behavior.h +++ b/app/include/zmk/behavior.h @@ -8,12 +8,12 @@ struct zmk_behavior_binding { char *behavior_dev; - u32_t param1; - u32_t param2; + uint32_t param1; + uint32_t param2; }; struct zmk_behavior_binding_event { int layer; - u32_t position; - s64_t timestamp; + uint32_t position; + int64_t timestamp; }; \ No newline at end of file diff --git a/app/include/zmk/ble.h b/app/include/zmk/ble.h index 90afbda0..f6f6e191 100644 --- a/app/include/zmk/ble.h +++ b/app/include/zmk/ble.h @@ -12,7 +12,7 @@ int zmk_ble_clear_bonds(); int zmk_ble_prof_next(); int zmk_ble_prof_prev(); -int zmk_ble_prof_select(u8_t index); +int zmk_ble_prof_select(uint8_t index); int zmk_ble_active_profile_index(); bt_addr_le_t *zmk_ble_active_profile_addr(); diff --git a/app/include/zmk/endpoints.h b/app/include/zmk/endpoints.h index c252ef09..05e9954b 100644 --- a/app/include/zmk/endpoints.h +++ b/app/include/zmk/endpoints.h @@ -18,4 +18,4 @@ int zmk_endpoints_select(enum zmk_endpoint endpoint); int zmk_endpoints_toggle(); enum zmk_endpoint zmk_endpoints_selected(); -int zmk_endpoints_send_report(u8_t usage_report); +int zmk_endpoints_send_report(uint8_t usage_report); diff --git a/app/include/zmk/event-manager.h b/app/include/zmk/event-manager.h index 4b8f72c0..31c53228 100644 --- a/app/include/zmk/event-manager.h +++ b/app/include/zmk/event-manager.h @@ -16,7 +16,7 @@ struct zmk_event_type { struct zmk_event_header { const struct zmk_event_type *event; - u8_t last_listener_index; + uint8_t last_listener_index; }; #define ZMK_EV_EVENT_HANDLED 1 diff --git a/app/include/zmk/events/battery-state-changed.h b/app/include/zmk/events/battery-state-changed.h index a5901708..a983820b 100644 --- a/app/include/zmk/events/battery-state-changed.h +++ b/app/include/zmk/events/battery-state-changed.h @@ -12,7 +12,7 @@ struct battery_state_changed { struct zmk_event_header header; // TODO: Other battery channels - u8_t state_of_charge; + uint8_t state_of_charge; }; ZMK_EVENT_DECLARE(battery_state_changed); \ No newline at end of file diff --git a/app/include/zmk/events/ble-active-profile-changed.h b/app/include/zmk/events/ble-active-profile-changed.h index 1e3a198b..4491dfc5 100644 --- a/app/include/zmk/events/ble-active-profile-changed.h +++ b/app/include/zmk/events/ble-active-profile-changed.h @@ -14,7 +14,7 @@ struct ble_active_profile_changed { struct zmk_event_header header; - u8_t index; + uint8_t index; struct zmk_ble_profile *profile; }; diff --git a/app/include/zmk/events/keycode-state-changed.h b/app/include/zmk/events/keycode-state-changed.h index a0e24366..7dc87e21 100644 --- a/app/include/zmk/events/keycode-state-changed.h +++ b/app/include/zmk/events/keycode-state-changed.h @@ -14,19 +14,19 @@ struct keycode_state_changed { struct zmk_event_header header; - u8_t usage_page; - u32_t keycode; - u8_t implicit_modifiers; + uint8_t usage_page; + uint32_t keycode; + uint8_t implicit_modifiers; bool state; - s64_t timestamp; + int64_t timestamp; }; ZMK_EVENT_DECLARE(keycode_state_changed); static inline struct keycode_state_changed * -keycode_state_changed_from_encoded(u32_t encoded, bool pressed, s64_t timestamp) { - u16_t page = HID_USAGE_PAGE(encoded) & 0xFF; - u16_t id = HID_USAGE_ID(encoded); +keycode_state_changed_from_encoded(uint32_t encoded, bool pressed, int64_t timestamp) { + uint16_t page = HID_USAGE_PAGE(encoded) & 0xFF; + uint16_t id = HID_USAGE_ID(encoded); zmk_mod_flags implicit_mods = SELECT_MODS(encoded); if (!page) { diff --git a/app/include/zmk/events/layer-state-changed.h b/app/include/zmk/events/layer-state-changed.h index dc13ed63..352c6025 100644 --- a/app/include/zmk/events/layer-state-changed.h +++ b/app/include/zmk/events/layer-state-changed.h @@ -11,14 +11,14 @@ struct layer_state_changed { struct zmk_event_header header; - u8_t layer; + uint8_t layer; bool state; - s64_t timestamp; + int64_t timestamp; }; ZMK_EVENT_DECLARE(layer_state_changed); -static inline struct layer_state_changed *create_layer_state_changed(u8_t layer, bool state) { +static inline struct layer_state_changed *create_layer_state_changed(uint8_t layer, bool state) { struct layer_state_changed *ev = new_layer_state_changed(); ev->layer = layer; ev->state = state; diff --git a/app/include/zmk/events/position-state-changed.h b/app/include/zmk/events/position-state-changed.h index e4cbbbe7..7058276e 100644 --- a/app/include/zmk/events/position-state-changed.h +++ b/app/include/zmk/events/position-state-changed.h @@ -11,9 +11,9 @@ struct position_state_changed { struct zmk_event_header header; - u32_t position; + uint32_t position; bool state; - s64_t timestamp; + int64_t timestamp; }; ZMK_EVENT_DECLARE(position_state_changed); \ No newline at end of file diff --git a/app/include/zmk/events/sensor-event.h b/app/include/zmk/events/sensor-event.h index 688f7de9..d1d72f41 100644 --- a/app/include/zmk/events/sensor-event.h +++ b/app/include/zmk/events/sensor-event.h @@ -12,9 +12,9 @@ struct sensor_event { struct zmk_event_header header; - u8_t sensor_number; + uint8_t sensor_number; struct device *sensor; - s64_t timestamp; + int64_t timestamp; }; ZMK_EVENT_DECLARE(sensor_event); \ No newline at end of file diff --git a/app/include/zmk/hid.h b/app/include/zmk/hid.h index 306bc26b..1f755aa2 100644 --- a/app/include/zmk/hid.h +++ b/app/include/zmk/hid.h @@ -19,7 +19,7 @@ #define ZMK_HID_CONSUMER_NKRO_SIZE 6 -static const u8_t zmk_hid_report_desc[] = { +static const uint8_t zmk_hid_report_desc[] = { /* USAGE_PAGE (Generic Desktop) */ HID_GI_USAGE_PAGE, HID_USAGE_GD, @@ -141,28 +141,28 @@ static const u8_t zmk_hid_report_desc[] = { // struct zmk_hid_boot_report // { -// u8_t modifiers; -// u8_t _unused; -// u8_t keys[6]; +// uint8_t modifiers; +// uint8_t _unused; +// uint8_t keys[6]; // } __packed; struct zmk_hid_keyboard_report_body { zmk_mod_flags modifiers; - u8_t _reserved; - u8_t keys[ZMK_HID_KEYBOARD_NKRO_SIZE]; + uint8_t _reserved; + uint8_t keys[ZMK_HID_KEYBOARD_NKRO_SIZE]; } __packed; struct zmk_hid_keyboard_report { - u8_t report_id; + uint8_t report_id; struct zmk_hid_keyboard_report_body body; } __packed; struct zmk_hid_consumer_report_body { - u16_t keys[ZMK_HID_CONSUMER_NKRO_SIZE]; + uint16_t keys[ZMK_HID_CONSUMER_NKRO_SIZE]; } __packed; struct zmk_hid_consumer_report { - u8_t report_id; + uint8_t report_id; struct zmk_hid_consumer_report_body body; } __packed; diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index 88dc933d..7303d4aa 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -6,14 +6,14 @@ #pragma once -typedef u32_t zmk_keymap_layers_state; +typedef uint32_t zmk_keymap_layers_state; -u8_t zmk_keymap_layer_default(); +uint8_t zmk_keymap_layer_default(); zmk_keymap_layers_state zmk_keymap_layer_state(); -bool zmk_keymap_layer_active(u8_t layer); -u8_t zmk_keymap_highest_layer_active(); -int zmk_keymap_layer_activate(u8_t layer); -int zmk_keymap_layer_deactivate(u8_t layer); -int zmk_keymap_layer_toggle(u8_t layer); +bool zmk_keymap_layer_active(uint8_t layer); +uint8_t zmk_keymap_highest_layer_active(); +int zmk_keymap_layer_activate(uint8_t layer); +int zmk_keymap_layer_deactivate(uint8_t layer); +int zmk_keymap_layer_toggle(uint8_t layer); -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); diff --git a/app/include/zmk/keys.h b/app/include/zmk/keys.h index af474b1f..27d34b00 100644 --- a/app/include/zmk/keys.h +++ b/app/include/zmk/keys.h @@ -9,14 +9,14 @@ #include #include -typedef u32_t zmk_key; -typedef u8_t zmk_action; -typedef u8_t zmk_mod; -typedef u8_t zmk_mod_flags; +typedef uint32_t zmk_key; +typedef uint8_t zmk_action; +typedef uint8_t zmk_mod; +typedef uint8_t zmk_mod_flags; struct zmk_key_event { - u32_t column; - u32_t row; + uint32_t column; + uint32_t row; zmk_key key; bool pressed; }; \ No newline at end of file diff --git a/app/include/zmk/matrix_transform.h b/app/include/zmk/matrix_transform.h index 29c2afcd..413678a7 100644 --- a/app/include/zmk/matrix_transform.h +++ b/app/include/zmk/matrix_transform.h @@ -6,4 +6,4 @@ #pragma once -u32_t zmk_matrix_transform_row_column_to_position(u32_t row, u32_t column); \ No newline at end of file +uint32_t zmk_matrix_transform_row_column_to_position(uint32_t row, uint32_t column); \ No newline at end of file diff --git a/app/include/zmk/split/bluetooth/service.h b/app/include/zmk/split/bluetooth/service.h index c2be512f..b9f9fc3e 100644 --- a/app/include/zmk/split/bluetooth/service.h +++ b/app/include/zmk/split/bluetooth/service.h @@ -6,5 +6,5 @@ #pragma once -int zmk_split_bt_position_pressed(u8_t position); -int zmk_split_bt_position_released(u8_t position); \ No newline at end of file +int zmk_split_bt_position_pressed(uint8_t position); +int zmk_split_bt_position_released(uint8_t position); \ No newline at end of file diff --git a/app/include/zmk/usb.h b/app/include/zmk/usb.h index 30461de2..62a7e3cb 100644 --- a/app/include/zmk/usb.h +++ b/app/include/zmk/usb.h @@ -25,5 +25,5 @@ static inline bool zmk_usb_is_powered() { return zmk_usb_get_conn_state() != ZMK static inline bool zmk_usb_is_hid_ready() { return zmk_usb_get_conn_state() == ZMK_USB_CONN_HID; } #ifdef CONFIG_ZMK_USB -int zmk_usb_hid_send_report(const u8_t *report, size_t len); +int zmk_usb_hid_send_report(const uint8_t *report, size_t len); #endif /* CONFIG_ZMK_USB */ \ No newline at end of file diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 1dc665dd..50a96068 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 199ece2f..85af24a4 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 3ea58681..b676e167 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)); } diff --git a/app/src/ble.c b/app/src/ble.c index 32c13500..5f5f94a9 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -36,8 +36,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include static struct bt_conn *auth_passkey_entry_conn; -static u8_t passkey_entries[6] = {0, 0, 0, 0, 0, 0}; -static u8_t passkey_digit = 0; +static uint8_t passkey_entries[6] = {0, 0, 0, 0, 0, 0}; +static uint8_t passkey_digit = 0; #if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) #define PROFILE_COUNT (CONFIG_BT_MAX_PAIRED - 1) @@ -58,7 +58,7 @@ enum advertising_type { BT_GAP_ADV_FAST_INT_MAX_2, NULL) static struct zmk_ble_profile profiles[PROFILE_COUNT]; -static u8_t active_profile; +static uint8_t active_profile; #define DEVICE_NAME CONFIG_BT_DEVICE_NAME #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) @@ -104,7 +104,7 @@ bool zmk_ble_active_profile_is_open() { return !bt_addr_le_cmp(&profiles[active_profile].peer, BT_ADDR_LE_ANY); } -void set_profile_address(u8_t index, const bt_addr_le_t *addr) { +void set_profile_address(uint8_t index, const bt_addr_le_t *addr) { char setting_name[15]; char addr_str[BT_ADDR_LE_STR_LEN]; @@ -228,7 +228,7 @@ int zmk_ble_clear_bonds() { int zmk_ble_active_profile_index() { return active_profile; } -int zmk_ble_prof_select(u8_t index) { +int zmk_ble_prof_select(uint8_t index) { LOG_DBG("profile %d", index); if (active_profile == index) { return 0; @@ -277,7 +277,7 @@ static int ble_profiles_handle_set(const char *name, size_t len, settings_read_c if (settings_name_steq(name, "profiles", &next) && next) { char *endptr; - u8_t idx = strtoul(next, &endptr, 10); + uint8_t idx = strtoul(next, &endptr, 10); if (*endptr != '\0') { LOG_WRN("Invalid profile index: %s", log_strdup(next)); return -EINVAL; @@ -339,7 +339,7 @@ static bool is_conn_active_profile(const struct bt_conn *conn) { return bt_addr_le_cmp(bt_conn_get_dst(conn), &profiles[active_profile].peer) == 0; } -static void connected(struct bt_conn *conn, u8_t err) { +static void connected(struct bt_conn *conn, uint8_t err) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); LOG_DBG("Connected thread: %p", k_current_get()); @@ -372,7 +372,7 @@ static void connected(struct bt_conn *conn, u8_t err) { } } -static void disconnected(struct bt_conn *conn, u8_t reason) { +static void disconnected(struct bt_conn *conn, uint8_t reason) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); @@ -581,12 +581,12 @@ bool zmk_ble_handle_key_user(struct zmk_key_event *key_event) { return true; } - u32_t val = (key == NUMBER_0) ? 0 : (key - NUMBER_1 + 1); + uint32_t val = (key == NUMBER_0) ? 0 : (key - NUMBER_1 + 1); passkey_entries[passkey_digit++] = val; if (passkey_digit == 6) { - u32_t passkey = 0; + uint32_t passkey = 0; for (int i = 5; i >= 0; i--) { passkey = (passkey * 10) + val; } diff --git a/app/src/display/widgets/battery_status.c b/app/src/display/widgets/battery_status.c index 7b1afd11..29ae11b4 100644 --- a/app/src/display/widgets/battery_status.c +++ b/app/src/display/widgets/battery_status.c @@ -32,7 +32,7 @@ void battery_status_init() { void set_battery_symbol(lv_obj_t *label) { char text[2] = " "; - u8_t level = bt_gatt_bas_get_battery_level(); + uint8_t level = bt_gatt_bas_get_battery_level(); #if IS_ENABLED(CONFIG_USB) if (zmk_usb_is_powered()) { diff --git a/app/src/display/widgets/output_status.c b/app/src/display/widgets/output_status.c index 723d4f79..3ee2335b 100644 --- a/app/src/display/widgets/output_status.c +++ b/app/src/display/widgets/output_status.c @@ -36,7 +36,7 @@ void set_status_symbol(lv_obj_t *label) { enum zmk_endpoint selected_endpoint = zmk_endpoints_selected(); bool active_profile_connected = zmk_ble_active_profile_is_connected(); bool active_profie_bonded = !zmk_ble_active_profile_is_open(); - u8_t active_profile_index = zmk_ble_active_profile_index(); + uint8_t active_profile_index = zmk_ble_active_profile_index(); char text[6] = {}; switch (selected_endpoint) { diff --git a/app/src/endpoints.c b/app/src/endpoints.c index 4367dd2f..030b27a9 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -61,7 +61,7 @@ static int send_keyboard_report() { switch (current_endpoint) { #if IS_ENABLED(CONFIG_ZMK_USB) case ZMK_ENDPOINT_USB: { - int err = zmk_usb_hid_send_report((u8_t *)keyboard_report, sizeof(*keyboard_report)); + int err = zmk_usb_hid_send_report((uint8_t *)keyboard_report, sizeof(*keyboard_report)); if (err) { LOG_ERR("FAILED TO SEND OVER USB: %d", err); } @@ -91,7 +91,7 @@ static int send_consumer_report() { switch (current_endpoint) { #if IS_ENABLED(CONFIG_ZMK_USB) case ZMK_ENDPOINT_USB: { - int err = zmk_usb_hid_send_report((u8_t *)consumer_report, sizeof(*consumer_report)); + int err = zmk_usb_hid_send_report((uint8_t *)consumer_report, sizeof(*consumer_report)); if (err) { LOG_ERR("FAILED TO SEND OVER USB: %d", err); } @@ -115,7 +115,7 @@ static int send_consumer_report() { } } -int zmk_endpoints_send_report(u8_t usage_page) { +int zmk_endpoints_send_report(uint8_t usage_page) { LOG_DBG("usage page 0x%02X", usage_page); switch (usage_page) { diff --git a/app/src/event_manager.c b/app/src/event_manager.c index 226f3ce8..8c454e9e 100644 --- a/app/src/event_manager.c +++ b/app/src/event_manager.c @@ -17,9 +17,9 @@ extern struct zmk_event_type *__event_type_end[]; extern struct zmk_event_subscription __event_subscriptions_start[]; extern struct zmk_event_subscription __event_subscriptions_end[]; -int zmk_event_manager_handle_from(struct zmk_event_header *event, u8_t start_index) { +int zmk_event_manager_handle_from(struct zmk_event_header *event, uint8_t start_index) { int ret = 0; - u8_t len = __event_subscriptions_end - __event_subscriptions_start; + uint8_t len = __event_subscriptions_end - __event_subscriptions_start; for (int i = start_index; i < len; i++) { struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i; if (ev_sub->event_type == event->event) { @@ -54,7 +54,7 @@ int zmk_event_manager_raise(struct zmk_event_header *event) { int zmk_event_manager_raise_after(struct zmk_event_header *event, const struct zmk_listener *listener) { - u8_t len = __event_subscriptions_end - __event_subscriptions_start; + uint8_t len = __event_subscriptions_end - __event_subscriptions_start; for (int i = 0; i < len; i++) { struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i; @@ -70,7 +70,7 @@ int zmk_event_manager_raise_after(struct zmk_event_header *event, int zmk_event_manager_raise_at(struct zmk_event_header *event, const struct zmk_listener *listener) { - u8_t len = __event_subscriptions_end - __event_subscriptions_start; + uint8_t len = __event_subscriptions_end - __event_subscriptions_start; for (int i = 0; i < len; i++) { struct zmk_event_subscription *ev_sub = __event_subscriptions_start + i; diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c index 72950ae9..8510edee 100644 --- a/app/src/ext_power_generic.c +++ b/app/src/ext_power_generic.c @@ -21,8 +21,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct ext_power_generic_config { const char *label; - const u8_t pin; - const u8_t flags; + const uint8_t pin; + const uint8_t flags; }; struct ext_power_generic_data { diff --git a/app/src/hid_listener.c b/app/src/hid_listener.c index b93abcab..534831cc 100644 --- a/app/src/hid_listener.c +++ b/app/src/hid_listener.c @@ -16,7 +16,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -static int hid_listener_keycode_pressed(u8_t usage_page, u32_t keycode, +static int hid_listener_keycode_pressed(uint8_t usage_page, uint32_t keycode, zmk_mod_flags implicit_modifiers) { int err; LOG_DBG("usage_page 0x%02X keycode 0x%02X mods 0x%02X", usage_page, keycode, @@ -41,7 +41,7 @@ static int hid_listener_keycode_pressed(u8_t usage_page, u32_t keycode, return zmk_endpoints_send_report(usage_page); } -static int hid_listener_keycode_released(u8_t usage_page, u32_t keycode, +static int hid_listener_keycode_released(uint8_t usage_page, uint32_t keycode, zmk_mod_flags implicit_modifiers) { int err; LOG_DBG("usage_page 0x%02X keycode 0x%02X mods 0x%02X", usage_page, keycode, diff --git a/app/src/hog.c b/app/src/hog.c index ea61933e..8d10b8f7 100644 --- a/app/src/hog.c +++ b/app/src/hog.c @@ -23,14 +23,14 @@ enum { }; struct hids_info { - u16_t version; /* version number of base USB HID Specification */ - u8_t code; /* country HID Device hardware is localized for. */ - u8_t flags; + uint16_t version; /* version number of base USB HID Specification */ + uint8_t code; /* country HID Device hardware is localized for. */ + uint8_t flags; } __packed; struct hids_report { - u8_t id; /* report id */ - u8_t type; /* report type */ + uint8_t id; /* report id */ + uint8_t type; /* report type */ } __packed; static struct hids_info info = { @@ -56,29 +56,29 @@ static struct hids_report consumer_input = { }; static bool host_requests_notification = false; -static u8_t ctrl_point; -// static u8_t proto_mode; +static uint8_t ctrl_point; +// static uint8_t proto_mode; static ssize_t read_hids_info(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, - u16_t len, u16_t offset) { + uint16_t len, uint16_t offset) { return bt_gatt_attr_read(conn, attr, buf, len, offset, attr->user_data, sizeof(struct hids_info)); } static ssize_t read_hids_report_ref(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) { + void *buf, uint16_t len, uint16_t offset) { return bt_gatt_attr_read(conn, attr, buf, len, offset, attr->user_data, sizeof(struct hids_report)); } static ssize_t read_hids_report_map(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) { + void *buf, uint16_t len, uint16_t offset) { return bt_gatt_attr_read(conn, attr, buf, len, offset, zmk_hid_report_desc, sizeof(zmk_hid_report_desc)); } static ssize_t read_hids_input_report(struct bt_conn *conn, const struct bt_gatt_attr *attr, - void *buf, u16_t len, u16_t offset) { + void *buf, uint16_t len, uint16_t offset) { struct zmk_hid_keyboard_report_body *report_body = &zmk_hid_get_keyboard_report()->body; return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body, sizeof(struct zmk_hid_keyboard_report_body)); @@ -86,7 +86,7 @@ static ssize_t read_hids_input_report(struct bt_conn *conn, const struct bt_gatt static ssize_t read_hids_consumer_input_report(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, - u16_t len, u16_t offset) { + uint16_t len, uint16_t offset) { struct zmk_hid_consumer_report_body *report_body = &zmk_hid_get_consumer_report()->body; return bt_gatt_attr_read(conn, attr, buf, len, offset, report_body, sizeof(struct zmk_hid_consumer_report_body)); @@ -94,20 +94,20 @@ static ssize_t read_hids_consumer_input_report(struct bt_conn *conn, // static ssize_t write_proto_mode(struct bt_conn *conn, // const struct bt_gatt_attr *attr, -// const void *buf, u16_t len, u16_t offset, -// u8_t flags) +// const void *buf, uint16_t len, uint16_t offset, +// uint8_t flags) // { // printk("PROTO CHANGED\n"); // return 0; // } -static void input_ccc_changed(const struct bt_gatt_attr *attr, u16_t value) { +static void input_ccc_changed(const struct bt_gatt_attr *attr, uint16_t value) { host_requests_notification = (value == BT_GATT_CCC_NOTIFY) ? 1 : 0; } static ssize_t write_ctrl_point(struct bt_conn *conn, const struct bt_gatt_attr *attr, - const void *buf, u16_t len, u16_t offset, u8_t flags) { - u8_t *value = attr->user_data; + const void *buf, uint16_t len, uint16_t offset, uint8_t flags) { + uint8_t *value = attr->user_data; if (offset + len > sizeof(ctrl_point)) { return BT_GATT_ERR(BT_ATT_ERR_INVALID_OFFSET); diff --git a/app/src/keymap.c b/app/src/keymap.c index 08115a1c..0dc7c1a1 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -20,7 +20,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include 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) && diff --git a/app/src/kscan.c b/app/src/kscan.c index 8575e708..b6ffc37f 100644 --- a/app/src/kscan.c +++ b/app/src/kscan.c @@ -19,9 +19,9 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #define ZMK_KSCAN_EVENT_STATE_RELEASED 1 struct zmk_kscan_event { - u32_t row; - u32_t column; - u32_t state; + uint32_t row; + uint32_t column; + uint32_t state; }; struct zmk_kscan_msg_processor { @@ -30,7 +30,7 @@ struct zmk_kscan_msg_processor { K_MSGQ_DEFINE(zmk_kscan_msgq, sizeof(struct zmk_kscan_event), CONFIG_ZMK_KSCAN_EVENT_QUEUE_SIZE, 4); -static void zmk_kscan_callback(struct device *dev, u32_t row, u32_t column, bool pressed) { +static void zmk_kscan_callback(struct device *dev, uint32_t row, uint32_t column, bool pressed) { struct zmk_kscan_event ev = { .row = row, .column = column, @@ -45,7 +45,7 @@ void zmk_kscan_process_msgq(struct k_work *item) { while (k_msgq_get(&zmk_kscan_msgq, &ev, K_NO_WAIT) == 0) { bool pressed = (ev.state == ZMK_KSCAN_EVENT_STATE_PRESSED); - u32_t position = zmk_matrix_transform_row_column_to_position(ev.row, ev.column); + uint32_t position = zmk_matrix_transform_row_column_to_position(ev.row, ev.column); struct position_state_changed *pos_ev; LOG_DBG("Row: %d, col: %d, position: %d, pressed: %s\n", ev.row, ev.column, position, (pressed ? "true" : "false")); diff --git a/app/src/matrix_transform.c b/app/src/matrix_transform.c index 4e68a56f..33be93d3 100644 --- a/app/src/matrix_transform.c +++ b/app/src/matrix_transform.c @@ -15,12 +15,12 @@ [(KT_ROW(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i)) * ZMK_MATRIX_COLS) + \ KT_COL(DT_PROP_BY_IDX(ZMK_KEYMAP_TRANSFORM_NODE, map, i))] = i, -static u32_t transform[] = {UTIL_LISTIFY(ZMK_KEYMAP_LEN, _TRANSFORM_ENTRY, 0)}; +static uint32_t transform[] = {UTIL_LISTIFY(ZMK_KEYMAP_LEN, _TRANSFORM_ENTRY, 0)}; #endif -u32_t zmk_matrix_transform_row_column_to_position(u32_t row, u32_t column) { - u32_t matrix_index; +uint32_t zmk_matrix_transform_row_column_to_position(uint32_t row, uint32_t column) { + uint32_t matrix_index; #if DT_NODE_HAS_PROP(ZMK_KEYMAP_TRANSFORM_NODE, col_offset) column += DT_PROP(ZMK_KEYMAP_TRANSFORM_NODE, col_offset); diff --git a/app/src/power.c b/app/src/power.c index bad54d28..2330a3e8 100644 --- a/app/src/power.c +++ b/app/src/power.c @@ -17,7 +17,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -static u32_t power_last_uptime; +static uint32_t power_last_uptime; #define MAX_IDLE_MS CONFIG_ZMK_IDLE_SLEEP_TIMEOUT @@ -29,10 +29,10 @@ bool is_usb_power_present() { #endif /* CONFIG_USB */ } -enum power_states sys_pm_policy_next_state(s32_t ticks) { +enum power_states sys_pm_policy_next_state(int32_t ticks) { #ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES #ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 - s32_t current = k_uptime_get(); + int32_t current = k_uptime_get(); if (power_last_uptime > 0 && !is_usb_power_present() && current - power_last_uptime > MAX_IDLE_MS) { return SYS_POWER_STATE_DEEP_SLEEP_1; diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index 6e5cb1b5..b2943e6a 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -31,18 +31,18 @@ enum rgb_underglow_effect { }; struct led_hsb { - u16_t h; - u8_t s; - u8_t b; + uint16_t h; + uint8_t s; + uint8_t b; }; struct rgb_underglow_state { - u16_t hue; - u8_t saturation; - u8_t brightness; - u8_t animation_speed; - u8_t current_effect; - u16_t animation_step; + uint16_t hue; + uint8_t saturation; + uint8_t brightness; + uint8_t animation_speed; + uint8_t current_effect; + uint16_t animation_step; bool on; }; @@ -59,7 +59,7 @@ static struct device *ext_power; static struct led_rgb hsb_to_rgb(struct led_hsb hsb) { double r, g, b; - u8_t i = hsb.h / 60; + uint8_t i = hsb.h / 60; double v = hsb.b / 100.0; double s = hsb.s / 100.0; double f = hsb.h / 360.0 * 6 - i; diff --git a/app/src/sensors.c b/app/src/sensors.c index f1cfdd15..5bccc854 100644 --- a/app/src/sensors.c +++ b/app/src/sensors.c @@ -19,7 +19,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #if ZMK_KEYMAP_HAS_SENSORS struct sensors_data_item { - u8_t sensor_number; + uint8_t sensor_number; struct device *dev; struct sensor_trigger trigger; }; @@ -53,7 +53,7 @@ static void zmk_sensors_trigger_handler(struct device *dev, struct sensor_trigge ZMK_EVENT_RAISE(event); } -static void zmk_sensors_init_item(const char *node, u8_t i, u8_t abs_i) { +static void zmk_sensors_init_item(const char *node, uint8_t i, uint8_t abs_i) { LOG_DBG("Init %s at index %d with sensor_number %d", node, i, abs_i); sensors[i].dev = device_get_binding(node); diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index 2d4d1ed8..f3c860f0 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -33,11 +33,12 @@ static struct bt_uuid_128 uuid = BT_UUID_INIT_128(ZMK_SPLIT_BT_SERVICE_UUID); static struct bt_gatt_discover_params discover_params; static struct bt_gatt_subscribe_params subscribe_params; -static u8_t split_central_notify_func(struct bt_conn *conn, struct bt_gatt_subscribe_params *params, - const void *data, u16_t length) { - static u8_t position_state[POSITION_STATE_DATA_LEN]; +static uint8_t split_central_notify_func(struct bt_conn *conn, + struct bt_gatt_subscribe_params *params, const void *data, + uint16_t length) { + static uint8_t position_state[POSITION_STATE_DATA_LEN]; - u8_t changed_positions[POSITION_STATE_DATA_LEN]; + uint8_t changed_positions[POSITION_STATE_DATA_LEN]; if (!data) { LOG_DBG("[UNSUBSCRIBED]"); @@ -48,14 +49,14 @@ static u8_t split_central_notify_func(struct bt_conn *conn, struct bt_gatt_subsc LOG_DBG("[NOTIFICATION] data %p length %u", data, length); for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) { - changed_positions[i] = ((u8_t *)data)[i] ^ position_state[i]; - position_state[i] = ((u8_t *)data)[i]; + changed_positions[i] = ((uint8_t *)data)[i] ^ position_state[i]; + position_state[i] = ((uint8_t *)data)[i]; } for (int i = 0; i < POSITION_STATE_DATA_LEN; i++) { for (int j = 0; j < 8; j++) { if (changed_positions[i] & BIT(j)) { - u32_t position = (i * 8) + j; + uint32_t position = (i * 8) + j; bool pressed = position_state[i] & BIT(j); struct position_state_changed *pos_ev = new_position_state_changed(); pos_ev->position = position; @@ -91,8 +92,8 @@ static int split_central_subscribe(struct bt_conn *conn) { return 0; } -static u8_t split_central_discovery_func(struct bt_conn *conn, const struct bt_gatt_attr *attr, - struct bt_gatt_discover_params *params) { +static uint8_t split_central_discovery_func(struct bt_conn *conn, const struct bt_gatt_attr *attr, + struct bt_gatt_discover_params *params) { int err; if (!attr) { @@ -245,7 +246,7 @@ static bool split_central_eir_found(struct bt_data *data, void *user_data) { return true; } -static void split_central_device_found(const bt_addr_le_t *addr, s8_t rssi, u8_t type, +static void split_central_device_found(const bt_addr_le_t *addr, int8_t rssi, uint8_t type, struct net_buf_simple *ad) { char dev[BT_ADDR_LE_STR_LEN]; @@ -272,7 +273,7 @@ static int start_scan(void) { return 0; } -static void split_central_connected(struct bt_conn *conn, u8_t conn_err) { +static void split_central_connected(struct bt_conn *conn, uint8_t conn_err) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); @@ -292,7 +293,7 @@ static void split_central_connected(struct bt_conn *conn, u8_t conn_err) { split_central_process_connection(conn); } -static void split_central_disconnected(struct bt_conn *conn, u8_t reason) { +static void split_central_disconnected(struct bt_conn *conn, uint8_t reason) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); diff --git a/app/src/split/bluetooth/service.c b/app/src/split/bluetooth/service.c index 86af685f..48390849 100644 --- a/app/src/split/bluetooth/service.c +++ b/app/src/split/bluetooth/service.c @@ -18,21 +18,21 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include -static u8_t num_of_positions = ZMK_KEYMAP_LEN; -static u8_t position_state[16]; +static uint8_t num_of_positions = ZMK_KEYMAP_LEN; +static uint8_t position_state[16]; static ssize_t split_svc_pos_state(struct bt_conn *conn, const struct bt_gatt_attr *attrs, - void *buf, u16_t len, u16_t offset) { + void *buf, uint16_t len, uint16_t offset) { return bt_gatt_attr_read(conn, attrs, buf, len, offset, &position_state, sizeof(position_state)); } static ssize_t split_svc_num_of_positions(struct bt_conn *conn, const struct bt_gatt_attr *attrs, - void *buf, u16_t len, u16_t offset) { - return bt_gatt_attr_read(conn, attrs, buf, len, offset, attrs->user_data, sizeof(u8_t)); + void *buf, uint16_t len, uint16_t offset) { + return bt_gatt_attr_read(conn, attrs, buf, len, offset, attrs->user_data, sizeof(uint8_t)); } -static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, u16_t value) { +static void split_svc_pos_state_ccc(const struct bt_gatt_attr *attr, uint16_t value) { LOG_DBG("value %d", value); } @@ -45,12 +45,12 @@ BT_GATT_SERVICE_DEFINE( BT_GATT_DESCRIPTOR(BT_UUID_NUM_OF_DIGITALS, BT_GATT_PERM_READ, split_svc_num_of_positions, NULL, &num_of_positions), ); -int zmk_split_bt_position_pressed(u8_t position) { +int zmk_split_bt_position_pressed(uint8_t position) { WRITE_BIT(position_state[position / 8], position % 8, true); return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state)); } -int zmk_split_bt_position_released(u8_t position) { +int zmk_split_bt_position_released(uint8_t position) { WRITE_BIT(position_state[position / 8], position % 8, false); return bt_gatt_notify(NULL, &split_svc.attrs[1], &position_state, sizeof(position_state)); } \ No newline at end of file diff --git a/app/src/usb.c b/app/src/usb.c index 79d03c7b..d0253b55 100644 --- a/app/src/usb.c +++ b/app/src/usb.c @@ -31,7 +31,7 @@ static const struct hid_ops ops = { .int_in_ready = in_ready_cb, }; -int zmk_usb_hid_send_report(const u8_t *report, size_t len) { +int zmk_usb_hid_send_report(const uint8_t *report, size_t len) { switch (usb_status) { case USB_DC_SUSPEND: return usb_wakeup_request(); @@ -78,7 +78,7 @@ enum zmk_usb_conn_state zmk_usb_get_conn_state() { } } -void usb_status_cb(enum usb_dc_status_code status, const u8_t *params) { +void usb_status_cb(enum usb_dc_status_code status, const uint8_t *params) { usb_status = status; raise_usb_status_changed_event(); };