CronusMax/Titane One wiimote bravo call of duty modern warfare

Use wiimote in bravo settings PS4 (adjust key mapping in script for other platforms) for: <b>Call of Duty Modern Warfare</b> wii + button: throw lethal grenade wii + button while twisting the wiimote 90o counter clock wise: throw tactical wii dpad left: use killstreak double click wii + button: use specialist weapon Happy wiimoting! keywords: wiimote, wii remote, bravo, PS4, call of duty, modern warfare</keywords>
Version1.00
AuthorOFC-Giorgio
Publish DateSun, 10 Nov 2019 - 12:54
Last UpdateSun, 10 Nov 2019 - 12:54
Downloads65
RATE


0

0

Release Notes: Version for CronusMax and Titan One
Code: Select all
// GPC Online Library
// ps4_consoletuner_titane_one_wiimote_bravo_call_of_duty_modern_warfare.gpc
 
//#pragma METAINFO("device and Titan One wiimote bravo PS4 call of duty modern warfare", 1, 0, "ofc-giorgio")
 
/***
 
Use wiimote in bravo settings PS4 (adjust key mapping in script for other platforms) for:
 
Call of Duty Modern Warfare
 
wii + button: throw lethal grenade
 
wii + button while twisting the wiimote 90o counter clock wise: throw tactical
 
wii dpad left: use killstreak       
 
double click wii + button: use specialist weapon
 
Happy wiimoting!
 
 
keywords: wiimote, wii remote, bravo, PS4, call of duty, modern warfare
 
url: https://www.consoletuner.com/forum/viewtopic.php?f=14&t=13929
***/

 
/*
   From the wiiu manual:
   * Z Button - ADS
   * C Button - Crouch/Prone
   * Control Stick - Move
   * Up on the +Control Pad - Jump
   * Right on the +Control Pad - Switch Weapon
   * Left on the +Control Pad - Inventory
   * Down on the +Control Pad - Melee Attack
   * A Button - Use/Sprint/Lock Camera
   * - Button - Throw Tacticals
   * + Button - Throw Lethals
   * 1 Button - Objectives/Menu
   * 2 Button - Scoreboard
   * B Button (underneath controller) - Fire Weapon
   * Shake Nunchuk - Reload
 
   Hold Wii-Left and select with Nunchuk left to use killstreak
 
   Bravo settings:
   * shake nunchuk / reload is disabled,
   * - is used for reload and
   * + is still used to throw lethals but + while twisting the wiimote is used
     for throwing tacticals
*/

 
// Sensitivity while aiming - Default: 100 - Range [0 ~ 327]
// set a number below 100 for less sens - above 100 for more sens
 
// MIDPOINT - Default: 50 - Range [0 ~ 100]
//    If you set a number below 50 you are defining a zone of high sensitivity range when close to rest position
//    (fast movements) and a low sensitivity range when far from rest position (better accuracy).
//    if you set a number above 50 you are defining a zone of low sensitivity when close to the rest position
//    (better accuracy), and a zone of high sensitivity when far from rest position (fast movements).**/
 
// while aiming down the sight:
define ADS_MIDPOINT        =  20;
define ADS_SENSITIVITY     = 100;
 
// while NOT aiming down the sight:
define NON_ADS_MIDPOINT    =  20;
define NON_ADS_SENSITIVITY = 100;
 
