Forums » Technology » Flight Sim Controllers » T.A.R.G.E.T. (Thrustmaster) » TFRP Rudders - Combined toe brake axis Active Topics You are not logged in. [Log In] [Register User]
Topic Options
Rate This Topic
Hop to:
#4274311 - 06/28/16 08:26 PM TFRP Rudders - Combined toe brake axis
DarKcyde Offline
Member

Registered: 05/12/06
Posts: 117
Loc: Canada
Code:
include "target.tmh"

int main()
{
	// Exclude missing devices
	Configure(&HCougar, MODE_EXCLUDED);
	Configure(&T16000, MODE_EXCLUDED);
	Configure(&T16000L, MODE_EXCLUDED);
	Configure(&LMFD, MODE_EXCLUDED);
	Configure(&RMFD, MODE_EXCLUDED);
	Configure(&TWCSThrottle, MODE_EXCLUDED);
	Configure(&TFRPRudder, MODE_FILTERED);
	
    if(Init(&EventHandle)) return 1; // declare the event handler, return on error
	
}

int EventHandle(int type, alias o, int x)
{
 int TRPCOMBO;
	// Combine rudder toe brakes into new axis, mapped to DX_THROTTLE_AXIS
	if (&o == &TFRPRudder & (x == TRPLEFT | x == TRPRIGHT)) {
		if (TFRPRudder[TRPLEFT] < TFRPRudder[TRPRIGHT]) TRPCOMBO = TFRPRudder[TRPRIGHT];
		else TRPCOMBO = TFRPRudder[TRPLEFT];
		DXAxis (DX_THROTTLE_AXIS, -TRPCOMBO);
	}
	
	if (&o == &TFRPRudder) {  //Map the MODE_FILTERED TFRP through Target, we can Trim, set deadzones, J/Scurves, etc.
		GetAxisData(&o, x);
		axdata.val = AxisVal(o[x], &axdata);
		if(x == TRPLEFT | x == TRPRIGHT) axdata.val = -axdata.val;  //Reverse the Toe Brakes, TM why u do dis??
		//axdata.locked = 1;                                        //Uncomment to disable pedals but keep TRPCOMBO axis
		if(!axdata.locked & !axdata.relative) GameOutput(&o, x, axdata.val);
	}
	else DefaultMapping(&o, x);
}


This creates a NEW axis, that is pressed only when you press both toe brakes. Because space ship. Gives you 4 axes on the rudders. It's mapped to the extra axis that isn't taken up by a Warthog. It leaves the TFRP out of the TM Combined virtual joystick, because that doesn't have enough axes to put it in there. Should be simple to add to any existing code. Note that its not a differential axis, like when people create a single rudder axis with their gas/brake pedals. This lets you map each toe brake separately, but press both of them together for a new input, while your left/right (usually) cancel each other out.

I use it for reverse thrust in Elite. Forward thrust on throttle, up/down thrust on each pedal, and both feet down for backing up.

UPDATE:
Added some code to run the TFRP through Target, but stay a separate device. Reversed the toe brakes, no idea why TM would have them rest high instead of at 0. This allows you to set curves, deadzones, trim, etc. Uncomment the indicated line if you have trouble with games detecting several axes when trying to map the Combined toe brakes.


Edited by DarKcyde (07/18/16 02:43 AM)
Edit Reason: updated script

Top
#4274420 - 06/29/16 06:53 AM Re: TFRP Rudders - Combined toe brake axis [Re: DarKcyde]
Thermal Offline
Junior Member

Registered: 03/07/11
Posts: 11
Y u want me buy new pedals that work with target?

Seriously, this looks really, really cool.

Top
#4274616 - 06/29/16 03:32 PM Re: TFRP Rudders - Combined toe brake axis [Re: DarKcyde]
DarKcyde Offline
Member

Registered: 05/12/06
Posts: 117
Loc: Canada
Haha yep. My pedals were fine, but I really wanted to be able to program everything in one place. Target is just so bloody awesome. First thing I did was figure out how to code this, before even using them. Even if they aren't the highest quality, I'll always have the chip to transplant into any crazy thing I build.

Top
#4279846 - 07/18/16 02:47 AM Re: TFRP Rudders - Combined toe brake axis [Re: DarKcyde]
DarKcyde Offline
Member

Registered: 05/12/06
Posts: 117
Loc: Canada
Added new code, run the Rudders through Target so we can control them, but remain a separate device.

Top
#4280381 - 07/20/16 11:48 AM Re: TFRP Rudders - Combined toe brake axis [Re: DarKcyde]
Splashy Offline
Junior Member

