[TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Tutorials, How-tos and FAQs for the Titan One device.

[TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Postby fbmrider86 » Thu Feb 26, 2015 4:38 am

Hi folks, long time lurker/tinker-er here. Awhile back I came across a smokin' deal on a G27 and after having so much fun playing Forza with a controller, I'm so glad I stumbled across the TitanOne-style devices. After messing around with some various snippets of code from here and the "other" site, I feel I've compiled a great collection of all of the "wants" of the typical G27/Forza fan (sorry, no FFB!).

Image
Image



******************************** IMPORTANT ********************************

You must utilize Controller Layout 10 for this code to work properly!

*****************************************************************************



  • This code changes some of the typically seen settings for the G27 and Forza games to include as many functions native to the game(s) as possible.
  • YOU MUST USE Controller Layout 10 for this script to function properly, DO NOT USE Layout 4/6!!!
  • Script has been fully tested utilizing Forza 4 (XB360) and Forza 5 (XB1).
  • Script is confirmed working both inside GTuner or utilizing MaxAimDI standalone application.
  • D-pad and "lettered" buttons are mapped to their respective buttons on the shifter.
  • Features Include:
  • - Adjustable steering deadzone ( controllable via 'wheelSlop' variable )
  • - Fully managed Brake and Accelerator pedals
  • - FULLY FUNCTIONAL Clutch Pedal (no longer an 'on/off' button, it is now mapped to an appropriate axis, allowing for a more realistic take off and proper clutch 'slipping'.
  • - Fully working six speed H-pattern shifter (utilizing J2Kbr's shifter code)
  • - Fully working Emergency Brake (mapped to Button 4) - Now complete with J-turns!
  • - EXTRA: "Line Lock" function - Allows for a certain amount of brake to be applied at the press of a single button (mimics the usage of an actual line-lock in drag racing, which locks the front brakes but allows the rear wheels to spin up and burnout).
  • - This is also fully adjustable, from 0 to 100% of braking applied during its activation.

Thanks to all of the folks who have made this possible, especially (and obviously) J2Kbr. You're a great asset to the sim-racing fans!

Button Layout:
Code: Select all
 
Layout Name: G27 (Forza w Clutch)
----------------------------------------------------
Controller:  XBox 360
GPC Script:  G27 (Forza w Clutch) [992 bytes]
----------------------------------------------------
00 XBox              : Button(23)
01 Back              : Button(8)
02 Start             : Button(7)
03 RB                : Button(5)
04 RT                :
05 RS                : Button(3)
06 LB                : Button(6)
07 LT                :
08 LS                : Button(1)
09 Right Analog Left : lY(-)
10 Right Analog Right: lY(+)
11 Right Analog Up   : Slider(2-)
12 Right Analog Down : Slider(2+)
13 Left Analog Left  : lX(-)
14 Left Analog Right : lX(+)
15 Left Analog Up    : lRZ(-)
16 Left Analog Down  : lRZ(+)
17 D-Pad Up          : POV1(0)
18 D-Pad Down        : POV1(180)
19 D-Pad Left        : POV1(270)
20 D-Pad Right       : POV1(90)
21 Y                 : Button(16)
22 B                 : Button(20), Button(19)
23 A                 : Button(22), Button(18)
24 X                 : Button(21), Button(17)
25 Extra 1           : Button(15)
26 Extra 2           : Button(9)
27 Extra 3           : Button(10)
28 Extra 4           : Button(11)
29 Extra 5           : Button(12)
30 Extra 6           : Button(13)
31 Extra 7           : Button(14)
32 Extra 8           : Button(22)
33 Extra 9           : Button(4)
----------------------------------------------------
Smoothness:   [X: 50] [Y: 50] [Y/X: 1.00]
Acceleration: [X: 1.000] [Y: 1.000] [Y/X: 1.000]
Sensitivity:  [X: 1.000] [Y: 1.000] [Y/X: 1.000]
Stickize:     [X: 142] [Y: 142] [Y/X: 1.00]
Deadzone:     [X: 20] [Y: 20] [Y/X: 1.00]
Shape:        [ELLIPSE]
 



Link to GLF (Layout) File:
G27 (Forza w Clutch).glf
(7.5 KiB) Downloaded 1289 times

Link to GPC Script: http://www.consoletuner.com/gpclib/?s=948

Raw GPC Code:
Code: Select all
/* 
   *****************************************************************************
   *****************************************************************************
   ******        Forza 4/5/Horizon/Horizon 2 - G27 MaxAimDI Script        ******
   ******                  Code written by:  FBMrider86                   ******
   ******    Contains code sourced from: J2Kbr (H pattern shifter code)   ******
   ******  Contains code sourced from: KittyDawn (steering deadzone code) ******
   *****************************************************************************
   *****************************************************************************
 
   *****************************************************************************
   ********************************  IMPORTANT  ********************************
   *****************************************************************************
   *****************************************************************************
   ***                                                                       ***
   **  You must utilize Controller Layout 10 for this code to work properly!  **
   ***                                                                       ***
   *****************************************************************************
   *****************************************************************************
   *****************************************************************************
   *****************************************************************************
 
   - This code changes some of the typically seen settings for the G27 and Forza games
     to include as many functions native to the game(s) as possible.
   - YOU MUST USE Controller Layout 10 for this script to function properly, DO NOT USE Layout 4/6!!!
   - Script has been fully tested utilizing Forza 4 (XB360) and Forza 5 (XB1). 
   - Features Include:
 
   *****************************************************************************************************
   *  * Adjustable steering deadzone ( controllable via 'wheelSlop' variable )                           *
   *  * Fully managed Brake and Accelerator pedals                                                       *
   *  * FULLY FUNCTIONAL Clutch Pedal (no longer an 'on/off' button, it is now mapped to                *
   *    an appropriate axis, allowing for a more realistic take off and proper                           *
   *    clutch 'slipping'.                                                                               *               
   *  * Fully working six speed H-pattern shifter (utilizing J2Kbr's shifter code)                       *
   *  * Fully working Emergency Brake (mapped to Button 4) - Now complete with J-turns!                   *
   *  * EXTRA: "Line Lock" function - Allows for a certain amount of brake to be applied               *
   *    at the press of a single button (mimics the usage of an actual line-lock in drag racing,       *
   *    which locks the front brakes but allows the rear wheels to spin up and burnout).               *
   *    This is also fully adjustable, from 0 to 100% of braking applied during its activation.        *
   *****************************************************************************************************
*/

 
int prev_gear, loop_gear;  // utilized by J2Kbr's shifter code
int wheelSlop = 8// accounts for slop in steering wheel (deadzone) : 0 would be NO dead zone (very twitchy)
int eBrake = 0;
int lineLockActivation = 0;
int brakePerc = 20// default is 20 ; utilized by Line Lock function
 
main
{
    // Steering Dead Zone Adjustment
    if(get_val(XB360_LX) < inv(wheelSlop) )
        set_val(XB360_LX, ((get_val(XB360_LX) * 7) / 9) - 23);
 
    else if( get_val( XB360_LX ) > wheelSlop )
        set_val( XB360_LX , (( get_val( XB360_LX ) * 7) / 9) + 23);
 
    else
        set_val( XB360_LX, get_val (XB360_LX ) );
 
    // END: Steering Dead Zone Adjustment
 
    // Pedal Manager:  Contains code to maintain Clutch, Accelerator and Brake Pedals
    pedalManager();
 
    // Line Lock - Button-activated braking; useful for burnouts - Mapped to Button 3
    lineLock();
 
    deactivateBtns();
 
    // Shifter Manager:  Contains code to manage 6-speed shifter
    shifterManager();
}
 
combo gearDOWN // Written by: J2Kbr
{
    set_val(XB360_LB, 100);
    wait(50);
    set_val(XB360_LB, 0);
    wait(40);
    set_val(XB360_LB, 0);
}
 
combo gearUP // Written by: J2Kbr
{
    set_val(XB360_RB, 100);
    wait(50);
    set_val(XB360_RB, 0);
    wait(40);
    set_val(XB360_RB, 0);
}
 
 
function deactivateBtns()  // Essentially 'deactivates' these inputs by not allowing the controller to change their value as we're utilizing their inputs elsewhere in the script.
{
    set_val(XB360_LS,0);
    set_val(XB360_RS,0);
    set_val(XB360_LY,0);
    set_val(XB360_RX,0);   
 
// added 3/1/2015: when line lock is active, disable the usage of up and down buttons in the game itself (avoids the constant switching between standard and detailed info. display)
    if( lineLockActivation == 1 )
    {
            set_val( XB360_UP, 0);
            set_val( XB360_DOWN, 0);
    }
}
 
function pedalManager() // Properly addresses Accelerator, Brake, and Clutch (and Emergency Brake)
{   
    // Accelerator Pedal
    set_val(XB360_RT, inv((get_val(XB360_RX))/2) + 50);
 
    // Brake Pedal
    set_val(XB360_LT, inv((get_val(XB360_LY))/2) + 50);
 
    // Emergency Brake - Map using CEMU_EXTRA9
    if( event_press( CEMU_EXTRA9) )  // EBrake and Clutch are on same Axis, must check for button press first
    {
        eBrake = 1;
    }
    if (event_release (CEMU_EXTRA9) )
        eBrake = 0;
 
    // Clutch Pedal - Check to see if E Brake has been activated first
    if( eBrake == 0 )
    {
        // Clutch and E Brake share the right analog stick's Y axis
        if(get_val(XB360_RY) < 0)
            set_val(XB360_RY, (get_val(XB360_RY)/2)-50);
        else if(get_val(XB360_RY) >= 0)
            set_val(XB360_RY, (get_val(XB360_RY)-100)/2);
    }
    // Activate Emergency Brake
    else
        set_val(XB360_RY, 100);
}
 
function lineLock() // Burnouts!
{
    // Line Lock - Applies braking force to vehicle (default is 20%) ; mapped to Button 3 on shifter
    //               Braking force is adjustable while Line Lock button is activated/pressed.
    //             Pressing Up on D-Pad while activated increases braking effectiveness.
    //               Pressing Down on D-Pad while activated decreases braking effectiveness.
    //             Pressing Button 1 while activated will reset the line lock to default of 20%
    //             Default: 20 ; Minimum: 0 ; Maximum : 100
 
    if( event_press( XB360_RS) )
        lineLockActivation = 1;
    if( event_release( XB360_RS) )
        lineLockActivation = 0;
 
    if( lineLockActivation == 1 )
    {
        if( event_press( XB360_UP) && brakePerc < 100 )
            brakePerc = brakePerc + 1;
        if( event_press( XB360_DOWN) && brakePerc > 0 )
            brakePerc = brakePerc - 1;
        if( event_press( XB360_LS) )
            brakePerc = 20;
 
        set_val(XB360_LT, brakePerc);
    }
 
}
 
function shifterManager() // Written by: J2Kbr
{
    // Reverse
    if( event_press(CEMU_EXTRA1) )
        loop_gear = loop_gear + 1 - prev_gear;
    else if( event_release(CEMU_EXTRA1 ))
        prev_gear = 1;
 
    // 1st Gear
    if( event_press(CEMU_EXTRA2) )
        loop_gear = loop_gear + 2 - prev_gear;
    else if( event_release(CEMU_EXTRA2) )
        prev_gear = 2;
 
    // 2nd Gear
    if( event_press(CEMU_EXTRA3) )
        loop_gear = loop_gear + 3 - prev_gear;
    else if( event_release(CEMU_EXTRA3) )
        prev_gear = 3;
 
    // 3rd Gear
    if( event_press(CEMU_EXTRA4) )
        loop_gear = loop_gear + 4 - prev_gear;
    else if( event_release(CEMU_EXTRA4) )
        prev_gear = 4;
 
    // 4th Gear
    if( event_press(CEMU_EXTRA5) )
        loop_gear = loop_gear + 5 - prev_gear;
    else if( event_release(CEMU_EXTRA5) )
        prev_gear = 5;
 
    // 5th Gear
    if( event_press(CEMU_EXTRA6) )
        loop_gear = loop_gear + 6 - prev_gear;
    else if( event_release(CEMU_EXTRA6) )
        prev_gear = 6;
 
    // 6th Gear
    if( event_press(CEMU_EXTRA7) )
        loop_gear = loop_gear + 7 - prev_gear;
    else if( event_release(CEMU_EXTRA7) )
        prev_gear = 7;
 
    // Press the LB or RB button to change the gear based on H-Shifter
    if(!combo_running(gearUP) && !combo_running(gearDOWN))
    {
        if(loop_gear > 0)
        {
            loop_gear = loop_gear - 1;
            combo_run(gearUP);
        }
        else if(loop_gear < 0)
        {
            loop_gear = loop_gear + 1;
            combo_run(gearDOWN);
        }
    }
}
 
User avatar
fbmrider86
Staff Sergeant
Staff Sergeant
 
Posts: 10
Joined: Wed Dec 31, 2014 2:03 am

Re: [TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Postby Chevy1995 » Sat Jan 02, 2016 12:16 am

i installed this layout now my gas and brake are on 50%
User avatar
Chevy1995
Sergeant First Class
Sergeant First Class
 
Posts: 22
Joined: Mon Dec 28, 2015 1:57 am

Re: [TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Postby AKHUGHES90 » Sat Jan 02, 2016 12:28 am

Try this

Code: Select all
/*
   *****************************************************************************
   *****************************************************************************
   ******        Forza 4/5/Horizon/Horizon 2 - G27 MaxAimDI Script        ******
   ******                  Code written by:  FBMrider86                   ******
   ******    Contains code sourced from: J2Kbr (H pattern shifter code)   ******
   ******  Contains code sourced from: KittyDawn (steering deadzone code) ******
   *****************************************************************************
   *****************************************************************************

   *****************************************************************************
   ********************************  IMPORTANT  ********************************
   *****************************************************************************
   *****************************************************************************
   ***                                                                       ***
   **  You must utilize Controller Layout 10 for this code to work properly!  **
   ***                                                                       ***
   *****************************************************************************
   *****************************************************************************
   *****************************************************************************
   *****************************************************************************

   - This code changes some of the typically seen settings for the G27 and Forza games
     to include as many functions native to the game(s) as possible.
   - YOU MUST USE Controller Layout 10 for this script to function properly, DO NOT USE Layout 4/6!!!
   - Script has been fully tested utilizing Forza 4 (XB360) and Forza 5 (XB1). 
   - Features Include:
   
   *****************************************************************************************************
   *  * Adjustable steering deadzone ( controllable via 'wheelSlop' variable )                     *
   *  * Fully managed Brake and Accelerator pedals                                          *
   *  * FULLY FUNCTIONAL Clutch Pedal (no longer an 'on/off' button, it is now mapped to             *
   *    an appropriate axis, allowing for a more realistic take off and proper                     *
   *    clutch 'slipping'.                                                            *           
   *  * Fully working six speed H-pattern shifter (utilizing J2Kbr's shifter code)                  *
   *  * Fully working Emergency Brake (mapped to Button 4) - Now complete with J-turns!               *
   *  * EXTRA: "Line Lock" function - Allows for a certain amount of brake to be applied            *
   *    at the press of a single button (mimics the usage of an actual line-lock in drag racing,       *
   *    which locks the front brakes but allows the rear wheels to spin up and burnout).            *
   *    This is also fully adjustable, from 0 to 100% of braking applied during its activation.        *
   *****************************************************************************************************
*/


int prev_gear, loop_gear;  // utilized by J2Kbr's shifter code
int wheelSlop = 8// accounts for slop in steering wheel (deadzone) : 0 would be NO dead zone (very twitchy)
int eBrake = 0;
int lineLockActivation = 0;
int brakePerc = 20// default is 20 ; utilized by Line Lock function

main
{
    // Steering Dead Zone Adjustment
    if(get_val(XB360_LX) < inv(wheelSlop) )
        set_val(XB360_LX, ((get_val(XB360_LX) * 7) / 9) - 23);

    else if( get_val( XB360_LX ) > wheelSlop )
        set_val( XB360_LX , (( get_val( XB360_LX ) * 7) / 9) + 23);

    else
        set_val( XB360_LX, get_val (XB360_LX ) );

    // END: Steering Dead Zone Adjustment
   
    // Pedal Manager:  Contains code to maintain Clutch, Accelerator and Brake Pedals
    pedalManager();
   
    // Line Lock - Button-activated braking; useful for burnouts - Mapped to Button 3
    lineLock();
   
    deactivateBtns();

    // Shifter Manager:  Contains code to manage 6-speed shifter
    shifterManager();
}

combo gearDOWN // Written by: J2Kbr
{
    set_val(XB360_LB, 100);
    wait(50);
    set_val(XB360_LB, 0);
    wait(40);
    set_val(XB360_LB, 0);
}

combo gearUP // Written by: J2Kbr
{
    set_val(XB360_RB, 100);
    wait(50);
    set_val(XB360_RB, 0);
    wait(40);
    set_val(XB360_RB, 0);
}


function deactivateBtns()  // Essentially 'deactivates' these inputs by not allowing the controller to change their value as we're utilizing their inputs elsewhere in the script.
{
    set_val(XB360_LS,0);
   set_val(XB360_RS,0);
   set_val(XB360_LY,0);
   set_val(XB360_RX,0);   

// added 3/1/2015: when line lock is active, disable the usage of up and down buttons in the game itself (avoids the constant switching between standard and detailed info. display)
    if( lineLockActivation == 1 )
    {
            set_val( XB360_UP, 0);
            set_val( XB360_DOWN, 0);
    }
}

function pedalManager() // Properly addresses Accelerator, Brake, and Clutch (and Emergency Brake)
{   
    // Accelerator Pedal
    set_val(XB360_RT, inv((get_val(XB360_RX))/2));

    // Brake Pedal
    set_val(XB360_LT, inv((get_val(XB360_LY))/2));

    // Emergency Brake - Map using CEMU_EXTRA9
    if( event_press( CEMU_EXTRA9) )  // EBrake and Clutch are on same Axis, must check for button press first
    {
        eBrake = 1;
    }
    if (event_release (CEMU_EXTRA9) )
        eBrake = 0;

    // Clutch Pedal - Check to see if E Brake has been activated first
    if( eBrake == 0 )
    {
        // Clutch and E Brake share the right analog stick's Y axis
      if(get_val(XB360_RY) < 0)
            set_val(XB360_RY, (get_val(XB360_RY)/2)-50);
        else if(get_val(XB360_RY) >= 0)
            set_val(XB360_RY, (get_val(XB360_RY)-100)/2);
    }
    // Activate Emergency Brake
    else
        set_val(XB360_RY, 100);
}

function lineLock() // Burnouts!
{
    // Line Lock - Applies braking force to vehicle (default is 20%) ; mapped to Button 3 on shifter
   //            Braking force is adjustable while Line Lock button is activated/pressed.
    //             Pressing Up on D-Pad while activated increases braking effectiveness.
   //            Pressing Down on D-Pad while activated decreases braking effectiveness.
    //             Pressing Button 1 while activated will reset the line lock to default of 20%
    //             Default: 20 ; Minimum: 0 ; Maximum : 100

    if( event_press( XB360_RS) )
        lineLockActivation = 1;
    if( event_release( XB360_RS) )
        lineLockActivation = 0;

    if( lineLockActivation == 1 )
    {
        if( event_press( XB360_UP) && brakePerc < 100 )
            brakePerc = brakePerc + 1;
        if( event_press( XB360_DOWN) && brakePerc > 0 )
            brakePerc = brakePerc - 1;
        if( event_press( XB360_LS) )
            brakePerc = 20;

        set_val(XB360_LT, brakePerc);
    }

}

function shifterManager() // Written by: J2Kbr
{
    // Reverse
    if( event_press(CEMU_EXTRA1) )
        loop_gear = loop_gear + 1 - prev_gear;
    else if( event_release(CEMU_EXTRA1 ))
        prev_gear = 1;

    // 1st Gear
    if( event_press(CEMU_EXTRA2) )
        loop_gear = loop_gear + 2 - prev_gear;
    else if( event_release(CEMU_EXTRA2) )
        prev_gear = 2;

    // 2nd Gear
    if( event_press(CEMU_EXTRA3) )
        loop_gear = loop_gear + 3 - prev_gear;
    else if( event_release(CEMU_EXTRA3) )
        prev_gear = 3;

    // 3rd Gear
    if( event_press(CEMU_EXTRA4) )
        loop_gear = loop_gear + 4 - prev_gear;
    else if( event_release(CEMU_EXTRA4) )
        prev_gear = 4;

    // 4th Gear
    if( event_press(CEMU_EXTRA5) )
        loop_gear = loop_gear + 5 - prev_gear;
    else if( event_release(CEMU_EXTRA5) )
        prev_gear = 5;

    // 5th Gear
    if( event_press(CEMU_EXTRA6) )
        loop_gear = loop_gear + 6 - prev_gear;
    else if( event_release(CEMU_EXTRA6) )
        prev_gear = 6;

    // 6th Gear
    if( event_press(CEMU_EXTRA7) )
        loop_gear = loop_gear + 7 - prev_gear;
    else if( event_release(CEMU_EXTRA7) )
        prev_gear = 7;

    // Press the LB or RB button to change the gear based on H-Shifter
    if(!combo_running(gearUP) && !combo_running(gearDOWN))
    {
        if(loop_gear > 0)
        {
            loop_gear = loop_gear - 1;
            combo_run(gearUP);
        }
        else if(loop_gear < 0)
        {
            loop_gear = loop_gear + 1;
            combo_run(gearDOWN);
        }
    }
}
Image
"We always start with completing the difficult. It just takes us a little longer to do the impossible."
Console Tuner Support Team®
User avatar
AKHUGHES90
Major
Major
 
Posts: 927
Joined: Mon Nov 24, 2014 12:19 am
Location: Springfield, IL USA CST (-6:00)

Re: [TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Postby Chevy1995 » Sat Jan 02, 2016 12:44 am

still the same as soon as i open maxaim di it goes on throttle and brake on forza six and horizon 2
User avatar
Chevy1995
Sergeant First Class
Sergeant First Class
 
Posts: 22
Joined: Mon Dec 28, 2015 1:57 am

Re: [TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Postby J2Kbr » Sat Jan 02, 2016 11:40 am

Just confirming, your steering wheel is a G27?
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20322
Joined: Tue Mar 18, 2014 1:39 pm

Re: [TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Postby Chevy1995 » Sat Jan 02, 2016 4:52 pm

Yes it is
User avatar
Chevy1995
Sergeant First Class
Sergeant First Class
 
Posts: 22
Joined: Mon Dec 28, 2015 1:57 am

Re: [TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Postby J2Kbr » Sun Jan 03, 2016 9:27 am

Chevy1995 wrote:Yes it is

thanks, I will reply you on the other topic.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20322
Joined: Tue Mar 18, 2014 1:39 pm

Re: [TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Postby SpiderjumpMC » Sat Apr 23, 2016 8:03 am

How do I change the degrees of rotation with this script?
User avatar
SpiderjumpMC
Private
Private
 
Posts: 1
Joined: Sat Apr 23, 2016 8:01 am

Re: [TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Postby J2Kbr » Sat Apr 23, 2016 12:46 pm

SpiderjumpMC wrote:How do I change the degrees of rotation with this script?

I believe that is something configured with the logithech drivers/app. The layout/script expects the 200° degrees.
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20322
Joined: Tue Mar 18, 2014 1:39 pm

Re: [TUTORIAL] Forza/G27 MaxAim DI Script (with clutch)

Postby Ghostprime1234 » Sun Mar 25, 2018 8:40 am

How do you install the layout to the GPC code?
User avatar
Ghostprime1234
Private First Class
Private First Class
 
Posts: 2
Joined: Thu Feb 08, 2018 6:07 am


Return to Tutorials and FAQs

Who is online

Users browsing this forum: No registered users and 7 guests