@@ -57,6 +57,10 @@ extern "C" {
5757#include < iostream>
5858#include " WiFiRSSIMonitor.hpp"
5959#include " gsmenu/gs_system.h"
60+ #include " gsmenu/air_actions.h"
61+ #include " gsmenu/gs_actions.h"
62+ #include " menu.h"
63+
6064
6165#define READ_BUF_SIZE (1024 *1024 ) // SZ_1M https://github.com/rockchip-linux/mpp/blob/ed377c99a733e2cdbcc457a6aa3f0fcd438a9dff/osal/inc/mpp_common.h#L179
6266#define MAX_FRAMES 24 // min 16 and 20+ recommended (mpp/readme.txt)
@@ -104,7 +108,10 @@ const char* unix_socket = NULL;
104108char * dvr_template = NULL ;
105109Dvr *dvr = NULL ;
106110OsSensors os_sensors; // TODO: pass as argument to `main_loop`
107-
111+ MenuAction airactions[MAX_ACTIONS];
112+ size_t airactions_count;
113+ MenuAction gsactions[MAX_ACTIONS];
114+ size_t gsactions_count;
108115
109116// Add global variables for plane id overrides
110117uint32_t video_plane_id_override = 0 ;
@@ -924,6 +931,52 @@ int main(int argc, char **argv)
924931 if (config[" gsmenu" ][" enabled" ]) {
925932 gsmenu_enabled = config[" gsmenu" ][" enabled" ].as <bool >();
926933 }
934+ if (gsmenu_enabled && config[" gsmenu" ][" actions" ]) {
935+ if (config[" gsmenu" ][" actions" ][" air" ]) {
936+ const YAML::Node& actionsNode = config[" gsmenu" ][" actions" ][" air" ];
937+ airactions_count = 0 ;
938+
939+ for (YAML::const_iterator it = actionsNode.begin ();
940+ it != actionsNode.end () && airactions_count < MAX_ACTIONS;
941+ ++it) {
942+
943+ std::string label = (*it)[" label" ].as <std::string>();
944+ std::string cmd = (*it)[" action" ].as <std::string>();
945+
946+ // Access the global array at the current index
947+ strncpy (airactions[airactions_count].label , label.c_str (), MAX_LABEL_LEN - 1 );
948+ airactions[airactions_count].label [MAX_LABEL_LEN - 1 ] = ' \0 ' ;
949+
950+ strncpy (airactions[airactions_count].action , cmd.c_str (), MAX_ACTION_LEN - 1 );
951+ airactions[airactions_count].action [MAX_ACTION_LEN - 1 ] = ' \0 ' ;
952+
953+ airactions_count++;
954+ }
955+ spdlog::debug (" Parsed {} GS Actions" , airactions_count);
956+ }
957+ if (config[" gsmenu" ][" actions" ][" ground" ]) {
958+ const YAML::Node& actionsNode = config[" gsmenu" ][" actions" ][" ground" ];
959+ gsactions_count = 0 ;
960+
961+ for (YAML::const_iterator it = actionsNode.begin ();
962+ it != actionsNode.end () && gsactions_count < MAX_ACTIONS;
963+ ++it) {
964+
965+ std::string label = (*it)[" label" ].as <std::string>();
966+ std::string cmd = (*it)[" action" ].as <std::string>();
967+
968+ // Access the global array at the current index
969+ strncpy (gsactions[gsactions_count].label , label.c_str (), MAX_LABEL_LEN - 1 );
970+ gsactions[gsactions_count].label [MAX_LABEL_LEN - 1 ] = ' \0 ' ;
971+
972+ strncpy (gsactions[gsactions_count].action , cmd.c_str (), MAX_ACTION_LEN - 1 );
973+ gsactions[gsactions_count].action [MAX_ACTION_LEN - 1 ] = ' \0 ' ;
974+
975+ gsactions_count++;
976+ }
977+ spdlog::debug (" Parsed {} GS Actions" , gsactions_count);
978+ }
979+ }
927980 }
928981
929982 if (config[" os_sensors" ] && config[" os_sensors" ].IsMap ()) {
0 commit comments