bool save_opentyrian_config( void )
{
	cJSON *root = load_json("opentyrian.conf");
	if (root == NULL)
		root = cJSON_CreateObject();
	
	cJSON *section;
	
	section = cJSON_CreateOrGetObjectItem(root, "video");
	cJSON_ForceType(section, cJSON_Object);
	
	{
		cJSON *setting;
		
		setting = cJSON_CreateOrGetObjectItem(section, "fullscreen");
		cJSON_SetBoolean(setting, fullscreen_enabled);
		
		setting = cJSON_CreateOrGetObjectItem(section, "scaler");
		cJSON_SetString(setting, scalers[scaler].name);
	}
	
	save_json(root, "opentyrian.conf");
	
	cJSON_Delete(root);
	
	return true;
}
Beispiel #2
0
bool save_opentyrian_config( void )
{
#ifdef __BLACKBERRY__
#else
#ifdef ENABLE_CONFIGURATION
    cJSON *root = load_json("opentyrian.conf");
    if (root == NULL)
        root = cJSON_CreateObject();

    cJSON *section;

    section = cJSON_CreateOrGetObjectItem(root, "video");
    cJSON_ForceType(section, cJSON_Object);

    {
        cJSON *setting;

        setting = cJSON_CreateOrGetObjectItem(section, "fullscreen");
        cJSON_SetBoolean(setting, fullscreen_enabled);

        setting = cJSON_CreateOrGetObjectItem(section, "scaler");
        cJSON_SetString(setting, scalers[scaler].name);
    }

    save_json(root, "opentyrian.conf");

    cJSON_Delete(root);
#endif /*ENABLE_CONFIGURATION*/
#endif
    return true;
}
bool save_joystick_assignments( int j )
{
	cJSON *root = load_json("joystick.conf");
	if (root == NULL)
		root = cJSON_CreateObject();
	
	cJSON *config = cJSON_CreateOrGetObjectItem(root, SDL_JoystickName(j));
	cJSON_ForceType(config, cJSON_Object);
	
	cJSON *setting;
	
	setting = cJSON_CreateOrGetObjectItem(config, "analog");
	cJSON_SetBoolean(setting, joystick[j].analog);
	
	setting = cJSON_CreateOrGetObjectItem(config, "sensitivity");
	cJSON_SetNumber(setting, joystick[j].sensitivity);
	
	setting = cJSON_CreateOrGetObjectItem(config, "threshold");
	cJSON_SetNumber(setting, joystick[j].threshold);
	
	setting = cJSON_CreateOrGetObjectItem(config, "assignments");
	cJSON_ForceType(setting, cJSON_Array);
	cJSON_ClearArray(setting);
	
	for (uint i = 0; i < COUNTOF(joystick->assignment); ++i)
	{
		cJSON *assignments;
		cJSON_AddItemToArray(setting, assignments = cJSON_CreateArray());
		
		for (uint k = 0; k < COUNTOF(*joystick->assignment); ++k)
		{
			if (joystick[j].assignment[i][k].type == NONE)
				continue;
			
			cJSON_AddItemToArray(assignments, cJSON_CreateString(assignment_to_code(&joystick[j].assignment[i][k])));
		}
	}
	
	save_json(root, "joystick.conf");
	
	cJSON_Delete(root);
	
	return true;
}