mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-12-18 08:43:10 +00:00
c8180747db
* Do not load all signals at once (Draft) * Minor cleanup * Refactor remote renaming * Improve function signatures * Rename infrared_remote functions * Optimise signal loading * Implement adding signals to remote * Add read_name() method * Deprecate a function * Partially implement deleting signals (draft) * Use m-array instead of m-list for signal name directory * Use plain C strings instead of furi_string * Implement deleting signals * Implement deleting signals via generalised callback * Implement renaming signals * Rename some types * Some more renaming * Remove unused type * Implement inserting signals (internal use) * Improve InfraredMoveView * Send an event to move a signal * Remove unused type * Implement moving signals * Implement creating new remotes with one signal * Un-deprecate and rename a function * Add InfraredRemote API docs * Add InfraredSignal API docs * Better error messages * Show progress pop-up when moving buttons in a remote * Copy labels to the InfraredMoveView to avoid pointer invalidation * Improve file selection scene * Show progress pop-up when renaming buttons in a remote * Refactor a scene * Show progress when deleting a button from remote * Use a random name for temp files * Add docs to infrared_brute_force.h * Rename Infrared type to InfraredApp * Add docs to infrared_app_i.h Co-authored-by: あく <alleteam@gmail.com>
69 lines
2.5 KiB
C
69 lines
2.5 KiB
C
#include "../infrared_app_i.h"
|
|
|
|
static void infrared_scene_edit_move_button_callback(
|
|
uint32_t index_old,
|
|
uint32_t index_new,
|
|
void* context) {
|
|
InfraredApp* infrared = context;
|
|
furi_assert(infrared);
|
|
|
|
infrared->app_state.prev_button_index = index_old;
|
|
infrared->app_state.current_button_index = index_new;
|
|
|
|
view_dispatcher_send_custom_event(
|
|
infrared->view_dispatcher, InfraredCustomEventTypeButtonSelected);
|
|
}
|
|
|
|
void infrared_scene_edit_move_on_enter(void* context) {
|
|
InfraredApp* infrared = context;
|
|
InfraredRemote* remote = infrared->remote;
|
|
|
|
for(size_t i = 0; i < infrared_remote_get_signal_count(remote); ++i) {
|
|
infrared_move_view_add_item(
|
|
infrared->move_view, infrared_remote_get_signal_name(remote, i));
|
|
}
|
|
|
|
infrared_move_view_set_callback(
|
|
infrared->move_view, infrared_scene_edit_move_button_callback, infrared);
|
|
|
|
view_set_orientation(view_stack_get_view(infrared->view_stack), ViewOrientationHorizontal);
|
|
view_stack_add_view(infrared->view_stack, infrared_move_view_get_view(infrared->move_view));
|
|
|
|
view_dispatcher_switch_to_view(infrared->view_dispatcher, InfraredViewStack);
|
|
}
|
|
|
|
bool infrared_scene_edit_move_on_event(void* context, SceneManagerEvent event) {
|
|
InfraredApp* infrared = context;
|
|
bool consumed = false;
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
|
if(event.event == InfraredCustomEventTypeButtonSelected) {
|
|
infrared_show_loading_popup(infrared, true);
|
|
const bool button_moved = infrared_remote_move_signal(
|
|
infrared->remote,
|
|
infrared->app_state.prev_button_index,
|
|
infrared->app_state.current_button_index);
|
|
infrared_show_loading_popup(infrared, false);
|
|
|
|
if(!button_moved) {
|
|
infrared_show_error_message(
|
|
infrared,
|
|
"Failed to move\n\"%s\"",
|
|
infrared_remote_get_signal_name(
|
|
infrared->remote, infrared->app_state.current_button_index));
|
|
scene_manager_search_and_switch_to_previous_scene(
|
|
infrared->scene_manager, InfraredSceneRemoteList);
|
|
}
|
|
|
|
consumed = true;
|
|
}
|
|
}
|
|
|
|
return consumed;
|
|
}
|
|
|
|
void infrared_scene_edit_move_on_exit(void* context) {
|
|
InfraredApp* infrared = context;
|
|
view_stack_remove_view(infrared->view_stack, infrared_move_view_get_view(infrared->move_view));
|
|
infrared_move_view_reset(infrared->move_view);
|
|
}
|