infrared_scene_rpc.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #include "../infrared_i.h"
  2. #include "gui/canvas.h"
  3. void infrared_scene_rpc_on_enter(void* context) {
  4. Infrared* infrared = context;
  5. Popup* popup = infrared->popup;
  6. popup_set_header(popup, "Infrared", 82, 28, AlignCenter, AlignBottom);
  7. popup_set_text(popup, "RPC mode", 82, 32, AlignCenter, AlignTop);
  8. popup_set_icon(popup, 2, 14, &I_Warning_30x23); // TODO: icon
  9. popup_set_context(popup, context);
  10. popup_set_callback(popup, infrared_popup_closed_callback);
  11. view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewPopup);
  12. notification_message(infrared->notifications, &sequence_display_backlight_on);
  13. }
  14. bool infrared_scene_rpc_on_event(void* context, SceneManagerEvent event) {
  15. Infrared* infrared = context;
  16. bool consumed = false;
  17. if(event.type == SceneManagerEventTypeCustom) {
  18. consumed = true;
  19. if(event.event == InfraredCustomEventTypeBackPressed) {
  20. view_dispatcher_stop(infrared->view_dispatcher);
  21. } else if(event.event == InfraredCustomEventTypePopupClosed) {
  22. view_dispatcher_stop(infrared->view_dispatcher);
  23. } else if(event.event == InfraredCustomEventTypeRpcLoaded) {
  24. const char* remote_name = infrared_remote_get_name(infrared->remote);
  25. infrared_text_store_set(infrared, 0, "loaded\n%s", remote_name);
  26. popup_set_text(
  27. infrared->popup, infrared->text_store[0], 82, 32, AlignCenter, AlignTop);
  28. }
  29. }
  30. return consumed;
  31. }
  32. void infrared_scene_rpc_on_exit(void* context) {
  33. Infrared* infrared = context;
  34. popup_reset(infrared->popup);
  35. }