#include "unimotion.h"
#include <IOKit/IOKitLib.h>
#include <CoreFoundation/CoreFoundation.h>
-#include <string.h>
#include <stdint.h>
enum data_type {
int read_sms(int type, int *x, int *y, int *z)
{
int _x, _y, _z;
- int xoff, yoff, zoff;
- Boolean ok;
+ 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;
+ 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;
}
int read_sms_real(int type, double *x, double *y, double *z)
{
int _x, _y, _z;
- int xscale, yscale, zscale;
+ int xscale, yscale, zscale;
int ret;
- Boolean ok;
-
+ 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;
-
+ 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;
}