2022-05-06 16:48:39 +00:00
|
|
|
#include "../ibutton_i.h"
|
2022-10-28 07:18:41 +00:00
|
|
|
#include <dolphin/dolphin.h>
|
2022-05-06 16:48:39 +00:00
|
|
|
|
|
|
|
enum SubmenuIndex {
|
|
|
|
SubmenuIndexEmulate,
|
2023-03-02 13:23:33 +00:00
|
|
|
SubmenuIndexWriteBlank,
|
|
|
|
SubmenuIndexWriteCopy,
|
2022-05-06 16:48:39 +00:00
|
|
|
SubmenuIndexEdit,
|
|
|
|
SubmenuIndexDelete,
|
|
|
|
SubmenuIndexInfo,
|
|
|
|
};
|
|
|
|
|
|
|
|
void ibutton_scene_saved_key_menu_on_enter(void* context) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
Submenu* submenu = ibutton->submenu;
|
|
|
|
|
2023-03-02 13:23:33 +00:00
|
|
|
const uint32_t features = ibutton_protocols_get_features(
|
|
|
|
ibutton->protocols, ibutton_key_get_protocol_id(ibutton->key));
|
|
|
|
|
|
|
|
submenu_add_item(submenu, "Emulate", SubmenuIndexEmulate, ibutton_submenu_callback, ibutton);
|
|
|
|
|
|
|
|
if(features & iButtonProtocolFeatureWriteBlank) {
|
2022-05-06 16:48:39 +00:00
|
|
|
submenu_add_item(
|
2023-03-02 13:23:33 +00:00
|
|
|
submenu, "Write Blank", SubmenuIndexWriteBlank, ibutton_submenu_callback, ibutton);
|
2022-05-06 16:48:39 +00:00
|
|
|
}
|
2023-03-02 13:23:33 +00:00
|
|
|
|
|
|
|
if(features & iButtonProtocolFeatureWriteCopy) {
|
|
|
|
submenu_add_item(
|
|
|
|
submenu, "Write Copy", SubmenuIndexWriteCopy, ibutton_submenu_callback, ibutton);
|
|
|
|
}
|
|
|
|
|
|
|
|
submenu_add_item(submenu, "Edit", SubmenuIndexEdit, ibutton_submenu_callback, ibutton);
|
|
|
|
submenu_add_item(submenu, "Delete", SubmenuIndexDelete, ibutton_submenu_callback, ibutton);
|
|
|
|
submenu_add_item(submenu, "Info", SubmenuIndexInfo, ibutton_submenu_callback, ibutton);
|
2022-05-06 16:48:39 +00:00
|
|
|
|
[FL-1962, FL-2464, FL-2465, FL-2466, FL-2560, FL-2637, FL-2595] Ibutton, Infrared, LfRFID GUI fixes (#1392)
* Ibutton, Infrared, LfRFID GUI fixes
* Loading screens update
Co-authored-by: あく <alleteam@gmail.com>
2022-07-17 07:41:16 +00:00
|
|
|
submenu_set_selected_item(
|
|
|
|
submenu, scene_manager_get_scene_state(ibutton->scene_manager, iButtonSceneSavedKeyMenu));
|
2022-05-06 16:48:39 +00:00
|
|
|
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ibutton_scene_saved_key_menu_on_event(void* context, SceneManagerEvent event) {
|
|
|
|
iButton* ibutton = context;
|
2023-03-02 13:23:33 +00:00
|
|
|
SceneManager* scene_manager = ibutton->scene_manager;
|
2022-05-06 16:48:39 +00:00
|
|
|
bool consumed = false;
|
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
2023-03-02 13:23:33 +00:00
|
|
|
scene_manager_set_scene_state(scene_manager, iButtonSceneSavedKeyMenu, event.event);
|
2022-05-06 16:48:39 +00:00
|
|
|
consumed = true;
|
|
|
|
if(event.event == SubmenuIndexEmulate) {
|
2023-03-02 13:23:33 +00:00
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneEmulate);
|
2022-10-28 07:18:41 +00:00
|
|
|
DOLPHIN_DEED(DolphinDeedIbuttonEmulate);
|
2023-03-02 13:23:33 +00:00
|
|
|
} else if(event.event == SubmenuIndexWriteBlank) {
|
|
|
|
ibutton->write_mode = iButtonWriteModeBlank;
|
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneWrite);
|
|
|
|
} else if(event.event == SubmenuIndexWriteCopy) {
|
|
|
|
ibutton->write_mode = iButtonWriteModeCopy;
|
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneWrite);
|
2022-05-06 16:48:39 +00:00
|
|
|
} else if(event.event == SubmenuIndexEdit) {
|
2023-03-02 13:23:33 +00:00
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneAddValue);
|
2022-05-06 16:48:39 +00:00
|
|
|
} else if(event.event == SubmenuIndexDelete) {
|
2023-03-02 13:23:33 +00:00
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneDeleteConfirm);
|
2022-05-06 16:48:39 +00:00
|
|
|
} else if(event.event == SubmenuIndexInfo) {
|
2023-03-02 13:23:33 +00:00
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneInfo);
|
2022-05-06 16:48:39 +00:00
|
|
|
}
|
2023-03-02 13:23:33 +00:00
|
|
|
|
|
|
|
} else if(event.type == SceneManagerEventTypeBack) {
|
|
|
|
scene_manager_set_scene_state(
|
|
|
|
scene_manager, iButtonSceneSavedKeyMenu, SubmenuIndexEmulate);
|
|
|
|
// Event is not consumed
|
2022-05-06 16:48:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ibutton_scene_saved_key_menu_on_exit(void* context) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
submenu_reset(ibutton->submenu);
|
|
|
|
}
|