desktop_scene_debug.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. desktop_start_new_idle_animation(desktop->animation);
  30. consumed = true;
  31. break;
  32. case DesktopDebugEventWrongDeed:
  33. dolphin_deed(dolphin, DolphinDeedWrong);
  34. desktop_debug_get_dolphin_data(desktop->debug_view);
  35. desktop_start_new_idle_animation(desktop->animation);
  36. consumed = true;
  37. break;
  38. case DesktopDebugEventSaveState:
  39. dolphin_flush(dolphin);
  40. consumed = true;
  41. break;
  42. default:
  43. break;
  44. }
  45. }
  46. furi_record_close("dolphin");
  47. return consumed;
  48. }
  49. void desktop_scene_debug_on_exit(void* context) {
  50. Desktop* desktop = (Desktop*)context;
  51. desktop_debug_reset_screen_idx(desktop->debug_view);
  52. }