GUI: Ascii input for ByteInput

This commit is contained in:
Willy-JL
2024-10-29 18:19:15 +00:00
parent 38471fdd75
commit 4ee5789168
2 changed files with 47 additions and 0 deletions

View File

@@ -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)

View File

@@ -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
@@ -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,