Skip to content

Commit

Permalink
plugins/ir_remote: Do not depend on config file ordering
Browse files Browse the repository at this point in the history
Rewind to the start of the file before reading each key. This enables
using a custom key order in the config file.
  • Loading branch information
friebel committed Feb 19, 2023
1 parent e6a7e86 commit 9d64e58
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions applications/plugins/ir_remote/infrared_remote_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ int32_t infrared_remote_app(void* p) {
//set missing filenames to N/A
//assign button signals
size_t index = 0;

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "UP", app->up_button)) {
FURI_LOG_W(TAG, "Could not read UP string");
furi_string_set(app->up_button, "N/A");
Expand All @@ -244,6 +246,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "DOWN", app->down_button)) {
FURI_LOG_W(TAG, "Could not read DOWN string");
furi_string_set(app->down_button, "N/A");
Expand All @@ -258,6 +261,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "LEFT", app->left_button)) {
FURI_LOG_W(TAG, "Could not read LEFT string");
furi_string_set(app->left_button, "N/A");
Expand All @@ -272,6 +276,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "RIGHT", app->right_button)) {
FURI_LOG_W(TAG, "Could not read RIGHT string");
furi_string_set(app->right_button, "N/A");
Expand All @@ -286,6 +291,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "OK", app->ok_button)) {
FURI_LOG_W(TAG, "Could not read OK string");
furi_string_set(app->ok_button, "N/A");
Expand All @@ -300,6 +306,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "BACK", app->back_button)) {
FURI_LOG_W(TAG, "Could not read BACK string");
furi_string_set(app->back_button, "N/A");
Expand All @@ -314,6 +321,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "UPHOLD", app->up_hold_button)) {
FURI_LOG_W(TAG, "Could not read UPHOLD string");
furi_string_set(app->up_hold_button, "N/A");
Expand All @@ -328,6 +336,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "DOWNHOLD", app->down_hold_button)) {
FURI_LOG_W(TAG, "Could not read DOWNHOLD string");
furi_string_set(app->down_hold_button, "N/A");
Expand All @@ -342,6 +351,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "LEFTHOLD", app->left_hold_button)) {
FURI_LOG_W(TAG, "Could not read LEFTHOLD string");
furi_string_set(app->left_hold_button, "N/A");
Expand All @@ -356,6 +366,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "RIGHTHOLD", app->right_hold_button)) {
FURI_LOG_W(TAG, "Could not read RIGHTHOLD string");
furi_string_set(app->right_hold_button, "N/A");
Expand All @@ -370,6 +381,7 @@ int32_t infrared_remote_app(void* p) {
}
}

flipper_format_rewind(ff);
if(!flipper_format_read_string(ff, "OKHOLD", app->ok_hold_button)) {
FURI_LOG_W(TAG, "Could not read OKHOLD string");
furi_string_set(app->ok_hold_button, "N/A");
Expand Down

0 comments on commit 9d64e58

Please sign in to comment.