Registered: 07/20/16
Posts: 2
Hey, sorry to bother you, but ive been searching for hours, to find scripts/solutions to combine the Toebrakes of the TFRP ... but i havent found anything... mind helping me out? Thanks biggrin

Top
#4280807 - 07/21/16 11:31 PM Re: TFRP Rudders - Combined toe brake axis [Re: DarKcyde]
DarKcyde Offline
Member

Registered: 05/12/06
Posts: 117
Loc: Canada
As requested, some code that does this!

Code:
include "target.tmh"

//program startup
int main()
{
	Configure(&TFRPRudder, MODE_FILTERED);
    if(Init(&EventHandle)) return 1; // declare the event handler, return on error
	
	//add initialization code here
}

//event handler
int EventHandle(int type, alias o, int x)
{
int TRPCOMBO;

	if (&o == &TFRPRudder) {  
		GetAxisData(&o, x);
		axdata.val = AxisVal(o[x], &axdata);
		if(x == TRPLEFT | x == TRPRIGHT) {
			axdata.locked = 1; //disable the toe brakes
			TRPCOMBO = -TFRPRudder[TRPRIGHT]/2 + TFRPRudder[TRPLEFT]/2;  //Toe brakes rest high, so negate and divide by 2
			DXAxis(DX_THROTTLE_AXIS, TRPCOMBO);  //Map to extra axis.
		}
		//axdata.locked = 1;                                        //Uncomment to disable pedals but keep TRPCOMBO axis
		if(!axdata.locked & !axdata.relative) GameOutput(&o, x, axdata.val);
		
	}
	else DefaultMapping(&o, x);
}



HOWEVER, I read your other post and saw this is for Elite Dangerous! You don't need this at all. Elite has plenty powerful axis mapping. Just map Thrust Up to one pedal, and Thrust down to the other pedal! Elite accepts axes on those, not just buttons.

I should have searched your posts first, could've saved half an hour. LOL. Oh well, its there for the next person who needs it, maybe for some old game, or some xbox or unity games with poor joystick support.

Top
#4296757 - 09/16/16 11:10 AM Re: TFRP Rudders - Combined toe brake axis [Re: DarKcyde]
Spivak Offline
Junior Member

Registered: 09/16/16
Posts: 1
Quote:
HOWEVER, I read your other post and saw this is for Elite Dangerous! You don't need this at all. Elite has plenty powerful axis mapping. Just map Thrust Up to one pedal, and Thrust down to the other pedal! Elite accepts axes on those, not just buttons.

I should have searched your posts first, could've saved half an hour. LOL. Oh well, its there for the next person who needs it, maybe for some old game, or some xbox or unity games with poor joystick support.


Just a correction, Elite uses digital inputs for Thrust up, down, right or left; if analogue inputs are wanted to be used must to be assigned an axis. I added my initialization code to yours, and I mapped to XROT instead of THROTTLE, but DX_Z_AXIS goes disabled when I run the script, so I miss the rudder axis. Any idea?

Thanks in advance.

Code:

