diff --git a/.flipcorg/gallery/screen7.png b/.flipcorg/gallery/screen7.png index d95d71c..81b3fc9 100644 Binary files a/.flipcorg/gallery/screen7.png and b/.flipcorg/gallery/screen7.png differ diff --git a/README.md b/README.md index 597a3c1..a036d19 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,9 @@

Advanced IR Remote App for Flipper Device

+ +

+ Version 1.3 - Changelog +

+

XRemote

@@ -58,16 +63,17 @@ Button name | Description `Play` | Play `Stop` | Stop - ## Alternative button names -In addition to the predefined names, `XRemote` uses alternative button names to make it as easy as possible to interact with different types of IR dumps. This means that if a button is not found in the file with the appropriate name, the application will try to find the same button with alternative names. Ensure this feature is enabled in the application settings before you use it. +In addition to the predefined names, `XRemote` uses alternative button names to make it as easy as possible to interact with different types of IR dumps. That means if a button with the appropriate name is not found in the file, the application will try to find the same button with alternative names. Ensure this feature is enabled in the application settings before you use it. -Alternate names are case insensitive and defined in the file: +The application stores and reads alternate names from the following file: ``` SD Card/apps_data/flipper_xremote/alt_names.cfg ``` -If this file does not exist, it will be created automatically with default values when the application is launched. You are free to remove, edit or add any values you want to this file. Here is the alt_names.cfg file with default contents: +If the `Alt-Names` option is enabled in the config and the file does not exist, it will be created automatically with default values during the application's startup. You can edit, add, or remove any button or alternate name values from this file. Button names must either have only the first uppercase or be entirely lowercase. As for alternate names, they are case-insensitive. The button can have one or several comma-separated alternate names. + +This is the default `alt_names.cfg` file: ``` Filetype: XRemote Alt-Names @@ -113,8 +119,10 @@ Play_pa: playpause,play,pause - Use deploy script from this repository to build and run the application on the device: ```bash - ./deploy.sh -b --fw=/path/to/the/firmware + ./deploy.sh --fw=/path/to/the/firmware -b -l ``` + + Do not use `-l` (link) option of you are building the project directly from the `applications_user` directory of the firmware. 2. If you don't have the firmware or the Linux please refer to the [official documentation](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/AppsOnSDCard.md) for build instructions. ## Progress diff --git a/docs/README.md b/docs/README.md index d35f29d..b359d69 100644 --- a/docs/README.md +++ b/docs/README.md @@ -51,9 +51,37 @@ Stop | Stop ## Alternative button names -In addition to the predefined names, XRemote uses alternative button names to make it as easy as possible to interact with different types of IR dumps. This means that if a button is not found in the file with the appropriate name, the application will try to find the same button with alternative names. Ensure this feature is enabled in the application settings before you use it. +In addition to the predefined names, XRemote uses alternative button names to make it as easy as possible to interact with different types of IR dumps. That means if a button with the appropriate name is not found in the file, the application will try to find the same button with alternative names. Ensure this feature is enabled in the application settings before you use it. -Alternate names are case insensitive and defined in the file: +The application stores and reads alternate names from the following file: SD_Card/apps_data/flipper_xremote/alt_names.cfg -If this file does not exist, it will be created automatically with default values when the application is launched. You are free to remove, edit or add any values you want to this file. \ No newline at end of file +If the Alt-Names option is enabled in the config and the file does not exist, it will be created automatically with default values during the application's startup. You can edit, add, or remove any button or alternate name values from this file. Button names must either have only the first uppercase or be entirely lowercase. As for alternate names, they are case-insensitive. The button can have one or several comma-separated alternate names. + +## Default alternative names + +Button name | Alternative names +------------|------------------- +Power | shutdown,off,on,standby +Setup | settings,config,cfg +Input | source,select +Menu | osd,gui +List | guide +Info | display +Mode | aspect,format +Back | return,exit +Ok | enter,select +Up | uparrow +Down | downarrow +Left | leftarrow +Right | rightarrow +Mute | silence,silent,unmute +Vol_up | vol+,volume+,volup,+ +Vol_dn | vol-,volume-,voldown,- +Ch_next | ch+,channel+,chup +Ch_prev | ch-,channel-,chdown +Next | next,skip,ffwd +Prev | prev,back,rewind,rew +Fast_fo | fastfwd,fastforward,ff +Fast_ba | fastback,fastrewind,fb +Play_pa | playpause,play,pause \ No newline at end of file diff --git a/docs/changelog.md b/docs/changelog.md index 8f0ac19..5ba6d60 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -3,8 +3,9 @@ Alternative names - Implemented alternative names functionality +- Implemented case-insensitive button search - Added Eject button support -- Fixed bugs +- Fixed bugs and refactored code ## v1.2 diff --git a/infrared/infrared_remote.c b/infrared/infrared_remote.c index 12066c1..1563ef0 100644 --- a/infrared/infrared_remote.c +++ b/infrared/infrared_remote.c @@ -91,9 +91,9 @@ InfraredRemoteButton* infrared_remote_get_button(InfraredRemote* remote, size_t bool infrared_remote_find_button_by_name(InfraredRemote* remote, const char* name, size_t* index) { for(size_t i = 0; i < InfraredButtonArray_size(remote->buttons); i++) { InfraredRemoteButton* button = *InfraredButtonArray_get(remote->buttons, i); - FuriString* firi_name = infrared_remote_button_get_furi_name(button); + FuriString* furi_name = infrared_remote_button_get_furi_name(button); - if(button && !furi_string_cmpi_str(firi_name, name)) { + if(button && !furi_string_cmpi_str(furi_name, name)) { *index = i; return true; } @@ -105,8 +105,8 @@ InfraredRemoteButton* infrared_remote_get_button_by_name(InfraredRemote* remote, const char* name) { for(size_t i = 0; i < InfraredButtonArray_size(remote->buttons); i++) { InfraredRemoteButton* button = *InfraredButtonArray_get(remote->buttons, i); - FuriString* firi_name = infrared_remote_button_get_furi_name(button); - if(button && !furi_string_cmpi_str(firi_name, name)) return button; + FuriString* furi_name = infrared_remote_button_get_furi_name(button); + if(button && !furi_string_cmpi_str(furi_name, name)) return button; } return NULL; } diff --git a/screens/settings_menu.png b/screens/settings_menu.png index 9c4ed5c..a038a56 100644 Binary files a/screens/settings_menu.png and b/screens/settings_menu.png differ diff --git a/views/xremote_common_view.c b/views/xremote_common_view.c index a4a43cc..1cc3d75 100644 --- a/views/xremote_common_view.c +++ b/views/xremote_common_view.c @@ -133,8 +133,8 @@ View* xremote_view_get_view(XRemoteView* rview) { return rview->view; } -InfraredRemoteButton* - infrared_remote_get_button_by_alt_name(InfraredRemote* remote, const char* name) { +static InfraredRemoteButton* + infrared_remote_get_button_by_alt_name(InfraredRemote* remote, const char* name, bool try_low) { Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* ff = flipper_format_buffered_file_alloc(storage); FuriString* header = furi_string_alloc(); @@ -142,6 +142,8 @@ InfraredRemoteButton* FURI_LOG_I(XREMOTE_APP_TAG, "loading alt_names file: \'%s\'", XREMOTE_ALT_NAMES); InfraredRemoteButton* button = NULL; + char key[XREMOTE_NAME_MAX] = {0}; + bool key_found = false; uint32_t version = 0; do { @@ -151,7 +153,20 @@ InfraredRemoteButton* if(!furi_string_equal(header, "XRemote Alt-Names") || (version != 1)) break; FuriString* value = furi_string_alloc(); - if(!flipper_format_read_string(ff, name, value)) break; + key_found = flipper_format_read_string(ff, name, value); + + if(!key_found) { + if(!try_low) break; + size_t i; + + /* Convert name to lowercase and try again */ + for(i = 0; name[i] != '\0' && i < sizeof(key) - 1; i++) { + key[i] = tolower(name[i]); + } + + key[i] = '\0'; + break; + } size_t start = 0; size_t posit = furi_string_search_str(value, ",", start); @@ -190,6 +205,8 @@ InfraredRemoteButton* furi_string_free(header); flipper_format_free(ff); + if(!key_found && try_low) return infrared_remote_get_button_by_alt_name(remote, key, false); + return button; } @@ -202,7 +219,7 @@ InfraredRemoteButton* xremote_view_get_button_by_name(XRemoteView* rview, const InfraredRemoteButton* button = infrared_remote_get_button_by_name(buttons->remote, name); if(button == NULL && settings->alt_names) - button = infrared_remote_get_button_by_alt_name(buttons->remote, name); + button = infrared_remote_get_button_by_alt_name(buttons->remote, name, true); return button; } diff --git a/views/xremote_common_view.h b/views/xremote_common_view.h index 5b591e3..7a6b2e7 100644 --- a/views/xremote_common_view.h +++ b/views/xremote_common_view.h @@ -21,7 +21,7 @@ #include "../infrared/infrared_remote.h" #define XREMOTE_BUTTON_COUNT 27 -#define XREMOTE_NAME_MAX 16 +#define XREMOTE_NAME_MAX 32 #define XREMOTE_COMMAND_POWER "Power" #define XREMOTE_COMMAND_EJECT "Eject" diff --git a/xremote.c b/xremote.c index 3b1b860..e6fee34 100644 --- a/xremote.c +++ b/xremote.c @@ -81,7 +81,6 @@ int32_t xremote_main(void* p) { /* Allocate context and main application */ XRemoteAppContext* context = xremote_app_context_alloc(p); XRemoteApp* app = xremote_app_alloc(context); - xremote_app_alt_names_check_and_store(); /* Allocate and build the menu */ xremote_app_submenu_alloc(app, XRemoteViewSubmenu, xremote_exit_callback); diff --git a/xremote_app.c b/xremote_app.c index d9fb117..84604ef 100644 --- a/xremote_app.c +++ b/xremote_app.c @@ -148,7 +148,7 @@ bool xremote_app_extension_store(XRemoteAppButtons* buttons, FuriString* path) { return success; } -bool xremote_app_alt_names_check_and_store() { +bool xremote_app_alt_names_check_and_init() { Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* ff = flipper_format_file_alloc(storage); bool success = false; @@ -353,6 +353,9 @@ XRemoteAppContext* xremote_app_context_alloc(void* arg) { ctx->app_settings = xremote_app_settings_alloc(); xremote_app_settings_load(ctx->app_settings); + /* Initialize alternative names */ + if(ctx->app_settings->alt_names) xremote_app_alt_names_check_and_init(); + /* Allocate and setup view dispatcher */ ctx->view_dispatcher = view_dispatcher_alloc(); view_dispatcher_enable_queue(ctx->view_dispatcher); diff --git a/xremote_app.h b/xremote_app.h index 51a8aac..123903f 100644 --- a/xremote_app.h +++ b/xremote_app.h @@ -121,7 +121,7 @@ XRemoteAppButtons* xremote_app_buttons_load(XRemoteAppContext* app_ctx); bool xremote_app_extension_store(XRemoteAppButtons* buttons, FuriString* path); bool xremote_app_extension_load(XRemoteAppButtons* buttons, FuriString* path); -bool xremote_app_alt_names_check_and_store(); +bool xremote_app_alt_names_check_and_init(); ////////////////////////////////////////////////////////////////////////////// // XRemote application factory diff --git a/xremote_settings.c b/xremote_settings.c index 2710f7d..7908c91 100644 --- a/xremote_settings.c +++ b/xremote_settings.c @@ -73,6 +73,7 @@ static void infrared_settings_alt_names_changed(VariableItem* item) { settings->alt_names = variable_item_get_current_value_index(item); const char* alt_names_str = xremote_app_get_alt_names_str(settings->alt_names); + if(settings->alt_names) xremote_app_alt_names_check_and_init(); variable_item_set_current_value_text(item, alt_names_str); xremote_app_settings_store(settings); }