Skip to content

Commit 69f124b

Browse files
committed
keyboard-switch: Force top location
The keyboard switcher is only used from the top so remove the option to create it in the bottom location. This simplifies the event hander.
1 parent 65f5b52 commit 69f124b

File tree

4 files changed

+6
-10
lines changed

4 files changed

+6
-10
lines changed

src/ui/components/keyboard_switch.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
*/
3131
typedef struct {
3232
keyboard_mode_t mode;
33-
slider_location_t location;
3433
bool active; // Marker is 'active', i.e., touched
3534
// if true, the special chars keyboard mode is available.
3635
bool special_chars;
@@ -90,18 +89,19 @@ static void _render(component_t* component)
9089
static void _on_event(const event_t* event, component_t* component)
9190
{
9291
keyboard_switch_data_t* ks_data = (keyboard_switch_data_t*)component->data;
92+
if (event->data.source != top_slider) {
93+
return;
94+
}
9395
switch (event->id) {
9496
case EVENT_CONTINUOUS_TAP:
95-
if (event->data.source == top_slider && ks_data->location == top_slider &&
96-
event->data.position > SLIDER_POSITION_ONE_THIRD &&
97+
if (event->data.position > SLIDER_POSITION_ONE_THIRD &&
9798
event->data.position <= SLIDER_POSITION_TWO_THIRD) {
9899
ks_data->active = true;
99100
break;
100101
}
101102
/* FALLTHROUGH */
102103
case EVENT_SHORT_TAP:
103-
if (event->data.source == top_slider && ks_data->location == top_slider &&
104-
event->data.position > SLIDER_POSITION_ONE_THIRD &&
104+
if (event->data.position > SLIDER_POSITION_ONE_THIRD &&
105105
event->data.position <= SLIDER_POSITION_TWO_THIRD) {
106106
ks_data->active = false;
107107
switch (ks_data->mode) {
@@ -145,7 +145,6 @@ static component_functions_t _component_functions = {
145145
/********************************** Create Instance **********************************/
146146

147147
component_t* keyboard_switch_create(
148-
slider_location_t location,
149148
bool special_chars,
150149
bool default_to_digits,
151150
component_t* parent,
@@ -164,7 +163,6 @@ component_t* keyboard_switch_create(
164163
}
165164
memset(ks_data, 0, sizeof(keyboard_switch_data_t));
166165

167-
ks_data->location = location;
168166
ks_data->mode = default_to_digits ? DIGITS : LOWER_CASE;
169167
ks_data->active = false;
170168
ks_data->special_chars = special_chars;

src/ui/components/keyboard_switch.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ typedef enum { LOWER_CASE, UPPER_CASE, DIGITS, SPECIAL_CHARS } keyboard_mode_t;
3030
* @param[in] parent The parent component.
3131
*/
3232
component_t* keyboard_switch_create(
33-
slider_location_t location,
3433
bool special_chars,
3534
bool default_to_digits,
3635
component_t* parent,

src/ui/components/trinary_input_string.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,6 @@ component_t* trinary_input_string_create(
495495

496496
if (params->wordlist == NULL && !params->number_input) {
497497
data->keyboard_switch_component = keyboard_switch_create(
498-
top_slider,
499498
params->special_chars,
500499
params->default_to_digits,
501500
component,

test/unit-test/test_ui_components.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static void test_ui_components_keyboard_switch(void** state)
142142
component_t* mock_component = fake_component_create();
143143

144144
component_t* keyboard_switch =
145-
keyboard_switch_create(top_slider, true, false, mock_component, _ks_cb, NULL);
145+
keyboard_switch_create(true, false, mock_component, _ks_cb, NULL);
146146
assert_non_null(keyboard_switch);
147147
assert_ui_component_functions(keyboard_switch);
148148
keyboard_switch->f->cleanup(keyboard_switch);

0 commit comments

Comments
 (0)