// Output controller stick and buttons (for indirect programaticaly computed setting via dummy mapping)
define CONSOLE_LEFT_STICK_LEFT_RIGHT        = PS4_LX;       // cod walk
define CONSOLE_LEFT_STICK_UP_DOWN           = PS4_LY;       // cod walk
define CONSOLE_RIGHT_STICK_LEFT_RIGHT       = PS4_RX;       // cod look
define CONSOLE_RIGHT_STICK_UP_DOWN          = PS4_RY;       // cod look
define CONSOLE_DPAD_LEFT                    = PS4_LEFT;     // cod killstreak etc
define CONSOLE_DPAD_RIGHT                   = PS4_RIGHT;    // cod killstreak etc
define CONSOLE_DPAD_UP                      = PS4_UP;       // cod killstreak etc
define CONSOLE_DPAD_DOWN                    = PS4_DOWN;     // cod killstreak etc
define CONSOLE_BUTTON_L1LB                  = PS4_L1;       // tactical grenade
define CONSOLE_BUTTON_R1RB                  = PS4_R1;       // lethal grenade
define CONSOLE_BUTTON_L2LT                  = PS4_L2;       // zoom ads
define CONSOLE_BUTTON_R2RT                  = PS4_R2;       // fire
define CONSOLE_BUTTON_L3LS                  = PS4_L3;       // sprint
define CONSOLE_BUTTON_R3RS                  = PS4_R3;       // melee
define CONSOLE_BUTTON_PSXBOX                = PS4_PS;       // home
define CONSOLE_BUTTON_OPTIONSSTARTMENUSTART = PS4_OPTIONS// menu
define CONSOLE_BUTTON_TOUCHSELECTVIEWBACK   = PS4_TOUCH;    // menu
define CONSOLE_BUTTON_SQUAREX               = PS4_SQUARE;   // reload
define CONSOLE_BUTTON_CIRCLEB               = PS4_CIRCLE;   // crouch
define CONSOLE_BUTTON_TRIANGLEY             = PS4_TRIANGLE; // switch weapon
define CONSOLE_BUTTON_CROSSA                = PS4_CROSS;    // jump
 
define CONSOLE_BUTTON_TOUCHX   = PS4_TOUCHX;    // menu
define CONSOLE_BUTTON_TOUCHY   = PS4_TOUCHY;    // menu
 
define INPUT_WII_NC_STICK_LEFT_RIGHT    = WII_NX;
define INPUT_WII_NC_STICK_UP_DOWN       = WII_NY;
define INPUT_WII_DPAD_LEFT              = WII_LEFT;
define INPUT_WII_DPAD_RIGHT             = WII_RIGHT;
define INPUT_WII_DPAD_UP                = WII_UP;
define INPUT_WII_DPAD_DOWN              = WII_DOWN;
define INPUT_WII_NC_GYRO_X              = WII_ACCNX;
define INPUT_WII_GYRO_X                 = WII_ACCX;
define INPUT_WII_BUTTON_PLUS            = WII_PLUS;
define INPUT_WII_BUTTON_MINUS           = WII_MINUS;
define INPUT_WII_BUTTON_HOME            = WII_HOME;
define INPUT_WII_BUTTON_ONE             = WII_ONE;
define INPUT_WII_BUTTON_TWO             = WII_TWO;
define INPUT_WII_BUTTON_A               = WII_A;
define INPUT_WII_BUTTON_B               = WII_B;
define INPUT_WII_BUTTON_C               = WII_C;
define INPUT_WII_BUTTON_Z               = WII_Z;
define INPUT_WII_SENSOR_IRX             = WII_IRX;
define INPUT_WII_SENSOR_IRY             = WII_IRY;
 
 
int    VALUE_WII_NC_STICK_LEFT_RIGHT    = 0;
int    VALUE_WII_NC_STICK_UP_DOWN       = 0;
int    VALUE_WII_DPAD_LEFT              = 0;
int    VALUE_WII_GYRO_X                 = 0;
int    VALUE_WII_BUTTON_PLUS            = 0;
int    VALUE_WII_BUTTON_Z               = 0;
int    VALUE_WII_SENSOR_IRX             = 0;
 
 
// standard mappings
unmap ALL_REMAPS;
 
