Accessibility: Multi-function Stick

Enables the left-stick to be remapped on the fly, with LED effects using: START + LEFT = Left-stick mode START + UP = D-pad mode START + RIGHT = Right-stick mode START + DOWN = Custom mode Full explanation in the code. Huge thanks to Jefferson Koppe and others in the Console Tuner forum for helping with this. The aim is to give more power to a person who cannot manage traditional controls. Search on "SpecialEffect" or "Accessibility" for more useful scripts like this one.
Version1.00
AuthorSpecialEffect
Publish DateFri, 11 Mar 2016 - 22:04
Last UpdateFri, 11 Mar 2016 - 22:04
Downloads70
RATE


1

0

Code: Select all
// CONVERT LEFT-ANALOGUE STICK TO ACT AS LEFT-STICK/D-PAD/RIGHT-STICK/CUSTOM WITH LED INDICATION
// SLOT 01 = NORMAL USE
 
 
//  MULTIPLE-MODES VIA START+ OTHER CONTROLS
 
// (TAP START) = START
 
// (HOLD START + L-STICK LEFT)   = LEFT-STICK MODE
// (HOLD START + L-STICK UP)     = D-PAD MODE
// (HOLD START + L-STICK RIGHT)  = RIGHT-STICK MODE
// (HOLD START + L-STICK DOWN)   = CUSTOM MODE =  [LB/L1 = LS/L3]     [RB/R1 = RS/R3]       [X/SQUARE = PS3 TOUCH-PAD]       [RT/R2 = LATCHED TRIGGER]
 
// (HOLD START + MAIN 8 BUTTONS) = CHANGE TO SLOTS 1-8
// (HOLD START + SELECT)         = CHANGE TO SLOT 9 - ONE-SWITCH MODE
 
 
// Pulled together in March 2016 by Barrie Ellis (SpecialEffect.org.uk / OneSwitch.org.uk)
// Many thanks to Jefferson Koppe and others at the Console Tuner community for help with these scripts.
// Colour help via: http://www.consoletuner.com/gpclib/?s=897.
// 7.3.2016
 
 
// colorled(0,0,0,0); // Off / No LED light
// colorled(1,0,0,0); // Dim Blue
// colorled(0,1,0,0); // Dim Red
// colorled(0,0,1,0); // Dim Lime/Green
// colorled(0,0,0,1); // Dim Fuchsia/Pink
// colorled(1,0,1,0); // Dim SkyBlue
// colorled(0,1,1,0); // Dim Yellow
// colorled(1,1,1,1); // Dim White
// colorled(2,0,0,0); // Blue 
// colorled(0,2,0,0); // Red
// colorled(0,0,2,0); // Lime/Green
// colorled(0,0,0,2); // Fuchsia/Pink
// colorled(2,0,2,0); // SkyBlue
// colorled(0,2,2,0); // Yellow
// colorled(2,2,2,2); // White
// colorled(3,0,0,0); // Bright Blue
// colorled(0,3,0,0); // Bright Red
// colorled(0,0,3,0); // Bright Lime/Green
// colorled(0,0,0,3); // Bright Fuchsia/Pink
// colorled(3,0,3,0); // Bright SkyBlue
// colorled(0,3,3,0); // Bright Yellow
// colorled(3,3,3,3); // Bright white
// ColorLed (1) Dim light
// ColorLed (2) LEFTSTICK/Medium
// ColorLed (3) Bright light
 
 
define LEFTSTICK = 0;
define DPAD = 1;
define RIGHTSTICK = 2;
define CUSTOM = 3;
 
define LSSPEED_VAL = 100; // LEFT-STICK strength
define RSSPEED_VAL = 100; // RIGHT-STICK strength
define RTSPEED_VAL = 100; // RIGHT-TRIGGER strength
int R2ToggleON = FALSE;
 
int profile = LEFTSTICK;
 
