2022-01-05 16:10:18 +00:00
|
|
|
#include "../irda_app.h"
|
2021-06-02 15:16:05 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SubmenuIndexUniversalLibrary,
|
|
|
|
SubmenuIndexLearnNewRemote,
|
|
|
|
SubmenuIndexSavedRemotes,
|
|
|
|
} SubmenuIndex;
|
|
|
|
|
|
|
|
static void submenu_callback(void* context, uint32_t index) {
|
|
|
|
IrdaApp* app = static_cast<IrdaApp*>(context);
|
|
|
|
IrdaAppEvent event;
|
|
|
|
|
|
|
|
event.type = IrdaAppEvent::Type::MenuSelected;
|
|
|
|
event.payload.menu_index = index;
|
|
|
|
|
|
|
|
app->get_view_manager()->send_event(&event);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IrdaAppSceneStart::on_enter(IrdaApp* app) {
|
|
|
|
IrdaAppViewManager* view_manager = app->get_view_manager();
|
|
|
|
Submenu* submenu = view_manager->get_submenu();
|
|
|
|
|
|
|
|
submenu_add_item(
|
|
|
|
submenu, "Universal library", SubmenuIndexUniversalLibrary, submenu_callback, app);
|
|
|
|
submenu_add_item(
|
|
|
|
submenu, "Learn new remote", SubmenuIndexLearnNewRemote, submenu_callback, app);
|
|
|
|
submenu_add_item(submenu, "Saved remotes", SubmenuIndexSavedRemotes, submenu_callback, app);
|
2021-06-09 13:04:49 +00:00
|
|
|
submenu_set_selected_item(submenu, submenu_item_selected);
|
|
|
|
submenu_item_selected = 0;
|
2021-06-02 15:16:05 +00:00
|
|
|
|
|
|
|
view_manager->switch_to(IrdaAppViewManager::ViewType::Submenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IrdaAppSceneStart::on_event(IrdaApp* app, IrdaAppEvent* event) {
|
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event->type == IrdaAppEvent::Type::MenuSelected) {
|
2021-06-09 13:04:49 +00:00
|
|
|
submenu_item_selected = event->payload.menu_index;
|
2021-06-02 15:16:05 +00:00
|
|
|
switch(event->payload.menu_index) {
|
|
|
|
case SubmenuIndexUniversalLibrary:
|
|
|
|
app->switch_to_next_scene(IrdaApp::Scene::Universal);
|
|
|
|
break;
|
|
|
|
case SubmenuIndexLearnNewRemote:
|
|
|
|
app->set_learn_new_remote(true);
|
|
|
|
app->switch_to_next_scene(IrdaApp::Scene::Learn);
|
|
|
|
break;
|
|
|
|
case SubmenuIndexSavedRemotes:
|
|
|
|
app->switch_to_next_scene(IrdaApp::Scene::RemoteList);
|
|
|
|
break;
|
2021-06-09 13:04:49 +00:00
|
|
|
default:
|
|
|
|
furi_assert(0);
|
|
|
|
break;
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|
|
|
|
consumed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IrdaAppSceneStart::on_exit(IrdaApp* app) {
|
|
|
|
IrdaAppViewManager* view_manager = app->get_view_manager();
|
|
|
|
Submenu* submenu = view_manager->get_submenu();
|
|
|
|
|
2021-07-22 00:07:00 +00:00
|
|
|
app->get_remote_manager()->reset_remote();
|
2022-01-21 17:32:03 +00:00
|
|
|
submenu_reset(submenu);
|
2021-06-02 15:16:05 +00:00
|
|
|
}
|