Xbox rumble test (Please be gentle ;) )

Post anything about MX Simulator here. Please. I'm begging you.
cpt_Slow
Posts: 683
Joined: Sat Dec 15, 2007 5:58 pm
Team: Privateer
Contact:

Re: Xbox rumble test (Please be gentle ;) )

Post by cpt_Slow »

Ok well I decided to have another go at this today, I've updated it to follow JLV's code (sort of) thanks for that. :) The vibration is toned down a bit,although it still misses some of the big hits. I think it might be something to do with it taking data from the camera position, so if the rider has absorbed the impact, the camera won't accelerate as quickly as it should. Annoying, but I've tried a lot to get around it with no success. Here's the link: http://www.mediafire.com/?ja89a17ar5l1nnr

And here's the code if anybody's interested :P

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 :(
Ashes
Posts: 311
Joined: Mon Mar 09, 2009 6:36 am
Team: Privateer #65

Re: Xbox rumble test (Please be gentle ;) )

Post by Ashes »

I WISH I could use this for my rumblepad!
cpt_Slow
Posts: 683
Joined: Sat Dec 15, 2007 5:58 pm
Team: Privateer
Contact:

Re: Xbox rumble test (Please be gentle ;) )

Post by cpt_Slow »

Don't you do programming yourself Ashes? Compared to your skin mixer this kind of thing should be easy? :P I will have to look into supporting other gamepads soon I think. :)

I've updated it to have variable intensity now from 1-100. The default is 80 and to change it you just alter the number in "settings.txt" Both xboxtest.exe and settings.txt need to go in mxsim istall folder. mx.bat goes on your desktop (may need to edit it with notepad if your mxsim install folder has a different path to mine.)

http://www.mediafire.com/?k3ln8rwf43ddlfg

Let me know what you think. :)
Stickerz
Posts: 984
Joined: Thu Feb 17, 2011 12:02 pm
Team: N/A

Re: Xbox rumble test (Please be gentle ;) )

Post by Stickerz »

So far it isn't working for me, my initial though is that it's because I am using a non-defualt driver for my controller, a custom one, second thought is what yzed said =/
Image
cpt_Slow
Posts: 683
Joined: Sat Dec 15, 2007 5:58 pm
Team: Privateer
Contact:

Re: Xbox rumble test (Please be gentle ;) )

Post by cpt_Slow »

What exactly isn't working? When you open mx.bat what happens?
Stickerz
Posts: 984
Joined: Thu Feb 17, 2011 12:02 pm
Team: N/A

Re: Xbox rumble test (Please be gentle ;) )

Post by Stickerz »

mxsim opens, although I had to edit the batch file because my install folder isn't in program files(x86) then I go to race, no vibration, I also tried using the microsoft drivers, so I don't think that's the problem
Image
Stickerz
Posts: 984
Joined: Thu Feb 17, 2011 12:02 pm
Team: N/A

Re: Xbox rumble test (Please be gentle ;) )

Post by Stickerz »

Ok, it works, it may have been not working because I had 2 of them open, going to try with the custom driver I use :)
Image
Ashes
Posts: 311
Joined: Mon Mar 09, 2009 6:36 am
Team: Privateer #65

Re: Xbox rumble test (Please be gentle ;) )

Post by Ashes »

cpt_Slow wrote:Don't you do programming yourself Ashes? Compared to your skin mixer this kind of thing should be easy? :P I will have to look into supporting other gamepads soon I think. :)

I've updated it to have variable intensity now from 1-100. The default is 80 and to change it you just alter the number in "settings.txt" Both xboxtest.exe and settings.txt need to go in mxsim istall folder. mx.bat goes on your desktop (may need to edit it with notepad if your mxsim install folder has a different path to mine.)

http://www.mediafire.com/?k3ln8rwf43ddlfg

Let me know what you think. :)

Yeah I do program.
I just haven't got time lately with work being what it is at the moment.
It made me think though - maybe there is a generic controller library (instead of CXBOXController.h).

Funny you should mention the skin mixer - I forgot about that, but now that you remind me, I STILL think that jlv should implement a similar system for the skins in game ;-)
cpt_Slow
Posts: 683
Joined: Sat Dec 15, 2007 5:58 pm
Team: Privateer
Contact:

Re: Xbox rumble test (Please be gentle ;) )

Post by cpt_Slow »

Glad you got it working stickerz. Yeah the default location is for windows 7 (and maybe vista) 64-bit.

Haha yeah I understand Ashes I was just joking with you since this code must look pretty simple to you compared with that. :P If I remember it worked really well, if there was just a mask for each uv layout the game just loaded images from the currently installed skins it could work...but not sure about online.

There is a generic controller class, the 360 controller uses xinput and other controllers use directinput I think. I wanted to make sure I could get. It working nicely for 360 controllers first though. Since I don't own another gamepad with rumble funcittion I may need some volunteer testers first. :P
Joe
Posts: 2971
Joined: Wed Dec 19, 2007 10:17 pm
Team: MXSP
Location: PEI,Canada

Re: Xbox rumble test (Please be gentle ;) )

Post by Joe »

Any updates on this?
cpt_Slow
Posts: 683
Joined: Sat Dec 15, 2007 5:58 pm
Team: Privateer
Contact:

Re: Xbox rumble test (Please be gentle ;) )

Post by cpt_Slow »

Unfortunately not, I don't have any of the files on my laptop so haven't had the chance to even look at it for a few months now. The 360 feedback seems to me to be pretty close with that latest update. As for support for generic controllers.....I think it's a little more in depth than for the 360 controller but I will try to look into it over Christmas if I get time. Sorry about that.
Joe
Posts: 2971
Joined: Wed Dec 19, 2007 10:17 pm
Team: MXSP
Location: PEI,Canada

Re: Xbox rumble test (Please be gentle ;) )

Post by Joe »

You said it is based on camera position? Im not getting much feed back maybe my camera isnt in a good spot what are your settings?
cpt_Slow
Posts: 683
Joined: Sat Dec 15, 2007 5:58 pm
Team: Privateer
Contact:

Re: Xbox rumble test (Please be gentle ;) )

Post by cpt_Slow »

Shouldn't really matter on the camera settings since it's just based on the acceleration and deceleration of the camera. It might not be working properly....have you tri Aned increasing the intensity? And just to check...you are in first person? It'll only work in first person unfortunately.
Joe
Posts: 2971
Joined: Wed Dec 19, 2007 10:17 pm
Team: MXSP
Location: PEI,Canada

Re: Xbox rumble test (Please be gentle ;) )

Post by Joe »

yes 1st person its at 80 what should it be at?
shanebell
Posts: 156
Joined: Wed Jul 29, 2009 8:32 pm
Team: Privateer

Re: Xbox rumble test (Please be gentle ;) )

Post by shanebell »

does anyone have the exe i could have? i never got to try this when it came out and now all the links are dead :?
jlv wrote:I apologize for ruining all future MX games for you guys.
Post Reply