What changed, and why it matters
This is a small code cleanup change. It removes the ability to place a keyboard-mode switcher at the bottom of the screen, because the product only ever uses it at the top. The event handler is simplified as a result. There is no security-relevant change here.
No security action needed. Treat as normal code-quality review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The keyboard_switch_create() function no longer accepts a slider_location_t parameter; it is implicitly always top_slider. The event handler now returns early for any event whose source is not top_slider, and the redundant location checks inside the EVENT_CONTINUOUS_TAP and EVENT_SHORT_TAP cases are removed. Callers and unit tests are updated accordingly. This is a pure refactor with no behavioral change for the actual firmware UI flows.
Changed components
src/ui/components/keyboard_switch.csrc/ui/components/keyboard_switch.hsrc/ui/components/trinary_input_string.ctest/unit-test/test_ui_components.cInspect captured patch +6 / −10
diff --git a/src/ui/components/keyboard_switch.c b/src/ui/components/keyboard_switch.c
index 99a75f4..b06b621 100644
--- a/src/ui/components/keyboard_switch.c
+++ b/src/ui/components/keyboard_switch.c
@@ -30,7 +30,6 @@
*/
typedef struct {
keyboard_mode_t mode;
- slider_location_t location;
bool active; // Marker is 'active', i.e., touched
// if true, the special chars keyboard mode is available.
bool special_chars;
@@ -90,18 +89,19 @@ static void _render(component_t* component)
static void _on_event(const event_t* event, component_t* component)
{
keyboard_switch_data_t* ks_data = (keyboard_switch_data_t*)component->data;
+ if (event->data.source != top_slider) {
+ return;
+ }
switch (event->id) {
case EVENT_CONTINUOUS_TAP:
- if (event->data.source == top_slider && ks_data->location == top_slider &&
- event->data.position > SLIDER_POSITION_ONE_THIRD &&
+ if (event->data.position > SLIDER_POSITION_ONE_THIRD &&
event->data.position <= SLIDER_POSITION_TWO_THIRD) {
ks_data->active = true;
break;
}
/* FALLTHROUGH */
case EVENT_SHORT_TAP:
- if (event->data.source == top_slider && ks_data->location == top_slider &&
- event->data.position > SLIDER_POSITION_ONE_THIRD &&
+ if (event->data.position > SLIDER_POSITION_ONE_THIRD &&
event->data.position <= SLIDER_POSITION_TWO_THIRD) {
ks_data->active = false;
switch (ks_data->mode) {
@@ -145,7 +145,6 @@ static component_functions_t _component_functions = {
/********************************** Create Instance **********************************/
component_t* keyboard_switch_create(
- slider_location_t location,
bool special_chars,
bool default_to_digits,
component_t* parent,
@@ -164,7 +163,6 @@ component_t* keyboard_switch_create(
}
memset(ks_data, 0, sizeof(keyboard_switch_data_t));
- ks_data->location = location;
ks_data->mode = default_to_digits ? DIGITS : LOWER_CASE;
ks_data->active = false;
ks_data->special_chars = special_chars;
diff --git a/src/ui/components/keyboard_switch.h b/src/ui/components/keyboard_switch.h
index 0e3ddbf..24f40c2 100644
--- a/src/ui/components/keyboard_switch.h
+++ b/src/ui/components/keyboard_switch.h
@@ -30,7 +30,6 @@ typedef enum { LOWER_CASE, UPPER_CASE, DIGITS, SPECIAL_CHARS } keyboard_mode_t;
* @param[in] parent The parent component.
*/
component_t* keyboard_switch_create(
- slider_location_t location,
bool special_chars,
bool default_to_digits,
component_t* parent,
diff --git a/src/ui/components/trinary_input_string.c b/src/ui/components/trinary_input_string.c
index 2726928..28af00d 100644
--- a/src/ui/components/trinary_input_string.c
+++ b/src/ui/components/trinary_input_string.c
@@ -495,7 +495,6 @@ component_t* trinary_input_string_create(
if (params->wordlist == NULL && !params->number_input) {
data->keyboard_switch_component = keyboard_switch_create(
- top_slider,
params->special_chars,
params->default_to_digits,
component,
diff --git a/test/unit-test/test_ui_components.c b/test/unit-test/test_ui_components.c
index 1cb9a1f..a3494f7 100644
--- a/test/unit-test/test_ui_components.c
+++ b/test/unit-test/test_ui_components.c
@@ -142,7 +142,7 @@ static void test_ui_components_keyboard_switch(void** state)
component_t* mock_component = fake_component_create();
component_t* keyboard_switch =
- keyboard_switch_create(top_slider, true, false, mock_component, _ks_cb, NULL);
+ keyboard_switch_create(true, false, mock_component, _ks_cb, NULL);
assert_non_null(keyboard_switch);
assert_ui_component_functions(keyboard_switch);
keyboard_switch->f->cleanup(keyboard_switch);
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.