mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-10 06:54:19 +00:00
Add the ability to turn pages in infrared (#2271)
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
75e9de12b0
commit
073fb3861a
1 changed files with 49 additions and 0 deletions
|
@ -178,6 +178,47 @@ static void button_menu_process_down(ButtonMenu* button_menu) {
|
|||
true);
|
||||
}
|
||||
|
||||
static void button_menu_process_right(ButtonMenu* button_menu) {
|
||||
furi_assert(button_menu);
|
||||
|
||||
with_view_model(
|
||||
button_menu->view,
|
||||
ButtonMenuModel * model,
|
||||
{
|
||||
if(ButtonMenuItemArray_size(model->items) > BUTTONS_PER_SCREEN) {
|
||||
size_t position_candidate = model->position + BUTTONS_PER_SCREEN;
|
||||
position_candidate -= position_candidate % BUTTONS_PER_SCREEN;
|
||||
if(position_candidate < (ButtonMenuItemArray_size(model->items))) {
|
||||
model->position = position_candidate;
|
||||
} else {
|
||||
model->position = 0;
|
||||
}
|
||||
}
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static void button_menu_process_left(ButtonMenu* button_menu) {
|
||||
furi_assert(button_menu);
|
||||
|
||||
with_view_model(
|
||||
button_menu->view,
|
||||
ButtonMenuModel * model,
|
||||
{
|
||||
if(ButtonMenuItemArray_size(model->items) > BUTTONS_PER_SCREEN) {
|
||||
size_t position_candidate;
|
||||
if(model->position < BUTTONS_PER_SCREEN) {
|
||||
position_candidate = (ButtonMenuItemArray_size(model->items) - 1);
|
||||
} else {
|
||||
position_candidate = model->position - BUTTONS_PER_SCREEN;
|
||||
};
|
||||
position_candidate -= position_candidate % BUTTONS_PER_SCREEN;
|
||||
model->position = position_candidate;
|
||||
}
|
||||
},
|
||||
true);
|
||||
}
|
||||
|
||||
static void button_menu_process_ok(ButtonMenu* button_menu, InputType type) {
|
||||
furi_assert(button_menu);
|
||||
|
||||
|
@ -239,6 +280,14 @@ static bool button_menu_view_input_callback(InputEvent* event, void* context) {
|
|||
consumed = true;
|
||||
button_menu_process_down(button_menu);
|
||||
break;
|
||||
case InputKeyRight:
|
||||
consumed = true;
|
||||
button_menu_process_right(button_menu);
|
||||
break;
|
||||
case InputKeyLeft:
|
||||
consumed = true;
|
||||
button_menu_process_left(button_menu);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue