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
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SubmenuIndexSave,
|
|
|
|
SubmenuIndexEmulate,
|
2023-03-02 13:23:33 +00:00
|
|
|
SubmenuIndexViewData,
|
|
|
|
SubmenuIndexWriteBlank,
|
|
|
|
SubmenuIndexWriteCopy,
|
2022-05-06 16:48:39 +00:00
|
|
|
} SubmenuIndex;
|
|
|
|
|
|
|
|
void ibutton_scene_read_key_menu_submenu_callback(void* context, uint32_t index) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
view_dispatcher_send_custom_event(ibutton->view_dispatcher, index);
|
|
|
|
}
|
|
|
|
|
|
|
|
void ibutton_scene_read_key_menu_on_enter(void* context) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
Submenu* submenu = ibutton->submenu;
|
|
|
|
|
2023-03-02 13:23:33 +00:00
|
|
|
const iButtonProtocolId protocol_id = ibutton_key_get_protocol_id(ibutton->key);
|
|
|
|
const uint32_t features = ibutton_protocols_get_features(ibutton->protocols, protocol_id);
|
|
|
|
|
2022-05-06 16:48:39 +00:00
|
|
|
submenu_add_item(
|
|
|
|
submenu, "Save", SubmenuIndexSave, ibutton_scene_read_key_menu_submenu_callback, ibutton);
|
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"Emulate",
|
|
|
|
SubmenuIndexEmulate,
|
|
|
|
ibutton_scene_read_key_menu_submenu_callback,
|
|
|
|
ibutton);
|
2023-03-02 13:23:33 +00:00
|
|
|
|
|
|
|
if(features & iButtonProtocolFeatureExtData) {
|
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"View Data",
|
|
|
|
SubmenuIndexViewData,
|
|
|
|
ibutton_scene_read_key_menu_submenu_callback,
|
|
|
|
ibutton);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(features & iButtonProtocolFeatureWriteBlank) {
|
2022-05-06 16:48:39 +00:00
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
2023-03-02 13:23:33 +00:00
|
|
|
"Write Blank",
|
|
|
|
SubmenuIndexWriteBlank,
|
2022-05-06 16:48:39 +00:00
|
|
|
ibutton_scene_read_key_menu_submenu_callback,
|
|
|
|
ibutton);
|
|
|
|
}
|
2023-03-02 13:23:33 +00:00
|
|
|
|
|
|
|
if(features & iButtonProtocolFeatureWriteCopy) {
|
|
|
|
submenu_add_item(
|
|
|
|
submenu,
|
|
|
|
"Write Copy",
|
|
|
|
SubmenuIndexWriteCopy,
|
|
|
|
ibutton_scene_read_key_menu_submenu_callback,
|
|
|
|
ibutton);
|
|
|
|
}
|
|
|
|
|
[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, iButtonSceneReadKeyMenu));
|
2022-05-06 16:48:39 +00:00
|
|
|
view_dispatcher_switch_to_view(ibutton->view_dispatcher, iButtonViewSubmenu);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ibutton_scene_read_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, iButtonSceneReadKeyMenu, event.event);
|
2022-05-06 16:48:39 +00:00
|
|
|
consumed = true;
|
2023-03-02 13:23:33 +00:00
|
|
|
|
2022-05-06 16:48:39 +00:00
|
|
|
if(event.event == SubmenuIndexSave) {
|
2023-03-02 13:23:33 +00:00
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneSaveName);
|
2022-05-06 16:48:39 +00:00
|
|
|
} else 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 == SubmenuIndexViewData) {
|
|
|
|
scene_manager_next_scene(scene_manager, iButtonSceneViewData);
|
|
|
|
} 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
|
|
|
}
|
2023-03-02 13:23:33 +00:00
|
|
|
} else if(event.event == SceneManagerEventTypeBack) {
|
|
|
|
scene_manager_set_scene_state(
|
|
|
|
ibutton->scene_manager, iButtonSceneReadKeyMenu, SubmenuIndexSave);
|
|
|
|
// Event is not consumed
|
2022-05-06 16:48:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return consumed;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ibutton_scene_read_key_menu_on_exit(void* context) {
|
|
|
|
iButton* ibutton = context;
|
|
|
|
submenu_reset(ibutton->submenu);
|
|
|
|
}
|