main {
    // (held) START + JOYSTICK or BUTTONS triggers different modes.
    // (tapped) START = LEFTSTICK.
 
    if(get_val(XB360_START)) {
        if(get_val(XB360_LX) <= -30) { profile = LEFTSTICK; colorled(1,0,0,0); } // BLUE LED - LEFT-STICK MODE
        else if(get_val(XB360_LY) <= -30) { profile = DPAD; colorled(0,0,0,0); }
        else if(get_val (XB360_LX) >= 30) { profile = RIGHTSTICK; colorled(0,1,0,0); } // RED LED - RIGHT-STICK MODE
        else if(get_val(XB360_LY) >= 30) { profile = CUSTOM; colorled(2,2,2,2); }
 
        else if(event_press(XB360_A)) load_slot(1); // *** START + A TO CHANGE SLOT TO WHAT EVER SLOT NUMBERED HERE
        else if(event_press(XB360_B)) load_slot(2);
        else if(event_press(XB360_RT)) load_slot(3);
        else if(event_press(XB360_LT)) load_slot(4);
        else if(event_press(XB360_X)) load_slot(5);
        else if(event_press(XB360_Y)) load_slot(6);
        else if(event_press(XB360_RB)) load_slot(7);
        else if(event_press(XB360_LB)) load_slot(8);
        else if(event_press(XB360_BACK)) load_slot(9);
 
        set_val(TRACE_1, profile);
        set_val(XB360_START, 0);
        set_val(XB360_A, 0);
        set_val(XB360_B, 0);
        set_val(XB360_X, 0);
        set_val(XB360_Y, 0);
        set_val(XB360_LT, 0);
        set_val(XB360_RT, 0);
        set_val(XB360_LB, 0);
        set_val(XB360_RB, 0);
        set_val(XB360_BACK, 0);
 
        set_val(XB360_LX, 0);
        set_val(XB360_LY, 0);
        set_val(XB360_RX, 0);
        set_val(XB360_RY, 0);
 
    } else if(event_release(XB360_START) && get_ptime(XB360_START) < 300) {
        combo_run(StartTap);
    }
 
        if(profile == LEFTSTICK) {
        if(get_val(XB360_RT) >= RTSPEED_VAL) {set_val(XB360_RT, RTSPEED_VAL);}
 
        if(get_val(XB360_LX) >= LSSPEED_VAL) {set_val(XB360_LX, LSSPEED_VAL);}
        if(get_val(XB360_LX) <= -LSSPEED_VAL) {set_val(XB360_LX, -LSSPEED_VAL);}
        if(get_val(XB360_LY) >= LSSPEED_VAL) {set_val(XB360_LY, LSSPEED_VAL);}
        if(get_val(XB360_LY) <= -LSSPEED_VAL) {set_val(XB360_LY, -LSSPEED_VAL);}
        }
 
 
        else if(profile == DPAD) {
        if(abs(get_val(XB360_LY)) >= 20 || abs(get_val(XB360_LX)) >= 20) {
            if(get_val(XB360_LY) <= -30) set_val(XB360_UP, 100);
            else if(get_val(PS3_LY) >= 30) set_val(XB360_DOWN, 100);
            if(get_val(XB360_LX) <= -30) set_val(XB360_LEFT, 100);
            else if(get_val(PS3_LX) >= 30) set_val(XB360_RIGHT, 100);
        }
        if(get_val(XB360_RT) >= RTSPEED_VAL) {set_val(XB360_RT, RTSPEED_VAL);}
 
        set_val(XB360_LX, 0);
        set_val(XB360_LY, 0);
        }
 
 
        else if(profile == RIGHTSTICK) {
        swap(XB360_LX, XB360_RX);
        swap(XB360_LY, XB360_RY);
        if(get_val(XB360_RT) >= RSSPEED_VAL) {set_val(XB360_RT, RSSPEED_VAL);}
 
        if(get_val(XB360_RX) >= RSSPEED_VAL) {set_val(XB360_RX, RSSPEED_VAL);}
        if(get_val(XB360_RX) <= -RSSPEED_VAL) {set_val(XB360_RX, -RSSPEED_VAL);}
        if(get_val(XB360_RY) >= RSSPEED_VAL) {set_val(XB360_RY, RSSPEED_VAL);}
        if(get_val(XB360_RY) <= -RSSPEED_VAL) {set_val(XB360_RY, -RSSPEED_VAL);}
        }
 
 
        else if(profile == CUSTOM) {
        swap(XB360_LB, XB360_LS);
        swap(XB360_RB, XB360_RS);
        swap(XB360_X, PS4_TOUCH);
 
        if(get_val(XB360_LX) >= LSSPEED_VAL) {set_val(XB360_LX, LSSPEED_VAL);}
        if(get_val(XB360_LX) <= -LSSPEED_VAL) {set_val(XB360_LX, -LSSPEED_VAL);}
        if(get_val(XB360_LY) >= LSSPEED_VAL) {set_val(XB360_LY, LSSPEED_VAL);}
        if(get_val(XB360_LY) <= -LSSPEED_VAL) {set_val(XB360_LY, -LSSPEED_VAL);}
 
        // LATCH RIGHT-TRIGGER RT=75%
        if (event_press(PS3_R2)) {R2ToggleON = !R2ToggleON;} // Toggles R2 on/off
        if (R2ToggleON) {set_val(PS3_R2,RTSPEED_VAL);} // -value is ACTIVE; +value is INACTIVE
 
}
}
 
combo StartTap {
    set_val(XB360_START, 100);
    wait(80);
}
 
// COLOR LED INDICATION for PS4 *NO NEED TO EDIT BELOW*
//--------------------------------------------------------------
function colorled(a,b,c,d) {
set_led(LED_1,a);
set_led(LED_2,b);
set_led(LED_3,c);
set_led(LED_4,d);
}