
And here's the code if anybody's interested

Code: Select all
#include "CXBOXController.h"
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
CXBOXController* Player1;
bool read_position( double& t, double& x, double& y, double& z)
{ char one[500];
fgets(one, 500, stdin);
sscanf (one,"t=%lf p0=%lf p1=%lf p2=%lf ", &t, &x, &y, &z);
return true;
}
double get_acceleration(double v0, double v1, double v2, double t0, double t1, double t2)
{
double acceleration;
acceleration = ((((v2-v1)/(t2-t1))-((v1-v0)/(t1-t0)))/(t2-t0))/15;
return(acceleration);
}
void set_vibrate(double a, double b)
{
int vib1;
int vib2;
if((a*2400)>65535)
{ vib1=65535;
vib2=65535;
}
else if (b>0)
{ vib1=a*2100;
vib2 = 0;
}
else
{
vib1 = 0;
vib2=a*2400;
}
Player1->Vibrate(vib1,vib2);
}
int main()
{
Player1 = new CXBOXController(1);
struct position{
double x[3] , y[3], z[3], t[3];
};
position p;
int i = 0;
double ax, ay, az;
double accel;
read_position(p.t[i],p.x[i],p.y[i],p.z[i]);
read_position(p.t[i++ % 3],p.x[i % 3],p.y[i % 3],p.z[i % 3]);
while ( read_position(p.t[i++ % 3],p.x[i % 3],p.y[i % 3],p.z[i % 3]))
{
ax = get_acceleration( p.x[(i - 3) % 3], p.x[(i - 2) % 3], p.x[(i - 1) % 3], p.t[(i - 3) % 3], p.t[(i - 2) % 3], p.t[(i - 1) % 3]);
ay = get_acceleration( p.y[(i - 3) % 3], p.y[(i - 2) % 3], p.y[(i - 1) % 3], p.t[(i - 3) % 3], p.t[(i - 2) % 3], p.t[(i - 1) % 3]);
az = get_acceleration( p.z[(i - 3) % 3], p.z[(i - 2) % 3], p.z[(i - 1) % 3], p.t[(i - 3) % 3], p.t[(i - 2) % 3], p.t[(i - 1) % 3]);
accel = sqrt((pow(ax,2))+ (pow(ay,2)) + (pow(az,2)));
set_vibrate(accel, ay);
}
return 0 ;
}
As for reading the suspension travel...I wish I could, sadly the only information I can use is camera positions and orientations
