picopass_scene_key_input.c 1.6 KB

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