fix armel build issues
[drnoksnes] / platform / hgw.cpp
index 5ffaed5..bccc6ed 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,25 @@ void HgwConfig()
                Settings.Transparency = transparency ? TRUE : FALSE;
        }
 
+       char scaler[NAME_MAX];
+       if (hgw_conf_request_string(hgw, kGConfScaler, scaler) == HGW_ERR_NONE
+               && strlen(scaler) > 0) {
+               free(Config.scaler);
+               Config.scaler = strdup(scaler);
+       }
+
        char displayFramerate = FALSE;
        if (hgw_conf_request_bool(hgw, kGConfDisplayFramerate, &displayFramerate) == HGW_ERR_NONE) {
                Settings.DisplayFrameRate = displayFramerate ? TRUE : FALSE;
        }
 
+       char displayControls = FALSE;
+       if (hgw_conf_request_bool(hgw, kGConfDisplayControls, &displayControls) == HGW_ERR_NONE) {
+               Config.touchscreenShow = displayControls ? true : false;
+       }
+
        int speedhacks = 0;
-       if (hgw_conf_request_int(hgw, kGConfFrameskip, &speedhacks) == HGW_ERR_NONE) {
+       if (hgw_conf_request_int(hgw, kGConfSpeedhacks, &speedhacks) == HGW_ERR_NONE) {
                if (speedhacks <= 0) {
                        Settings.HacksEnabled = FALSE;
                        Settings.HacksFilter = FALSE;
@@ -225,6 +239,10 @@ static const ButtonEntry buttons[] = {
        BUTTON_INITIALIZER(RIGHT, "right"),
        ACTION_INITIALIZER(Quit, "quit"),
        ACTION_INITIALIZER(ToggleFullscreen, "fullscreen"),
+       ACTION_INITIALIZER(QuickLoad1, "quickload1"),
+       ACTION_INITIALIZER(QuickSave1, "quicksave1"),
+       ACTION_INITIALIZER(QuickLoad2, "quickload2"),
+       ACTION_INITIALIZER(QuickSave2, "quicksave2"),
        BUTTON_LAST
 };
 
@@ -234,9 +252,10 @@ static void createActionMappingsOnly()
        ZeroMemory(Config.joypad1Mapping, sizeof(Config.joypad1Mapping));
        ZeroMemory(Config.action, sizeof(Config.action));
        
-       // Map quit to fullscreen and escape
+       // Map quit to fullscreen, escape and task switch.
        Config.action[72] = kActionQuit;
        Config.action[9] = kActionQuit;
+       Config.action[71] = kActionQuit;
 }
 
 static void parseGConfKeyMappings()
@@ -287,5 +306,10 @@ static void parseGConfKeyMappings()
                        Config.action[72] = kActionQuit;
                }
        }
+
+       // If task switch key is not mapped, map it to Quit by default.
+       if (!Config.action[71] && !Config.joypad1Mapping[71]) {
+               Config.action[71] = kActionQuit;
+       }
 }