remap  INPUT_WII_BUTTON_HOME     -> CONSOLE_BUTTON_PSXBOX;                // home
remap  INPUT_WII_BUTTON_MINUS    -> CONSOLE_BUTTON_SQUAREX;               // reload hold: use/interact
remap  INPUT_WII_BUTTON_PLUS     -> CONSOLE_BUTTON_R1RB;                  // lethal grenade
remap  INPUT_WII_BUTTON_ONE      -> CONSOLE_BUTTON_OPTIONSSTARTMENUSTART; // menu/map
remap  INPUT_WII_BUTTON_TWO      -> CONSOLE_BUTTON_TOUCHSELECTVIEWBACK;   // scoreboard
remap  INPUT_WII_BUTTON_A        -> CONSOLE_BUTTON_L3LS;                  // sprint
remap  INPUT_WII_BUTTON_B        -> CONSOLE_BUTTON_R2RT;                  // fire
remap  INPUT_WII_DPAD_UP         -> CONSOLE_BUTTON_CROSSA;                // jump/mantle
remap  INPUT_WII_BUTTON_C        -> CONSOLE_BUTTON_CIRCLEB;               // crouch/prone
remap  INPUT_WII_BUTTON_Z        -> CONSOLE_BUTTON_L2LT;                  // zoom/aiming down the sights (ADS)
remap  INPUT_WII_DPAD_RIGHT      -> CONSOLE_BUTTON_TRIANGLEY;             // switch weapon
remap  INPUT_WII_DPAD_DOWN       -> CONSOLE_BUTTON_R3RS;                  // melee
remap  INPUT_WII_SENSOR_IRX      -> CONSOLE_RIGHT_STICK_LEFT_RIGHT;       // look
remap  INPUT_WII_SENSOR_IRY      -> CONSOLE_RIGHT_STICK_UP_DOWN;          // look
 
 
// Dummy mapping  3 4 9 10 17 20 24 not used in api (gyros 21 22 23 25 26 27; 21 is used for detecting twisting wiimote)
 
define OUTPUT_CONSOLE_LEFT_STICK_LEFT_RIGHT =  3
remap  OUTPUT_CONSOLE_LEFT_STICK_LEFT_RIGHT -> CONSOLE_LEFT_STICK_LEFT_RIGHT;
define OUTPUT_CONSOLE_LEFT_STICK_UP_DOWN    =  4;
remap  OUTPUT_CONSOLE_LEFT_STICK_UP_DOWN    -> CONSOLE_LEFT_STICK_UP_DOWN;
define OUTPUT_CONSOLE_DPAD_LEFT             =  9;
remap  OUTPUT_CONSOLE_DPAD_LEFT             -> CONSOLE_DPAD_LEFT;
define OUTPUT_CONSOLE_DPAD_RIGHT            =  10;
remap  OUTPUT_CONSOLE_DPAD_RIGHT            -> CONSOLE_DPAD_RIGHT;
define OUTPUT_CONSOLE_DPAD_UP               =  17;
remap  OUTPUT_CONSOLE_DPAD_UP               -> CONSOLE_DPAD_UP;
define OUTPUT_CONSOLE_DPAD_DOWN             =  20;
remap  OUTPUT_CONSOLE_DPAD_DOWN             -> CONSOLE_DPAD_DOWN;
define OUTPUT_CONSOLE_BUTTON_L1LB           =  24;
remap  OUTPUT_CONSOLE_BUTTON_L1LB           -> CONSOLE_BUTTON_L1LB;
 
//int ps4auth;
int isDPADing = 0;
int TimerSpecialistWeapon = 0;
 
int ps4auth;
 
int LAST_IRX = 0;
int LAST_IRY = 0;
int ircount = 1;
 
init
{
  ps4auth = ps4_authtimeout();
  my_init();
}
 
main
{
  if(ps4_authtimeout() > ps4auth)
  {
    my_init();
  }
  ps4auth = ps4_authtimeout();
 
  // Retrieve values from input controller (wiimote + nc)
  VALUE_WII_DPAD_LEFT           = get_val(INPUT_WII_DPAD_LEFT);
  VALUE_WII_NC_STICK_LEFT_RIGHT = get_val(INPUT_WII_NC_STICK_LEFT_RIGHT);
  VALUE_WII_NC_STICK_UP_DOWN    = get_val(INPUT_WII_NC_STICK_UP_DOWN);
  VALUE_WII_GYRO_X              = get_val(INPUT_WII_GYRO_X);
  VALUE_WII_BUTTON_PLUS         = get_val(INPUT_WII_BUTTON_PLUS);
  VALUE_WII_BUTTON_Z            = get_val(INPUT_WII_BUTTON_Z);
  VALUE_WII_SENSOR_IRX          = get_val(INPUT_WII_SENSOR_IRX);
 
  set_val(INPUT_WII_SENSOR_IRX, inv(VALUE_WII_SENSOR_IRX));
 
  // use different sensitivity for ADS (aiming down the sights) and non ADS
  if (VALUE_WII_BUTTON_Z == 100)
  {
    sensitivity(INPUT_WII_SENSOR_IRX, ADS_MIDPOINT, ADS_SENSITIVITY);
    sensitivity(INPUT_WII_SENSOR_IRY, ADS_MIDPOINT, ADS_SENSITIVITY);
  }
  else
  {
    sensitivity(INPUT_WII_SENSOR_IRX, NON_ADS_MIDPOINT, NON_ADS_SENSITIVITY);
    sensitivity(INPUT_WII_SENSOR_IRY, NON_ADS_MIDPOINT, NON_ADS_SENSITIVITY);
  }
 
  // test for wiimote out of reach of sensorbar
  if(wiir_offscreen())
  {
    set_val(INPUT_WII_SENSOR_IRX, 0); // prevent camera from spinning
    set_val(INPUT_WII_SENSOR_IRY, 0); // prevent camera from spinning
 
    ircount = ircount + 1;
    if (ircount > 3)
    {
      ircount = 0;
      if (LAST_IRX > 0) { LAST_IRX = LAST_IRX - 1; }
      if (LAST_IRX < 0) { LAST_IRX = LAST_IRX + 1; }
 
      if (LAST_IRY > 0) { LAST_IRY = LAST_IRY - 1; }
      if (LAST_IRY < 0) { LAST_IRY = LAST_IRY + 1; }
    }
 
    set_val(INPUT_WII_SENSOR_IRX, LAST_IRX); // fade out
    set_val(INPUT_WII_SENSOR_IRY, LAST_IRY); // fade out
 
    set_led(LED_4, 1);   // light led 4 to indicate sensorbar is out of sight
  }
  else
  {
    set_led(LED_4, 0);
    LAST_IRX = get_val(INPUT_WII_SENSOR_IRX);
    LAST_IRY = get_val(INPUT_WII_SENSOR_IRY);
  }
 
  // wii dpad left: use killstreak       
  isDPADing = 0;
  if(VALUE_WII_DPAD_LEFT == 100)
  {
    isDPADing = 1;
      // mw: killstreak
    set_val(OUTPUT_CONSOLE_DPAD_RIGHT, 100); // right
 
    // Moving with right stick or dpad buttons
    // WII_LEFT acts like a SHIFT key, when pressed the Nunchuck stick is not used for moving but for
    // selecting dpad up, down, left or right.
 
    // selecting dpad left, right, up, down.
    // threshold is higher (vs 30) in order to have only one dpad button selected at a time
    if(VALUE_WII_NC_STICK_LEFT_RIGHT < -30)
    {
      set_val(OUTPUT_CONSOLE_DPAD_LEFT,  100)// left
      set_val(OUTPUT_CONSOLE_DPAD_RIGHT, 0);
    }
    else
    // already handled by wii dpad left: use killstreak       
    //if(VALUE_WII_NC_STICK_LEFT_RIGHT >  30)
    //{       
    //  set_val(OUTPUT_CONSOLE_DPAD_RIGHT, 100); // right (in modern warfare, was left in bo)
    //}
    //else
    if(VALUE_WII_NC_STICK_UP_DOWN    >  30)
    {
      // mw: gesture/spray decal
      set_val(OUTPUT_CONSOLE_DPAD_DOWN,  100);
      set_val(OUTPUT_CONSOLE_DPAD_RIGHT, 0);
    } // down (sign is flipped compared to math class)
    else
    if(VALUE_WII_NC_STICK_UP_DOWN    < -30)
    {
      // mw: not used
      set_val(OUTPUT_CONSOLE_DPAD_UP,    100);
      set_val(OUTPUT_CONSOLE_DPAD_RIGHT, 0);
    } // up (sign is flipped compared to math class)
  }
 
 
  if(isDPADing == 0)
  {
    // moving left/right
    if (VALUE_WII_NC_STICK_LEFT_RIGHT < -30) { set_val(OUTPUT_CONSOLE_LEFT_STICK_LEFT_RIGHT, -100); } // left
    else
    if (VALUE_WII_NC_STICK_LEFT_RIGHT > 30)  { set_val(OUTPUT_CONSOLE_LEFT_STICK_LEFT_RIGHT,  100); } // right
    else
    { set_val(OUTPUT_CONSOLE_LEFT_STICK_LEFT_RIGHT, VALUE_WII_NC_STICK_LEFT_RIGHT); }
 
    // moving up/down
    if (VALUE_WII_NC_STICK_UP_DOWN    < -30) { set_val(OUTPUT_CONSOLE_LEFT_STICK_UP_DOWN,    -100); } // up (sign is flipped compared to math class)
    else
    if (VALUE_WII_NC_STICK_UP_DOWN    > 30)  { set_val(OUTPUT_CONSOLE_LEFT_STICK_UP_DOWN,     100); } // down (sign is flipped compared to math class)
    else
    { set_val(OUTPUT_CONSOLE_LEFT_STICK_UP_DOWN, VALUE_WII_NC_STICK_UP_DOWN); }
  }
 
  // Bravo settings  twisting the wiimote 90o, hold it and press the + button
  // is used for throwing tacticals (instead of lethal grenade)
  if((VALUE_WII_BUTTON_PLUS > 0) && (VALUE_WII_GYRO_X > 20))
  {
    set_val(INPUT_WII_BUTTON_PLUS,        0); // stop/prevent throwing lethal
    set_val(OUTPUT_CONSOLE_BUTTON_L1LB, 100); // throw tactical grenade
  }   
  //else
  //{
  //  set_val(OUTPUT_CONSOLE_BUTTON_L1LB, 0);
  //}
  else
  {
 
    // Bravo settings (COD Modern Warfare: throwing both lethal and tactical to activate Specialist weapon or skill) 
    // this can not be done in bravo settings so to in bravo settings
    // activate Specialist weapon or skill by double tapping the lethal grenade button
    // TimerSpecialistWeapon - Countdown function
    if (TimerSpecialistWeapon > 0)
    {
      TimerSpecialistWeapon = TimerSpecialistWeapon - get_rtime(); // Reduce the timer value by the elapsed run time
    }
 
    // Timer - Detection of the release
    if (event_release(INPUT_WII_BUTTON_PLUS))
    {
      TimerSpecialistWeapon = 300;   // 300 ms timer (starting the timer)
    }
 
    // Timer - Detection of the press
    if ((event_press(INPUT_WII_BUTTON_PLUS)) && (TimerSpecialistWeapon > 0))
    {
       TimerSpecialistWeapon = 0;
       combo_run(ComboSpecialistWeapon);
    }   
  }
 
 
  // Empty battery indicator (turn all leds on if battery level less or equal 20%)
  if(get_battery() <= 2)
  {
    set_led(LED_1, 1);
    set_led(LED_2, 1);
    set_led(LED_3, 1);
    set_led(LED_4, 1);
  }
 
} // end of main() function
 
combo ComboSpecialistWeapon
{
   set_val(INPUT_WII_BUTTON_PLUS, 100);
   set_val(OUTPUT_CONSOLE_BUTTON_L1LB, 100);
   wait(500);
   set_val(INPUT_WII_BUTTON_PLUS, 0);
   set_val(OUTPUT_CONSOLE_BUTTON_L1LB, 0);   
}
 
function my_init()
{
  block_rumble();
}