mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 04:34:43 +04:00
Merge remote-tracking branch 'OFW/dev' into dev
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <gui/canvas.h>
|
||||
#include <gui/elements.h>
|
||||
#include <input/input.h>
|
||||
|
||||
#include <furi.h>
|
||||
#include <furi_hal_resources.h>
|
||||
@@ -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);
|
||||
|
||||
@@ -358,7 +360,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(
|
||||
@@ -371,7 +373,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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,8 +381,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;
|
||||
@@ -398,10 +407,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;
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user