8 #define DIE(format, ...) do { \
9 fprintf(stderr, "Died at %s:%d: ", __FILE__, __LINE__ ); \
10 fprintf(stderr, format "\n", ## __VA_ARGS__); \
17 static HgwContext *hgw;
21 // hildon-games-wrapper sets this env variable for itself.
22 char* service = getenv("HGW_EXEC_SERVICE");
25 // Not launched from hildon-games-wrapper
30 hgw = hgw_context_init();
33 fprintf(stderr, "Error opening hgw context\n");
38 HgwStartCommand cmd = hgw_context_get_start_command(hgw);
42 case HGW_COMM_NONE: // called from libosso
44 Config.snapshotLoad = true;
45 Config.snapshotSave = true;
47 case HGW_COMM_RESTART:
48 Config.snapshotLoad = false;
49 Config.snapshotSave = true;
53 Config.snapshotLoad = false;
54 Config.snapshotSave = false;
55 Config.quitting = true;
59 printf("Loading in HGW mode\n");
64 if (!hgwLaunched) return;
66 hgw_context_destroy(hgw,
67 (Config.snapshotSave ? HGW_BYE_PAUSED : HGW_BYE_INACTIVE));
74 if (!hgwLaunched) return;
76 Config.fullscreen = true;
78 char romFile[PATH_MAX];
79 if (hgw_conf_request_string(hgw, kGConfRomFile, romFile) == HGW_ERR_NONE) {
80 S9xSetRomFile(romFile);
82 DIE("No Rom in Gconf!");
88 if (!hgwLaunched) return;
91 HgwMessageFlags flags = HGW_MSG_FLAG_NONE;
93 if ( hgw_msg_check_incoming(hgw, &msg, flags) == HGW_ERR_COMMUNICATION ) {
94 // Message Incoming, process msg
97 case HGW_MSG_TYPE_CBREQ:
101 Config.quitting = true;
105 case HGW_MSG_TYPE_DEVSTATE:
107 case HGW_DEVICE_STATE_SHUTDOWN:
108 Config.quitting = true; // try to quit gracefully
117 hgw_msg_free_data(&msg);