Accessibility: Touch Pad as 4 buttons (tap to pulse them)

Convert a PS4 touch-pad into four (or more) buttons / other controls. Useful for those unable to reach the OPTIONS, TOUCH CLICK, SHARE and Home buttons.
Version1.00
AuthorSpecialEffect
Publish DateThu, 21 Feb 2019 - 14:57
Last UpdateThu, 21 Feb 2019 - 14:57
Downloads15
RATE


0

0

Code: Select all
// Script2 for Vivek - 21.2.2019
// Convert 4 parts of a PS4 Track-pad to act as four menu type functions. Pulsed.
// Based on code supplied by Vivek. Touch-pad code tweaked by Barrie Ellis - www.specialeffect.org.uk
 
 
//remap examples
 
//remap XB1_LB -> XB1_LT;
//remap XB1_RB -> XB1_RT;
//remap XB1_RT -> XB1_RB;
//remap XB1_LT -> XB1_LB;
 
define TOUCH_DEADZONE_X = 20;   // adjust from 0 to 70 to adjust central deadzone
define TOUCH_DEADZONE_Y = 60;   // adjust from 0 to 70 to adjust central deadzone
int LAST_POS_X = 0;          //
int LAST_POS_Y = 0;          //
int CURRENT_POS_X = 0;           //
int CURRENT_POS_Y = 0;           //
 
 
main {
 
//set_val(PS4_TOUCHX, 0);  set_val(PS4_TOUCHY, 0); set_val(PS4_TOUCH,0);  // CLEAR TOUCH OUTPUT
 
 
 
CURRENT_POS_X = get_val(PS4_TOUCHX);
CURRENT_POS_Y = get_val(PS4_TOUCHY);
 
if (LAST_POS_X != CURRENT_POS_X) {                            // DON'T PROCESS TOUCH UNTIL TOUCH-PAD FIRST USED
    LAST_POS_X = get_val(PS4_TOUCHX);
    LAST_POS_Y = get_val(PS4_TOUCHY);
 
        if (CURRENT_POS_X < -TOUCH_DEADZONE_X) {combo_run(TAP_TP_LEFT);}
        if (CURRENT_POS_X > TOUCH_DEADZONE_X) {combo_run(TAP_TP_RIGHT);}
        if (CURRENT_POS_Y < -TOUCH_DEADZONE_Y) {combo_run(TAP_TP_UP);}
        if (CURRENT_POS_Y > TOUCH_DEADZONE_Y) {combo_run(TAP_TP_DOWN);}
    }
 
 
 
if (get_console() != PIO_XB1 && get_controller() == PIO_PS4) { // IF XB1 CONSOLE + PS4 CONTROLLER block six-axis to P1-P4 remapping   
       set_val(XB1_P1, 0);
       set_val(XB1_P2, 0);
       set_val(XB1_P3, 0);
       set_val(XB1_P4, 0);
       }
 
}
 
 
 
combo TAP_TP_LEFT {
    set_val(PS4_SHARE, 100); wait(180);
}
 
combo TAP_TP_RIGHT {
    set_val(PS4_OPTIONS, 100); wait(180);
}
 
combo TAP_TP_UP {
    set_val(PS4_TOUCH, 100); wait(180);
}
 
combo TAP_TP_DOWN {
    set_val(PS4_PS, 100); wait(180);
}