Exemple #1
0
int read_sms_real(int type, double *x, double *y, double *z)
{
    int _x, _y, _z;
    int xscale, yscale, zscale;
    int ret;
    Boolean ok;
 
    ret = read_sms_raw(type, &_x, &_y, &_z);
    if ( !ret )
        return 0;

    static CFStringRef app = CFSTR("com.ramsayl.UniMotion");
    static CFStringRef xscalestr = CFSTR("x_scale");
    static CFStringRef yscalestr = CFSTR("y_scale");
    static CFStringRef zscalestr = CFSTR("z_scale");
    xscale = CFPreferencesGetAppIntegerValue(xscalestr, app, &ok);
    if ( !ok ) return 0;
    yscale = CFPreferencesGetAppIntegerValue(yscalestr, app, &ok);
    if ( !ok ) return 0;
    zscale = CFPreferencesGetAppIntegerValue(zscalestr, app, &ok);
    if ( !ok ) return 0;
    
    *x = _x / (double)xscale;
    *y = _y / (double)yscale;
    *z = _z / (double)zscale;
    
    return 1;
}
Exemple #2
0
int read_sms(int type, int *x, int *y, int *z)
{
    int _x, _y, _z;
    int xoff, yoff, zoff;
    Boolean ok;
    int ret;
 
    ret = read_sms_raw(type, &_x, &_y, &_z);
    if ( !ret )
        return 0;

    static CFStringRef app = CFSTR("com.ramsayl.UniMotion");
    static CFStringRef xoffstr = CFSTR("x_offset");
    static CFStringRef yoffstr = CFSTR("y_offset");
    static CFStringRef zoffstr = CFSTR("z_offset");
    xoff = CFPreferencesGetAppIntegerValue(xoffstr, app, &ok);
    if ( ok ) _x += xoff;
    yoff = CFPreferencesGetAppIntegerValue(yoffstr, app, &ok);
    if ( ok ) _y += yoff;
    zoff = CFPreferencesGetAppIntegerValue(zoffstr, app, &ok);
    if ( ok ) _z += zoff;
    
    *x = _x;
    *y = _y;
    *z = _z;

    return ret;
}
Exemple #3
0
static uint64_t setup_defaults_settings(){
    
    Boolean keyExistsAndHasValue = false;
    uint64_t seconds;
    seconds = CFPreferencesGetAppIntegerValue(CFSTR("OTR"), CFSTR("com.apple.security"), &keyExistsAndHasValue);
    secdebug("OTR", "Retrieving OTR default settings was success? %d value retrieved: %llu", keyExistsAndHasValue, seconds);
    return keyExistsAndHasValue ? seconds : (kSecondsPerMinute * 15); //15 minutes by default
}
Exemple #4
0
void LoadControllerSettings (void)
{
	CFStringRef	keyCFStringRef;

    for (int a = 0; a < kNeedCount; a++)
    {
		pRecDevice	pDevice  = NULL;
		pRecElement	pElement = NULL;
		Boolean		r = false;
		char		needCStr[64], num[10];

		strcpy(needCStr, gNeeds[a]);
		if (padSetting > 1)
		{
			sprintf(num, "_%d", padSetting);
			strcat(needCStr, num);
		}

		keyCFStringRef = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("%s"), needCStr);
		if (keyCFStringRef)
		{
			r = HIDRestoreElementPref(keyCFStringRef, kCFPreferencesCurrentApplication, &pDevice, &pElement);
			if (r && pDevice && pElement)
			{
				gActionRecs[a].fDevice  = pDevice;
				gActionRecs[a].fElement = pElement;
			}
			else
			{
				gActionRecs[a].fDevice  = NULL;
				gActionRecs[a].fElement = NULL;
			}

			CFRelease(keyCFStringRef);
		}
	}

	for (int a = 0; a < MAC_MAX_PLAYERS; a++)
	{
		keyCFStringRef = CFStringCreateWithFormat(kCFAllocatorDefault, NULL, CFSTR("DirectionHint_%d_%d"), a, padSetting);
		if (keyCFStringRef)
		{
			Boolean	r;

			gDirectionHint[a] = (int) CFPreferencesGetAppIntegerValue(keyCFStringRef, kCFPreferencesCurrentApplication, &r);
			if (!r)
				gDirectionHint[a] = kPadElemTypeNone;

			CFRelease(keyCFStringRef);
		}
		else
			gDirectionHint[a] = kPadElemTypeNone;
	}

	JoypadSetDirectionInfo();
}
Exemple #5
0
// Checks the global preference to see if text at the specified point size
// will be drawn antialiased or not.
//
// Note that iSize is of type Fixed!
//
Boolean IsAntiAliased(Fixed iSize)
{
    Boolean keyExistsAndHasValidFormat;
    CFIndex value;

    value = CFPreferencesGetAppIntegerValue( CFSTR("AppleAntiAliasingThreshold"),
                                             kCFPreferencesCurrentApplication,
                                             &keyExistsAndHasValidFormat );

    if ( keyExistsAndHasValidFormat )
        return ( Fix2X(iSize) > value ); // 'value' is the maximum not-antialiasing size
    else
        return true;
}
bool outOfSpace(CFStringRef pathName)
{
	Boolean			validKey;
	unsigned int	minMeg;
	struct statfs	fileSys;
	
	minMeg = CFPreferencesGetAppIntegerValue(MINMEG_PREF_KEY,PREF_DOMAIN,&validKey);
	if (!validKey)
	{
		minMeg = DEFAULT_MEG;
		CFPreferencesSetAppValue(MINMEG_PREF_KEY,CFNumberCreate(kCFAllocatorDefault,kCFNumberIntType,&minMeg),PREF_DOMAIN);
	}

	if (statfs(CFStringGetCStringPtr(pathName,CFStringGetFastestEncoding(pathName)),&fileSys))
		return false;

	if ((fileSys.f_bsize/1024)*(fileSys.f_bavail/1024) < minMeg)
		return true;
		
	return false;
}
void PreferencesDialog::initDataBase()
{
	m_dataBase = new TrackerSettingsDatabase();	

	m_dataBase->store(KEY_USEMIDI, 0);
	m_dataBase->store(KEY_SAVEPREFS, 0);
	m_dataBase->store(KEY_MIDIDEVICE, "");
	m_dataBase->store(KEY_RECORDVELOCITY, 0);
	m_dataBase->store(KEY_VELOCITYAMPLIFY, 100);
	m_dataBase->store(KEY_INSERTEMULATION, 0);
	m_dataBase->store(KEY_SIXTEENBITCOLOR, 0);

	// try to retrieve the values from the PLIST
	Boolean success = FALSE;
	CFStringRef key = CFSTR(KEY_USEMIDI);	
	Boolean b = CFPreferencesGetAppBooleanValue(key, applicationID, &success);
	if (success)
		m_dataBase->store(KEY_USEMIDI, b);		
	
	// Return boolean
	success = FALSE;
	key = CFSTR(KEY_SAVEPREFS);	
	b = CFPreferencesGetAppBooleanValue(key, applicationID, &success);
	if (success)
		m_dataBase->store(KEY_SAVEPREFS, b);		

	// Return string, little bit more complicated
	key = CFSTR(KEY_MIDIDEVICE);	
	CFPropertyListRef plistRef = CFPreferencesCopyAppValue(key, applicationID);
	if (plistRef)
	{
		if (CFGetTypeID(plistRef) == CFStringGetTypeID())
		{
			CFStringRef stringRef = static_cast<CFStringRef>(plistRef);
			char buffer[512];
			CFStringGetCString(stringRef, buffer, 512, kCFStringEncodingASCII);
			m_dataBase->store(KEY_MIDIDEVICE, buffer);	
		}
	}

	// More boolean values following
	success = FALSE;
	key = CFSTR(KEY_RECORDVELOCITY);	
	b = CFPreferencesGetAppBooleanValue(key, applicationID, &success);
	if (success)
		m_dataBase->store(KEY_RECORDVELOCITY, b);		

	// Integer value
	success = FALSE;
	key = CFSTR(KEY_VELOCITYAMPLIFY);	
	int i = CFPreferencesGetAppIntegerValue(key, applicationID, &success);
	if (success)
		m_dataBase->store(KEY_VELOCITYAMPLIFY, i);		

	// Integer value
	success = FALSE;
	key = CFSTR(KEY_INSERTEMULATION);	
	i = CFPreferencesGetAppIntegerValue(key, applicationID, &success);
	if (success)
		m_dataBase->store(KEY_INSERTEMULATION, i);		

	// More boolean values following
	success = FALSE;
	key = CFSTR(KEY_SIXTEENBITCOLOR);	
	b = CFPreferencesGetAppBooleanValue(key, applicationID, &success);
	if (success)
		m_dataBase->store(KEY_SIXTEENBITCOLOR, b);		
}