|
| 1 | +#include "../picopass_i.h" |
| 2 | +#include <lib/toolbox/random_name.h> |
| 3 | +#include <gui/modules/validators.h> |
| 4 | +#include <toolbox/path.h> |
| 5 | + |
| 6 | +void picopass_scene_key_input_text_input_callback(void* context) { |
| 7 | + Picopass* picopass = context; |
| 8 | + |
| 9 | + picopass->dev->dev_data.pacs.elite_kdf = true; |
| 10 | + memcpy(picopass->dev->dev_data.pacs.key, picopass->byte_input_store, RFAL_PICOPASS_BLOCK_LEN); |
| 11 | + view_dispatcher_send_custom_event(picopass->view_dispatcher, PicopassCustomEventByteInputDone); |
| 12 | +} |
| 13 | + |
| 14 | +void picopass_scene_key_input_on_enter(void* context) { |
| 15 | + Picopass* picopass = context; |
| 16 | + |
| 17 | + ByteInput* byte_input = picopass->byte_input; |
| 18 | + byte_input_set_header_text(byte_input, "Enter The Key In Hex"); |
| 19 | + byte_input_set_result_callback( |
| 20 | + byte_input, |
| 21 | + picopass_scene_key_input_text_input_callback, |
| 22 | + NULL, |
| 23 | + picopass, |
| 24 | + picopass->byte_input_store, |
| 25 | + RFAL_PICOPASS_BLOCK_LEN); |
| 26 | + view_dispatcher_switch_to_view(picopass->view_dispatcher, PicopassViewByteInput); |
| 27 | +} |
| 28 | + |
| 29 | +bool picopass_scene_key_input_on_event(void* context, SceneManagerEvent event) { |
| 30 | + Picopass* picopass = context; |
| 31 | + bool consumed = false; |
| 32 | + |
| 33 | + if(event.type == SceneManagerEventTypeCustom) { |
| 34 | + if(event.event == PicopassCustomEventByteInputDone) { |
| 35 | + scene_manager_next_scene(picopass->scene_manager, PicopassSceneWriteKey); |
| 36 | + consumed = true; |
| 37 | + } |
| 38 | + } |
| 39 | + return consumed; |
| 40 | +} |
| 41 | + |
| 42 | +void picopass_scene_key_input_on_exit(void* context) { |
| 43 | + Picopass* picopass = context; |
| 44 | + |
| 45 | + // Clear view |
| 46 | + byte_input_set_result_callback(picopass->byte_input, NULL, NULL, NULL, NULL, 0); |
| 47 | + byte_input_set_header_text(picopass->byte_input, ""); |
| 48 | +} |
0 commit comments