include "target.tmh"
int main()
{
	Configure(&HCougar, MODE_EXCLUDED);
	Configure(&T16000, MODE_EXCLUDED);
	Configure(&T16000L, MODE_EXCLUDED);
	Configure(&LMFD, MODE_EXCLUDED);
	Configure(&RMFD, MODE_EXCLUDED);
	Configure(&TWCSThrottle, MODE_EXCLUDED);
	Configure(&TFRPRudder, MODE_FILTERED);
	if(Init(&EventHandle)) return 1;
	SetKBRate(32, 50);
	SetKBLayout(KB_ENG);
	SetShiftButton(0, 0, 0, 0, 0, 0);
	MapAxis(&Joystick, JOYX, DX_X_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
	SetSCurve(&Joystick, JOYX, 0, 0, 0, 0, 0);
	MapAxis(&Joystick, JOYY, DX_Y_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
	SetSCurve(&Joystick, JOYY, 0, 0, 0, 0, 0);
	MapAxis(&Throttle, SCX, 0, AXIS_NORMAL, MAP_ABSOLUTE);
	SetSCurve(&Throttle, SCX, 0, 0, 0, 0, 0);
	MapAxis(&Throttle, SCY, DX_YROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
	SetSCurve(&Throttle, SCY, 0, 0, 0, 0, 0);
	MapAxis(&Throttle, THR_RIGHT, DX_THROTTLE_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
	SetSCurve(&Throttle, THR_RIGHT, 0, 0, 0, 0, 0);
	MapAxis(&Throttle, THR_LEFT, 0, AXIS_NORMAL, MAP_ABSOLUTE);
	SetSCurve(&Throttle, THR_LEFT, 0, 0, 0, 0, 0);
	MapAxis(&Throttle, THR_FC, DX_SLIDER_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
	SetSCurve(&Throttle, THR_FC, 0, 0, 0, 0, 0);
	MapAxis(&TFRPRudder, TRPRIGHT, DX_XROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
	SetSCurve(&TFRPRudder, TRPRIGHT, 0, 0, 0, 0, 0);
	MapAxis(&TFRPRudder, TRUDDER, DX_Z_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
	SetSCurve(&TFRPRudder, TRUDDER, 0, 0, 0, 0, 0);
	MapAxis(&TFRPRudder, TRPLEFT, DX_YROT_AXIS, AXIS_NORMAL, MAP_ABSOLUTE);
	SetSCurve(&TFRPRudder, TRPLEFT, 0, 0, 0, 0, 0);

}
int EventHandle(int type, alias o, int x)
{
int TRPCOMBO; 
	if (&o == &TFRPRudder) { 
		GetAxisData(&o, x); 
		axdata.val = AxisVal(o[x], &axdata); 
		if(x == TRPLEFT | x == TRPRIGHT) { 
			axdata.locked = 1;			
			TRPCOMBO = -TFRPRudder[TRPRIGHT]/2 + TFRPRudder[TRPLEFT]/2; 
			DXAxis(DX_XROT_AXIS, TRPCOMBO); //Map to extra axis. 
		} 
		//axdata.locked = 1; 		
		if(!axdata.locked & !axdata.relative) GameOutput(&o, x, axdata.val); 
	}
	else DefaultMapping(&o, x);
}



Edit:

I did not realize the axis is in another independent rudder device. It work flawless, Thanks!


Edited by Spivak (09/16/16 11:26 AM)

Top
#4297608 - 09/20/16 01:07 AM Re: TFRP Rudders - Combined toe brake axis [Re: DarKcyde]
DarKcyde Offline
Member

Registered: 05/12/06
Posts: 117
Loc: Canada
Spivak, looks like you figured it out. You don't have to map the rudders at all, that' why we set them to Mode_filtered. That disables them, its that last GameOutput(&o, x, axdata.val); that tells them to perform their original function, assuming we didn't set axdata.locked. Took me hours of staring at Target.tmh to figure out how this stuff works.

OK, I was wrong, Elite does only use the axis as a digital On/Off when you map Up and Down separately. Good thing we're doing all this coding.

I did some more tinkering. This code maps the left/right toe to a single axis (Differential_Toe = X axis), and maps the Both-brakes-down axis to Y axis. Rudder just passes through to the original Z axis. All of that on the original T-rudder device, so it leaves all the Thrustmaster Combined DX axes for the warthog. No need to use MapAxis() for anything on the rudders, it all runs on its own device. It's a bit easier to see in Device Analyzer than the joystick control panel.

Use Configure(&TFRPRudder, MODE_FILTERED); as the other examples.

There is a fair bit of crosstalk between the X and Y axes at partial travel, you may have to comment out the GameOutput line of Differential_Toe to get the combo to map in game.

Code:
int EventHandle(int type, alias o, int x) {
	int TRPCOMBO, Differential_Toe;

	if (&o == &TFRPRudder) {  
		GetAxisData(&o, x);
		axdata.val = AxisVal(o[x], &axdata);
		if(x == TRPLEFT | x == TRPRIGHT) {
			axdata.locked = 1;
			Differential_Toe = -TFRPRudder[TRPRIGHT]/2 + TFRPRudder[TRPLEFT]/2;
			GameOutput(&o, TRPRIGHT, Differential_Toe);
			
			if (TFRPRudder[TRPLEFT] < TFRPRudder[TRPRIGHT]) TRPCOMBO = TFRPRudder[TRPRIGHT];
			else TRPCOMBO = TFRPRudder[TRPLEFT];
			GameOutput (&o, TRPLEFT, -TRPCOMBO);
		}
		if(!axdata.locked & !axdata.relative) GameOutput(&o, x, axdata.val);
	}
	
	else DefaultMapping(&o, x);
}



I like this better than my original stuff. Does everything in one place, with no downsides.

Top
#4298054 - 09/22/16 01:12 AM Re: TFRP Rudders - Combined toe brake axis [Re: DarKcyde]
Wolfereign Offline
Junior Member

Registered: 09/22/16
Posts: 2
Originally Posted By: DarKcyde
Code:
int EventHandle(int type, alias o, int x) {
	int TRPCOMBO, Differential_Toe;

	if (&o == &TFRPRudder) {  
		GetAxisData(&o, x);
		axdata.val = AxisVal(o[x], &axdata);
		if(x == TRPLEFT | x == TRPRIGHT) {
			axdata.locked = 1;
			Differential_Toe = -TFRPRudder[TRPRIGHT]/2 + TFRPRudder[TRPLEFT]/2;
			GameOutput(&o, TRPRIGHT, Differential_Toe);
			
			if (TFRPRudder[TRPLEFT] < TFRPRudder[TRPRIGHT]) TRPCOMBO = TFRPRudder[TRPRIGHT];
			else TRPCOMBO = TFRPRudder[TRPLEFT];
			GameOutput (&o, TRPLEFT, -TRPCOMBO);
		}
		if(!axdata.locked & !axdata.relative) GameOutput(&o, x, axdata.val);
	}
	
	else DefaultMapping(&o, x);
}



I like this better than my original stuff. Does everything in one place, with no downsides.


Thanks for the hard work however I noticed with this method You cannot set Deadzones/Curves for the Right/Left toe brake axis (X/Y-Axis). The pedal axis (Z) responds to the SetSCurve method fine but the other two do not. Do you know of a work around for this, or another way other than GameOuput since it seams to ignore Deadzones/Curves?

Top
#4298061 - 09/22/16 02:43 AM Re: TFRP Rudders - Combined toe brake axis [Re: DarKcyde]
Wolfereign Offline
Junior Member

Registered: 09/22/16
Posts: 2
Sorry Answered my own question here's updated code that calls the functions to apply the curved/deadzone settings
Code:
int main(){
        
        SetSCurve(&TFRPRudder, TRPRIGHT, 0, 20, 0, 0, 0); //Right Toe Brake
        SetSCurve(&TFRPRudder, TRPLEFT, 0, 0, 20, 0, 0); //Left Toe Brake
        SetSCurve(&TFRPRudder, TRUDDER, 0, 10, 0, 0, 0); //Rudder Pedals

}//end main

int EventHandle(int type, alias o, int x){
	
	//Create needed variables
	int TRPCOMBO;
	int Differential_Toe;	
	
	if (&o == &TFRPRudder) {
		
		GetAxisData(&o, x);
		axdata.val = AxisVal(o[x], &axdata);
		
		if(x == TRPLEFT | x == TRPRIGHT) {			
			
			axdata.locked = 1;
			Differential_Toe = -TFRPRudder[TRPRIGHT]/2 + TFRPRudder[TRPLEFT]/2;
			
			//apply curves/deadzones and output data
			Differential_Toe = AxisVal(Differential_Toe, &axdata);
			GameOutput(&o, TRPRIGHT, Differential_Toe);
				
			if (TFRPRudder[TRPLEFT] < TFRPRudder[TRPRIGHT])
				TRPCOMBO = TFRPRudder[TRPRIGHT];
			else
				TRPCOMBO = TFRPRudder[TRPLEFT];
			
			//apply curves/deadzones and output data
			TRPCOMBO = AxisVal(TRPCOMBO, &axdata);			
			GameOutput(&o, TRPLEFT, -TRPCOMBO);
			
		}//end inner if
		
		if(!axdata.locked & !axdata.relative) 
			GameOutput(&o, x, axdata.val);
			
	}//end out if
	
	else DefaultMapping(&o, x);

}//end EventHandler



"AxisVal" has to be used before "GameOutput" in order tailor the output data with the user defined curves/deadzones.


Edited by Wolfereign (09/22/16 02:45 AM)

Top
Topic Options
Rate This Topic
Hop to:

Moderator:  RacerGT 
 
Quick Search
Recent Articles
Support SimHQ
.
Social


Recent Topics
Free game on Steam: Fractured Space. Any good?
by letterboy1
Yesterday at 08:11 PM
How money changes people
by Desert Eagle
Yesterday at 02:47 PM
Good docu on Tobruk 40-41
by Stewie
Yesterday at 01:52 PM
Ye old sawmill
by KraziKanuK
Yesterday at 01:29 PM
Big R/C P-47
by KRT_Bong
Yesterday at 01:03 PM
Best flight sim collection owner?
by tagTaken2
Yesterday at 06:11 AM
Film ending credits
by PanzerMeyer
09/23/16 07:35 PM
My computer has been hacked
by KraziKanuK
09/23/16 08:44 AM
Heads up....
by Stewie
09/23/16 08:01 AM
Latest Mean Tweets......love Bryan Cranston's.....
by RossUK
09/23/16 07:52 AM
 

Forum Use Agreement | Privacy Statement
Copyright 1997-2016, SimHQ Inc. All Rights Reserved.