initial scaler selector in gui
[drnoksnes] / platform / hgw.cpp
index ef5799a..4617525 100644 (file)
@@ -23,20 +23,20 @@ void HgwInit()
 {
        // hildon-games-wrapper sets this env variable for itself.
        char* service = getenv("HGW_EXEC_SERVICE");
-       
+
        if (!service) {
                // Not launched from hildon-games-wrapper
                hgwLaunched = false;
                return;
        }
-       
+
        hgw = hgw_context_init();
-       
+
        if (!hgw) {
                fprintf(stderr, "Error opening hgw context\n");
                hgwLaunched = false;
        }
-       
+
        hgwLaunched = true;
        printf("Loading in HGW mode\n");
 }
@@ -54,20 +54,22 @@ void HgwDeinit()
 void HgwConfig()
 {
        if (!hgwLaunched) return;
-       
+
        Config.fullscreen = true;
-       
+
        char romFile[PATH_MAX + 1];
-       if (hgw_conf_request_string(hgw, kGConfRomFile, romFile) == HGW_ERR_NONE) {
+       if (hgw_conf_request_string(hgw, kGConfRomFile, romFile) == HGW_ERR_NONE
+               && strlen(romFile) > 0) {
                S9xSetRomFile(romFile);
        } else {
-               hgw_context_destroy(hgw, HGW_BYE_INACTIVE);
-               DIE("No Rom in Gconf!");
+               printf("Exiting gracefully because there's no ROM in Gconf\n");
+               HgwDeinit();
+               exit(0);
        }
 
-       char no_audio = FALSE;
-       if (hgw_conf_request_bool(hgw, kGConfDisableAudio, &no_audio) == HGW_ERR_NONE) {
-               Config.enableAudio = no_audio ? false : true;
+       char sound = FALSE;
+       if (hgw_conf_request_bool(hgw, kGConfSound, &sound) == HGW_ERR_NONE) {
+               Config.enableAudio = sound ? true : false;
        }
 
        char turbo = FALSE;
@@ -85,13 +87,11 @@ void HgwConfig()
                Settings.Transparency = transparency ? TRUE : FALSE;
        }
 
-       char scaler[256];
-       scaler[0] = '\0';
-       if (hgw_conf_request_string(hgw, kGConfScaler, scaler) == HGW_ERR_NONE) {
-               if (strlen(scaler) > 0) {
-                       free(Config.scaler);
-                       Config.scaler = strdup(scaler);
-               }
+       char scaler[NAME_MAX];
+       if (hgw_conf_request_bool(hgw, kGConfScaler, scaler) == HGW_ERR_NONE
+               && strlen(scaler) > 0) {
+               free(Config.scaler);
+               Config.scaler = strdup(scaler);
        }
 
        char displayFramerate = FALSE;