Skip to content

Conversation

NickeZ
Copy link
Collaborator

@NickeZ NickeZ commented Sep 25, 2025

No description provided.

@NickeZ NickeZ requested a review from benma September 25, 2025 11:44
@NickeZ NickeZ force-pushed the maint/reduce-events branch 10 times, most recently from 130affe to 0c8d37a Compare September 29, 2025 10:22
@NickeZ
Copy link
Collaborator Author

NickeZ commented Sep 29, 2025

Fixed bug where keyboard was activated by wrong events. There was a logical bug in the event handler of trinary_input_char.

Copy link
Collaborator

@benma benma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am midway through the 2nd commit, but want to look at trinary_input_string.c more closely.

For review feedback, please add commits (no amend), and squash later, as it's a big PR and revisiting all files is time-consuming.

Comment on lines 363 to 368
case UPPER_CASE:
trinary_input_char_set_alphabet(trinary_char, _alphabet_uppercase, 1);
break;
case DIGITS:
trinary_input_char_set_alphabet(trinary_char, _digits, 1);
break;
case SPECIAL_CHARS:
trinary_input_char_set_alphabet(trinary_char, _special_chars, 2);
Copy link
Collaborator

@benma benma Sep 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a copy/paste of the last branch of _set_alphabet(), and before this PR, _set_alphabet() was called on keyboard switching. Why not just call _set_alphabet() here instead of repeating the code?

Or at least move this to a helper function and call it from both places.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_set_alphabet() seems to be some kind of "god function" that behaves very differently based on input. I can see again if I can reduce the duplicity, but sometimes just writing it out is simpler than having an extra function.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

called the callback in _set_alphabet() to keep it DRY.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imho calling _on_keyboard_switch_cb() from _set_alphabet() even though there was no keyboard switch is less intuitive than calling _set_alphabet() from _on_keyboard_switch_cb() 😂 as you say, it's the "god" function that sets the keyboard correctly whenever called, so it's appropriate to call it.

But not that important, if you prefer it much more this way, then ok.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i made a separate function to update the input_char from the keyboard_mode.

I really didn't like that the else clause could cause a nullptr-deref in case the keyboard switch component was NULL, so I added an extra check. I'm sure the other checks implicitly meant that that was impossible. But it just felt so unsafe.

@NickeZ
Copy link
Collaborator Author

NickeZ commented Sep 30, 2025

I am midway through the 2nd commit, but want to look at trinary_input_string.c more closely.

For review feedback, please add commits (no amend), and squash later, as it's a big PR and revisiting all files is time-consuming.

Sorry, I started fixing the issues before reading this comment.

@NickeZ NickeZ force-pushed the maint/reduce-events branch 3 times, most recently from eb04254 to 4d74e73 Compare October 1, 2025 07:44
Copy link
Collaborator

@benma benma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK, feel free to squash everything

@NickeZ NickeZ force-pushed the maint/reduce-events branch from 4d74e73 to 78578f6 Compare October 1, 2025 08:14
NickeZ added 2 commits October 1, 2025 10:16
* entry_screen isn't used
* confirm_button was just a trivial wrapper
Using events for communication between components in the same screen
seem to make things racy, simplify/sequentialize by using callbacks
instead.

Keep events only for external events like slider inputs.
@NickeZ NickeZ force-pushed the maint/reduce-events branch from 78578f6 to 445a392 Compare October 1, 2025 08:17
@NickeZ NickeZ merged commit 29e55e3 into BitBoxSwiss:master Oct 1, 2025
32 checks passed
@NickeZ NickeZ deleted the maint/reduce-events branch October 1, 2025 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants