comparison menu.c @ 1292:5905593d6828

Allow initial_path to contain variable references which allows the default value to be actually specified in the default config file
author Michael Pavone <pavone@retrodev.com>
date Tue, 21 Mar 2017 00:40:25 -0700
parents 0a34e31c4fd0
children 72ea3885e7b5
comparison
equal deleted inserted replaced
1291:f17fe0d00626 1292:5905593d6828
165 genesis_context *gen = m68k->system; 165 genesis_context *gen = m68k->system;
166 menu_context *menu = gen->extra; 166 menu_context *menu = gen->extra;
167 if (!menu) { 167 if (!menu) {
168 gen->extra = menu = calloc(1, sizeof(menu_context)); 168 gen->extra = menu = calloc(1, sizeof(menu_context));
169 menu->curpath = tern_find_path(config, "ui\0initial_path\0").ptrval; 169 menu->curpath = tern_find_path(config, "ui\0initial_path\0").ptrval;
170 if (menu->curpath) { 170 if (!menu->curpath){
171 menu->curpath = strdup(menu->curpath);
172 } else {
173 #ifdef __ANDROID__ 171 #ifdef __ANDROID__
174 menu->curpath = strdup(get_external_storage_path()); 172 menu->curpath = get_external_storage_path();
175 #else 173 #else
176 menu->curpath = strdup(get_home_dir()); 174 menu->curpath = "$HOME";
177 #endif 175 #endif
178 } 176 }
177 tern_node *vars = tern_insert_ptr(NULL, "HOME", get_home_dir());
178 vars = tern_insert_ptr(vars, "EXEDIR", get_exe_dir());
179 menu->curpath = replace_vars(menu->curpath, vars, 1);
179 } 180 }
180 if (menu->state) { 181 if (menu->state) {
181 uint32_t dst = menu->latch << 16 | value; 182 uint32_t dst = menu->latch << 16 | value;
182 switch (address >> 2) 183 switch (address >> 2)
183 { 184 {