Skip to content

Commit

Permalink
GUI: Ascii input for ByteInput
Browse files Browse the repository at this point in the history
  • Loading branch information
Willy-JL committed Oct 29, 2024
1 parent 38471fd commit 4ee5789
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
- OFW: Dolphin: Happy mode in Desktop settings (by @portasynthinca3)
- OFW: CLI: Improvements part I, `neofetch` command (by @portasynthinca3), fix for lab.flipper.net (by @xMasterX)
- GUI:
- ByteInput supports ASCII input (by @Willy-JL)
- OFW: Add up and down button drawing functions to GUI elements (by @DerSkythe)
- OFW: Extended icon draw function in Canvas (by @RebornedBrain)
- OFW: RPC: Support 5V on GPIO control for ext. modules (by @gsurkov)
Expand Down
46 changes: 46 additions & 0 deletions applications/services/gui/modules/byte_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,51 @@ static bool byte_input_view_input_callback(InputEvent* event, void* context) {
return consumed;
}

static bool byte_input_view_ascii_callback(AsciiEvent* event, void* context) {
ByteInput* byte_input = context;
furi_assert(byte_input);

switch(event->value) {
case AsciiValueDC3: // Right
case AsciiValueDC4: // Left
with_view_model(
byte_input->view,
ByteInputModel * model,
{
if(event->value == AsciiValueDC3) {
byte_input_inc_selected_byte_mini(model);
} else {
byte_input_dec_selected_byte_mini(model);
}
},
true);
return true;
default: // Look in keyboard
for(size_t r = 0; r < keyboard_row_count; r++) {
const ByteInputKey* row = byte_input_get_row(r);
uint8_t size = byte_input_get_row_size(r);
for(size_t key = 0; key < size; key++) {
char value = row[key].value;
if(event->value == value) {
with_view_model(
byte_input->view,
ByteInputModel * model,
{
model->selected_row = r;
model->selected_column = key;
byte_input_handle_ok(model);
},
true);
return true;
}
}
}
break;
}

return false;
}

/** Reset all input-related data in model
*
* @param model The model
Expand All @@ -747,6 +792,7 @@ ByteInput* byte_input_alloc(void) {
view_allocate_model(byte_input->view, ViewModelTypeLocking, sizeof(ByteInputModel));
view_set_draw_callback(byte_input->view, byte_input_view_draw_callback);
view_set_input_callback(byte_input->view, byte_input_view_input_callback);
view_set_ascii_callback(byte_input->view, byte_input_view_ascii_callback);

with_view_model(
byte_input->view,
Expand Down

0 comments on commit 4ee5789

Please sign in to comment.