Previous Thread
Next Thread
Print Thread
Rate This Thread
Hop To
#4435154 - 08/21/18 09:29 AM Generate a key input upon an axis value  
Joined: May 2001
Posts: 468
Joao Muas Offline
Member
Joao Muas  Offline
Member

Joined: May 2001
Posts: 468
Portugal
Hello there.

What I want to achieve is very simple in principle.

Let's say I want my trigger TS1 to work as an aircraft differential brakes (IL-2 BOS).

By default "," brakes the main left wheel and "." brakes the main right wheel.

I want to press TS1 and generate a "," if the rudder (DX_ZROT_AXIS in my case) is turned to the left, and a "." if the rudder is turned to the right.

(Note that AXMAP2 doesn't achieve exactly the same thing, as the output is generated by the axis input, not the key input.)

This should be easy to achieve if we can read an axis value, like this pseudo code for example:
Code
I press TS1, and if DX_ZROT_AXIS has a negative value (rotated to the left) TS1 generates a ","
I press TS1, and if DX_ZROT_AXIS has a positive value (rotated to the right) TS1 generates a "."
I press TS1, and if DX_ZROT_AXIS has a zero value (rudder is centered) than I want TS1 to generate both "," and "."

I don't know how to read the current axis value, so how can I achieve this?

Thanks.


Last edited by Joao Muas; 08/21/18 09:30 AM.
Inline advert (2nd and 3rd post)

#4435253 - 08/22/18 12:54 AM Re: Generate a key input upon an axis value [Re: Joao Muas]  
Joined: May 2001
Posts: 468
Joao Muas Offline
Member
Joao Muas  Offline
Member

Joined: May 2001
Posts: 468
Portugal
SOLVED!!

It works like this (for the T16000 stick):
Code
MapKey(&T16000, TS1,
    EXEC(
        "if(T16000[RUDDER]<0) ActKey(KEYON+',');" // rudder turned to the left, press left wheel brake key
        "if(T16000[RUDDER]==0) ActKey(KEYON+',');" // rudder centered, press left wheel brake key
        "if(T16000[RUDDER]==0) ActKey(KEYON+'.');" // rudder centered, press right wheel brake key 
        "if(T16000[RUDDER]>0) ActKey(KEYON+'.');" // rudder turned to the right, press right wheel brake key
    )
);
MapKeyR(&T16000, TS1,
    EXEC(
        "ActKey(',');" // release left wheel brake key
        "ActKey('.');" // release right wheel brake key
    )
);


Got it from here
Thank you!!

#4435258 - 08/22/18 03:03 AM Re: Generate a key input upon an axis value [Re: Joao Muas]  
Joined: Jul 2016
Posts: 61
Drakoz Offline
Junior Member
Drakoz  Offline
Junior Member

Joined: Jul 2016
Posts: 61
I was just about to remind you of the T16000[RUDDER] thing. Looks like are figuring this stuff out!

I just wasn't sure if you had a TARGET compatible rudder pedal set. You would either need a rudder connected to your HOTAS, like connected to the T16000 Throttle, or connected to the HOTAS Cougar Joystick, or using the Thrustmaster T.RJ12 Rudder adapter in order to see the current axis position of the rudder in TARGET. The T.RJ12 adapter uses the same RJ12 style connector and pinout as the connector on your T16000 Throttle, but it allows the rudder to be treated as a separate device instead of part of the T16000. Since you have a T16000, you don't care, but for someone wanting to add a rudder to the HOTAS Warthog, this adapter would give TARGET compatibility. The adapter basically brings in 3 analog axis which are TARGET compatible, so it is possible to create a custom cable and connect any 3 analog axis (pots or hall effect sensors) to TARGET.

One suggestion, instead of using the ranges of < 0, > 0, and 0, it would be better to have a little dead zone specified for the center of the axis. So maybe use < 100, > 100, and -99 to +99 for the "rudder centered" position. Or use the axis setup command to add a dead zone to the Rudder. There are 65,535 possible positions for an axis, so the difference between -1, 0, and 1 is practically in the noise - too easy to get a false action.

#4435353 - 08/22/18 06:34 PM Re: Generate a key input upon an axis value [Re: Joao Muas]  
Joined: Nov 2001
Posts: 3,955
Sokol1 Offline
Senior Member
Sokol1  Offline
Senior Member

Joined: Nov 2001
Posts: 3,955
Internet
Originally Posted by Joao Muas

Let's say I want my trigger TS1 to work as an aircraft differential brakes (IL-2 BOS).



Bo'X series has 'differential brakes' modeled for all aircraft's, just press the button assigned for "Wheel brakes" and move rudder pedal or "twist rudder", for brake right of left wheel individually, no "jugglery" with scripts is need. wink






#4435364 - 08/22/18 08:03 PM Re: Generate a key input upon an axis value [Re: Sokol1]  
Joined: May 2001
Posts: 468
Joao Muas Offline
Member
Joao Muas  Offline
Member

Joined: May 2001
Posts: 468
Portugal
Originally Posted by Sokol1
Originally Posted by Joao Muas

Let's say I want my trigger TS1 to work as an aircraft differential brakes (IL-2 BOS).



Bo'X series has 'differential brakes' modeled for all aircraft's, just press the button assigned for "Wheel brakes" and move rudder pedal or "twist rudder", for brake right of left wheel individually, no "jugglery" with scripts is need. wink






It's true... only at some extent... if you want to brake just one wheel without moving the rudder (German & American style) you really need to press the key for each wheel separately.
If you refer to the Russian & British system, yes... and of course you can use this solution on any aircraft, cause it works, but it's not exactly the same thing.
That is why BO'X correctly includes both options, so you are able to accurately emulate the behavior of the plane you are flying with your joystick inputs. smile

#4435369 - 08/22/18 08:47 PM Re: Generate a key input upon an axis value [Re: Drakoz]  
Joined: May 2001
Posts: 468
Joao Muas Offline
Member
Joao Muas  Offline
Member

Joined: May 2001
Posts: 468
Portugal
Originally Posted by Drakoz
One suggestion, instead of using the ranges of < 0, > 0, and 0, it would be better to have a little dead zone specified for the center of the axis. So maybe use < 100, > 100, and -99 to +99 for the "rudder centered" position. Or use the axis setup command to add a dead zone to the Rudder. There are 65,535 possible positions for an axis, so the difference between -1, 0, and 1 is practically in the noise - too easy to get a false action.

True. To cover all inputs, I also have a AXMAP2( LIST( 0, 45, 55, 100 )… to execute the same, with a dead zone of 10%. So I changed my above code conditions with the T16000[RUDDER] center value within -3277 to 3277 to match the same dead zone.

Code
include "target.tmh"
char brakes; // variable for diferential braking

int main()
{

	MapKey(&T16000, TS1,
		EXEC("if(T16000[RUDDER]<-3277) ActKey(KEYON+',');"
                     "if(T16000[RUDDER]>=-3277 & T16000[RUDDER]<=3277) {ActKey(KEYON+','); ActKey(KEYON+'.');}"
                     "if(T16000[RUDDER]>3277) ActKey(KEYON+'.');"
                     "brakes=1;"));		
	MapKeyR(&T16000, TS1, EXEC("ActKey(','); ActKey('.'); brakes=0;"));

	KeyAxis(&T16000, RUDDER, 0,
		AXMAP2( LIST( 0, 45, 55, 100 ),
                    EXEC("ActKey('.'); if(brakes) ActKey(KEYON+',');"),
                    EXEC("ActKey(','); ActKey('.'); if(brakes) {ActKey(KEYON+','); ActKey(KEYON+'.');}"),
                    EXEC("ActKey(','); if(brakes) ActKey(KEYON+'.');")));

}
int EventHandle(int type, alias o, int x)
{
	DefaultMapping(&o, x);
}

Seems to work pretty well.

Last edited by Joao Muas; 08/22/18 08:48 PM.

Moderated by  RacerGT 

Quick Search
Recent Articles
Support SimHQ

If you shop on Amazon use this Amazon link to support SimHQ
.
Social


Recent Topics
Roy Cross is 100 Years Old
by F4UDash4. 04/23/24 11:22 AM
Actors portraying US Presidents
by PanzerMeyer. 04/19/24 12:19 PM
Dickey Betts was 80
by Rick_Rawlings. 04/19/24 01:11 AM
Exodus
by RedOneAlpha. 04/18/24 05:46 PM
Grumman Wildcat unique landing gear
by Coot. 04/17/24 03:54 PM
Peter Higgs was 94
by Rick_Rawlings. 04/17/24 12:28 AM
Whitey Herzog was 92
by F4UDash4. 04/16/24 04:41 PM
Anyone can tell me what this is?
by NoFlyBoy. 04/16/24 04:10 PM
Copyright 1997-2016, SimHQ Inc. All Rights Reserved.

Powered by UBB.threads™ PHP Forum Software 7.6.0