Havner's idea on the ED forums has inspired me to write a similar implementation for the Cougar. The idea is to take the best of both the "standard" helicopter trimmer and the "Central Position Trimmer Mode" (hereafter CPTM) and combine them. Since I use the Cougar, I was able to incorporate the rudder as well. This could be easily modified for the Warthog, though without the rudder trim. CPTM must be disabled in DCS for this to work.

Here's how it works:
I have trim mapped to H4U (similar in position to the KA-50, and since I already use S3 for a modifier I didn't want to use that). H4U short does the standard trimmer without any CPTM, allowing for small and quick adjustments. H4U long enables CPTM, but instead of locking the joystick until recenter it re-trims the stick in the opposite direction (in TARGET), which has the same effect, but still allows minor adjustments without having to recenter. This allows you to make a major trim adjustment, then refine it as necessary without recentering.

Finally, should you want to recenter, you can do so using the "old method" of moving the joystick back to center (though the trim will offset in the other direction until the joystick is centered), and you can even specify the size of the center region at which point opposite trim is released. The other option is to recenter while keeping the trim offset in realtime, which can be accomplished by holding H4D or S3. Holding either of these buttons while moving the stick to center will re-trim the stick at defined polling intervals, essentially neutralizing the stick until the button is released.

Here's the code (though simplified from my profile to keep the message simple):
Click to reveal..
Code:
int    CenterPositTrimmer        =    50 ;
//    Allows TARGET based Central Position Trimmer Mode (CPTM) for helicopters.  Positive value is polling time in ms for neutral retrimming; set 0 to disable.
//    If enabled, be sure to disable CPTM in DCS Options.
int        CenterPositTempo    =    500;
//    Default TEMPO value (TEMPO short will be standard trimmer for minor changes, long for CPTM)
int        CenterPositRudder    =    0 ;
 //    If 1, TARGET-based CPTM also trims rudder.
int        CenterPositZone        =   2000    ;
//    "Dead Zone" for CPTM recentering.  Value between 0 and 32768 (lower is smaller dead zone).



int CPTM_Trim(int trim, int prof=0, int poll=2)
//poll = 2 because that is the REXEC flag for both polling trimmers.
{
if (    (prof == 2) & (!CenterPositRudder)   )
//if rudder trim disengaged this will still kill rudder trim to BS2 regardless of TEMPO or setting.
//Forum note: prof == 2 is the BS2 profile.
//Forum note: this condition is now obsolete with selectable rudder trim for the Ka-50 in DCS
    {
    ActKey(CHAIN(    KEYON+D(),
                    KEYON+PULSE+Rudder_Left,
                    KEYON+D(),
                    KEYON+PULSE+Rudder_Right    ));
    }
if (CenterPositTrimmer)
    {
    StopAutoRepeat(poll);    //should stop any polling of previous trimmers
    
    if (trim)            //trim enabled (doesn't need to be CPTM TEMPO)
        {
        if (CPTM_Engaged)    //forces axis trim if TEMPO long
                                     //nested if/then to exit routine if TEMPO short
            {
           //divide by 32 because the axis has 65536 values and trim has 2048
            TrimDXAxis(DX_X_AXIS, SET(-HCougar[JOYX]/32));    
            TrimDXAxis(DX_Y_AXIS, SET(-HCougar[JOYY]/32));
            if  (CenterPositRudder)  TrimDXAxis(DX_ZROT_AXIS, SET(-HCougar[RUDDER]/32));
            }
        }
    else    //trim reset
        {
        TrimDXAxis(DX_X_AXIS, SET(0));
        TrimDXAxis(DX_Y_AXIS, SET(0));
        if (CenterPositRudder) TrimDXAxis(DX_ZROT_AXIS, SET(0));
        }


    CPTM_Engaged = 0;
    CPTM_Mapping(trim, MFD_Var);  //Forum Note: MFD_Var indicates aircraft profile
    }
}



int CPTM_Recenter_Active()
{
    TrimDXAxis(DX_X_AXIS, SET(-HCougar[JOYX]/32));    
    TrimDXAxis(DX_Y_AXIS, SET(-HCougar[JOYY]/32));
    if (CenterPositRudder) TrimDXAxis(DX_ZROT_AXIS, SET(-HCougar[RUDDER]/32));
}

int    CPTM_Center_Poll(int dz)    //dz is deadzone value
{
if (    (abs(HCougar[JOYX]) < dz) & (abs(HCougar[JOYY]) < dz) &
    (    ((CenterPositRudder) & (abs(HCougar[RUDDER]) < dz))
        | (!CenterPositRudder)    )    ) //all axes within dead zone
    CPTM_Trim(0);
}


int CPTM_Mapping(int trim, int prof = 0)
//Forum Note: my actual profile remaps TG1/2, S1 and S2 to prevent my CommState routine (which remaps Hats 2-4 to F1-F12 for the comms menu) from engaging.  These are likely unnecessary for your own uses and are omitted.
{
if (CenterPositTrimmer)
    {
    if (trim)
        {
        MapKey    (&HCougar, H4D, CHAIN(EXEC("StopAutoRepeat(2);"), D(30), REXEC(2,CenterPositTrimmer,"CPTM_Recenter_Active();")));      

        MapKeyR    (&HCougar, H4D, EXEC("CPTM_Trim(0);"));    
        MapKey    (&HCougar, S3,     CHAIN(DX30,EXEC("StopAutoRepeat(2);"), D(30), REXEC(2,CenterPositTrimmer, "CPTM_Recenter_Active();")));  
        MapKeyR    (&HCougar, S3,     EXEC("CPTM_Trim(0);"));
        }
    else    //release
        {
        H4UD_CPTM(prof);  //Forum Note: prof is the designated aircraft profile
        MapKey    (&HCougar, S3, CHAIN(DX30,TEMPO(DX3,     EXEC("S3S4Shifted();"), 300)));
//DX3 short, long for modifier and eject check (forum note: another routine that includes eject check; just set this to your default S3 functionality instead)
        MapKeyR    (&HCougar, S3,                             EXEC("S3Release();"));
 //forum note: another routine that includes eject check
        }
    }
}
//Forum Note: this routine reassigns H4U/H4D functionality after trimming is finished.  You can customize this liberally for your own uses, though keep the CPTM values and routines in place.
int H4UD_CPTM(int prof = 0)
{
if (prof == 2)
    {
    MapKeyIO(&HCougar,    H4U,    TEMPO(EXEC("SnapViewModRelease(KBPress);"), EXEC("SetSnapViewT(8);")),        
                                TEMPO(CHAIN(EXEC("CPTM_Engaged = 0;"),DX15),CHAIN(EXEC("CPTM_Engaged = 1;"),DX15),CenterPositTempo));        //Snapview8 or DX15 (force trim)
    MapKeyRIO(&HCougar, H4U,    0,    CHAIN(EXEC("CPTM_Trim(1,2);"),REXEC(2, CenterPositTrimmer, "CPTM_Center_Poll(CenterPositZone);")));

    MapKey    (&HCougar,    H4D,    DX17);
    MapKeyRIO(&HCougar, H4D,    EXEC("CPTM_Trim(0);"),0);
//Forum Note: S3+DX17 is used for reset trim in BS2

    }                        
else
    {
    MapKey    (&HCougar,    H4U,    TEMPO(CHAIN(EXEC("CPTM_Engaged = 0;"),DX15), CHAIN(EXEC("CPTM_Engaged = 1;"),DX15),CenterPositTempo));    //Force Trim Set; shift reset
    MapKeyRIO(&HCougar, H4U,            EXEC("CPTM_Trim(0);"),
                                CHAIN(    EXEC("CPTM_Trim(1);"),    REXEC(2, CenterPositTrimmer, "CPTM_Center_Poll(CenterPositZone);")));
    if (prof == 6)
        {
        MapKeyIO(&HCougar,    H4D,    CHAIN(    PULSE+DX17,D(200),
                                            PULSE+DX17,D(200),
                                            PULSE+DX17,D(200),
                                            PULSE+DX17,D(200),
                                            PULSE+DX17), DX17);    //flare; shift for 5x flares
        MapKeyR    (&HCougar,    H4D,    0);
        }
    else
        {
        MapKey    (&HCougar,    H4D,    DX17);    
        MapKeyR    (&HCougar,    H4D,    0);    
        }
    }        
}


I know it's tough reading a profile with other integration (and without context of the other routines), but hopefully you can get the important stuff from here. I've added comments where I felt that my other routines might add confusion.

Regards,

Last edited by HomeFries; 10/30/15 05:51 PM.

-Home Fries

"Pacifism is a shifty doctrine under which a man accepts the benefits of the social group without being willing to pay - and claims a halo for his dishonesty."
- Robert A. Heinlein

The average naval aviator, despite the sometimes swaggering exterior, is very much capable of such feelings as love, affection, intimacy, and caring. These feelings just don't involve anyone else.