> /* ----- BEGIN TED MODIFICATION 2004----- */
#define CRANGE (50 / 2)
typedef int SENSOR_API;
typedef struct _ACCELREPORT {
INT PresentState; // Current internal state (stable: 0, unstable1: 1: unstable2: 2)
USHORT LatestRawAccelDataX; // latest raw acceleration data of X axis <-- works!
USHORT LatestRawAccelDataY; // latest raw acceleration data of Y axis <-- works!
USHORT LatestAccelDataX; // latest acceleration data of X axis (average in 40ms) <-- Works even better?
USHORT LatestAccelDataY; // latest acceleration data of Y axis (average in 40ms) <-- Works even better?
CHAR Temperature; // latest temperature
USHORT LatestZeroG_X; // latest zero-G offset of X axis <-- Seems to be the current notion of "center"
USHORT LatestZeroG_Y; // latest zero-G offset of Y axis <-- ""
} ACCELREPORT, *PACCELREPORT;
typedef SENSOR_API (__stdcall *readSensor_t)(PACCELREPORT pAcceleration);
static readSensor_t sensorFunction = 0;
static USHORT centerX, centerY;
ACCELREPORT data;
/* See if we need to initialize for the first time */
if(!sensorFunction)
{
HMODULE hSensor = LoadLibrary("Sensor.dll");
if(hSensor)
{
sensorFunction = (readSensor_t) GetProcAddress(hSensor, "ShockproofGetAccelerometerData");
if(sensorFunction) {
sensorFunction(&data);
centerX = data.LatestZeroG_X;
centerY = data.LatestZeroG_Y;
}
}
}