diff --git a/applications/main/infrared/scenes/common/infrared_scene_universal_common.c b/applications/main/infrared/scenes/common/infrared_scene_universal_common.c index 62b7350e71..4e5a965a70 100644 --- a/applications/main/infrared/scenes/common/infrared_scene_universal_common.c +++ b/applications/main/infrared/scenes/common/infrared_scene_universal_common.c @@ -13,10 +13,12 @@ typedef union { } InfraredSceneState; #pragma pack(pop) -void infrared_scene_universal_common_item_callback(void* context, uint32_t index) { +void infrared_scene_universal_common_item_callback(void* context, uint32_t index, InputType type) { InfraredApp* infrared = context; - uint32_t event = infrared_custom_event_pack(InfraredCustomEventTypeButtonSelected, index); - view_dispatcher_send_custom_event(infrared->view_dispatcher, event); + if(type == InputTypeShort) { + uint32_t event = infrared_custom_event_pack(InfraredCustomEventTypeButtonSelected, index); + view_dispatcher_send_custom_event(infrared->view_dispatcher, event); + } } static void infrared_scene_universal_common_progress_input_callback( diff --git a/applications/main/infrared/scenes/common/infrared_scene_universal_common.h b/applications/main/infrared/scenes/common/infrared_scene_universal_common.h index a6c697d774..277598e42e 100644 --- a/applications/main/infrared/scenes/common/infrared_scene_universal_common.h +++ b/applications/main/infrared/scenes/common/infrared_scene_universal_common.h @@ -5,4 +5,4 @@ void infrared_scene_universal_common_on_enter(void* context); bool infrared_scene_universal_common_on_event(void* context, SceneManagerEvent event); void infrared_scene_universal_common_on_exit(void* context); -void infrared_scene_universal_common_item_callback(void* context, uint32_t index); +void infrared_scene_universal_common_item_callback(void* context, uint32_t index, InputType type); diff --git a/applications/services/gui/modules/button_panel.c b/applications/services/gui/modules/button_panel.c index 9301870efd..efc512bc5d 100644 --- a/applications/services/gui/modules/button_panel.c +++ b/applications/services/gui/modules/button_panel.c @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -46,6 +47,7 @@ ARRAY_DEF(ButtonMatrix, ButtonArray_t); struct ButtonPanel { View* view; + bool freeze_input; }; typedef struct { @@ -63,7 +65,7 @@ static void button_panel_process_up(ButtonPanel* button_panel); static void button_panel_process_down(ButtonPanel* button_panel); static void button_panel_process_left(ButtonPanel* button_panel); static void button_panel_process_right(ButtonPanel* button_panel); -static void button_panel_process_ok(ButtonPanel* button_panel); +static void button_panel_process_ok(ButtonPanel* button_panel, InputType input); static void button_panel_view_draw_callback(Canvas* canvas, void* _model); static bool button_panel_view_input_callback(InputEvent* event, void* context); @@ -347,7 +349,7 @@ static void button_panel_process_right(ButtonPanel* button_panel) { true); } -void button_panel_process_ok(ButtonPanel* button_panel) { +void button_panel_process_ok(ButtonPanel* button_panel, InputType type) { ButtonItem* button_item = NULL; with_view_model( @@ -360,7 +362,7 @@ void button_panel_process_ok(ButtonPanel* button_panel) { true); if(button_item && button_item->callback) { - button_item->callback(button_item->callback_context, button_item->index); + button_item->callback(button_item->callback_context, button_item->index, type); } } @@ -368,8 +370,15 @@ static bool button_panel_view_input_callback(InputEvent* event, void* context) { ButtonPanel* button_panel = context; furi_assert(button_panel); bool consumed = false; - - if(event->type == InputTypeShort) { + if(event->key == InputKeyOk) { + if((event->type == InputTypePress) || (event->type == InputTypeRelease)) { + button_panel->freeze_input = (event->type == InputTypePress); + } + consumed = true; + button_panel_process_ok(button_panel, event->type); + } + if(!button_panel->freeze_input && + (!(event->type == InputTypePress) && !(event->type == InputTypeRelease))) { switch(event->key) { case InputKeyUp: consumed = true; @@ -387,10 +396,6 @@ static bool button_panel_view_input_callback(InputEvent* event, void* context) { consumed = true; button_panel_process_right(button_panel); break; - case InputKeyOk: - consumed = true; - button_panel_process_ok(button_panel); - break; default: break; } diff --git a/applications/services/gui/modules/button_panel.h b/applications/services/gui/modules/button_panel.h index 1218222b88..159e143362 100644 --- a/applications/services/gui/modules/button_panel.h +++ b/applications/services/gui/modules/button_panel.h @@ -15,7 +15,7 @@ extern "C" { typedef struct ButtonPanel ButtonPanel; /** Callback type to call for handling selecting button_panel items */ -typedef void (*ButtonItemCallback)(void* context, uint32_t index); +typedef void (*ButtonItemCallback)(void* context, uint32_t index, InputType type); /** Allocate new button_panel module. *