mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-18 16:53:45 +00:00
a8acfcabb4
* Add skeleton for infrared C port, rename old app * Add scene stubs * Add more views * Misc changes * Add remote and signal class stubs * Complete infrared signal class * Add remote button class stub * Check if button contains a signal during destruction * Complete infrared signal class more * Implement remote storing * Implement remote loading * Fix error handling * Implement remote transmitting * Rename scene * Canonise event consumption * Implement remote learning (stub) * Implement learn success screen (stub) * Implement AskBack scene * Improve remote saving&loading * Fix remote file name * Add LearnDone scene * Switch from Remote scene correctly * Add SceneButtonSelect * Remove unneeded assert * Add new SceneManager method * Use new SceneManager method in Infrared * Implement renaming of buttons and remotes * Implement deleting of buttons and remotes * Add universal remotes list * Add brute force code * Brute force code improvements * Partially implement Universal Remote GUI * Fix wrong singnal handling * Fully implement Universal Remote * Use standard custom events everywhere * Return infrared CLI * Remove old Infrared app * Change container name * Fix scene order * Put ButtonPanel into stack only when needed * Show loading animation during slow operations * Do not hardcode Loading widget coordinates * Switch Loading widget orientation as needed * Save Start scene state * Save Remote scene state * Save Edit scene state * Save EditButtonSelect scene state * Do not use scene state * Use string_t instead of const char* for brevity * Fix memory leak * Fix saving raw remotes * Add Infrared debug menu * Add debug view * Move Infrared monitor into Infrared application * Remove old Infrared monitor app * Use common signal received callback everywhere
92 lines
4 KiB
C
92 lines
4 KiB
C
#include "../../infrared_i.h"
|
|
|
|
#include <dolphin/dolphin.h>
|
|
|
|
void infrared_scene_universal_common_item_callback(void* context, uint32_t index) {
|
|
Infrared* infrared = context;
|
|
uint32_t event = infrared_custom_event_pack(InfraredCustomEventTypeButtonSelected, index);
|
|
view_dispatcher_send_custom_event(infrared->view_dispatcher, event);
|
|
}
|
|
|
|
static void infrared_scene_universal_common_progress_back_callback(void* context) {
|
|
Infrared* infrared = context;
|
|
uint32_t event = infrared_custom_event_pack(InfraredCustomEventTypeBackPressed, -1);
|
|
view_dispatcher_send_custom_event(infrared->view_dispatcher, event);
|
|
}
|
|
|
|
static void infrared_scene_universal_common_show_popup(Infrared* infrared, uint32_t record_count) {
|
|
ViewStack* view_stack = infrared->view_stack;
|
|
InfraredProgressView* progress = infrared->progress;
|
|
infrared_progress_view_set_progress_total(progress, record_count);
|
|
infrared_progress_view_set_back_callback(
|
|
progress, infrared_scene_universal_common_progress_back_callback, infrared);
|
|
view_stack_add_view(view_stack, infrared_progress_view_get_view(progress));
|
|
}
|
|
|
|
static void infrared_scene_universal_common_hide_popup(Infrared* infrared) {
|
|
ViewStack* view_stack = infrared->view_stack;
|
|
InfraredProgressView* progress = infrared->progress;
|
|
view_stack_remove_view(view_stack, infrared_progress_view_get_view(progress));
|
|
}
|
|
|
|
void infrared_scene_universal_common_on_enter(void* context) {
|
|
Infrared* infrared = context;
|
|
view_stack_add_view(infrared->view_stack, button_panel_get_view(infrared->button_panel));
|
|
}
|
|
|
|
bool infrared_scene_universal_common_on_event(void* context, SceneManagerEvent event) {
|
|
Infrared* infrared = context;
|
|
SceneManager* scene_manager = infrared->scene_manager;
|
|
InfraredBruteForce* brute_force = infrared->brute_force;
|
|
bool consumed = false;
|
|
|
|
if(infrared_brute_force_is_started(brute_force)) {
|
|
if(event.type == SceneManagerEventTypeTick) {
|
|
infrared_play_notification_message(infrared, InfraredNotificationMessageBlinkSend);
|
|
bool success = infrared_brute_force_send_next(brute_force);
|
|
if(success) {
|
|
success = infrared_progress_view_increase_progress(infrared->progress);
|
|
}
|
|
if(!success) {
|
|
infrared_brute_force_stop(brute_force);
|
|
infrared_scene_universal_common_hide_popup(infrared);
|
|
}
|
|
consumed = true;
|
|
} else if(event.type == SceneManagerEventTypeCustom) {
|
|
if(infrared_custom_event_get_type(event.event) == InfraredCustomEventTypeBackPressed) {
|
|
infrared_brute_force_stop(brute_force);
|
|
infrared_scene_universal_common_hide_popup(infrared);
|
|
consumed = true;
|
|
}
|
|
}
|
|
} else {
|
|
if(event.type == SceneManagerEventTypeBack) {
|
|
scene_manager_previous_scene(scene_manager);
|
|
consumed = true;
|
|
} else if(event.type == SceneManagerEventTypeCustom) {
|
|
if(infrared_custom_event_get_type(event.event) ==
|
|
InfraredCustomEventTypeButtonSelected) {
|
|
uint32_t record_count;
|
|
if(infrared_brute_force_start(
|
|
brute_force, infrared_custom_event_get_value(event.event), &record_count)) {
|
|
DOLPHIN_DEED(DolphinDeedIrBruteForce);
|
|
infrared_scene_universal_common_show_popup(infrared, record_count);
|
|
infrared_play_notification_message(
|
|
infrared, InfraredNotificationMessageBlinkSend);
|
|
} else {
|
|
scene_manager_previous_scene(scene_manager);
|
|
}
|
|
consumed = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void infrared_scene_universal_common_on_exit(void* context) {
|
|
Infrared* infrared = context;
|
|
ButtonPanel* button_panel = infrared->button_panel;
|
|
view_stack_remove_view(infrared->view_stack, button_panel_get_view(button_panel));
|
|
button_panel_reset(button_panel);
|
|
}
|