desktop_scene_debug.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #include "../desktop_i.h"
  2. #include "../views/desktop_debug.h"
  3. #include <dolphin/dolphin.h>
  4. #include <dolphin/helpers/dolphin_deed.h>
  5. void desktop_scene_debug_callback(DesktopDebugEvent event, void* context) {
  6. Desktop* desktop = (Desktop*)context;
  7. view_dispatcher_send_custom_event(desktop->view_dispatcher, event);
  8. }
  9. void desktop_scene_debug_on_enter(void* context) {
  10. Desktop* desktop = (Desktop*)context;
  11. desktop_debug_get_dolphin_data(desktop->debug_view);
  12. desktop_debug_set_callback(desktop->debug_view, desktop_scene_debug_callback, desktop);
  13. view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewDebug);
  14. }
  15. bool desktop_scene_debug_on_event(void* context, SceneManagerEvent event) {
  16. Desktop* desktop = (Desktop*)context;
  17. Dolphin* dolphin = furi_record_open("dolphin");
  18. bool consumed = false;
  19. if(event.type == SceneManagerEventTypeCustom) {
  20. switch(event.event) {
  21. case DesktopDebugEventExit:
  22. scene_manager_next_scene(desktop->scene_manager, DesktopSceneMain);
  23. dolphin_flush(dolphin);
  24. consumed = true;
  25. break;
  26. case DesktopDebugEventDeed:
  27. dolphin_deed(dolphin, DolphinDeedIButtonEmulate);
  28. desktop_debug_get_dolphin_data(desktop->debug_view);
  29. consumed = true;
  30. break;
  31. case DesktopDebugEventWrongDeed:
  32. dolphin_deed(dolphin, DolphinDeedWrong);
  33. desktop_debug_get_dolphin_data(desktop->debug_view);
  34. consumed = true;
  35. break;
  36. case DesktopDebugEventSaveState:
  37. dolphin_flush(dolphin);
  38. consumed = true;
  39. break;
  40. default:
  41. break;
  42. }
  43. }
  44. furi_record_close("dolphin");
  45. return consumed;
  46. }
  47. void desktop_scene_debug_on_exit(void* context) {
  48. Desktop* desktop = (Desktop*)context;
  49. desktop_debug_reset_screen_idx(desktop->debug_view);
  50. desktop_start_new_idle_animation(desktop->animation);
  51. }