PS4/PS5 Touch-pad Gestures - from buttons

GPC2 script programming for Titan Two. Code examples, questions, requests.

PS4/PS5 Touch-pad Gestures - from buttons

Postby SpecialEffect » Tue Sep 21, 2021 3:10 pm

I'm looking for help to do the following, please, for a person unable to physically swipe a PS4/PS5 touchpad:

TAP COUNTER:

1. Count the number of times "Touch P1" is tapped by the user within an adjustable time limit.
2. If "Touch P1" is tapped once then ignore.
3. If "Touch P1" is tapped a second time but after the expiry of an adjustable timer, then treat as the first tap.

TOUCHPAD SWIPE SIMULATION (ideally with a way to adjust the speed of swipe):

3. If "Touch P1" is tapped twice within time, swipe left (from P1X=100,P1Y=0 smoothly to end at P1X=-100,P1Y=0)
4. If "Touch P1" is tapped three times within time, swipe right (from P1X=-100,P1Y=0 smoothly to P1X=100,P1Y=0)
5. If "Touch P1" is tapped four times within time, swipe up (from P1X=0,P1Y=100 smoothly to P1X=0,P1Y=-100)
6. If "Touch P1" is tapped five times, within time, swipe down (from P1X=0,P1Y=-100 smoothly to P1X=0,P1Y=100).

Jefferson has knocked this up previously (to convert a stick to touch-pad input), but it's not going to do the trick in this case (thought I'd share the simplified code anyway):

Code: Select all
#pragma METAINFO("PS4 LEFT-STICK = TOUCH", 1, 0, "ConsoleTuner.com")
 
#include <xb1.gph>
#include <ps4.gph>
 
main {
 
    // Hold Left-Stick "LS/L3" to use Right-Stick Axis (RX & RY) for Swipe Touchpad.
        if(is_active(XB1_LY) || is_active(XB1_LX)) {
            set_val(PS4_TOUCH1, 100.0);
            set_val(PS4_TOUCH1X, get_val(XB1_LX));
            set_val(PS4_TOUCH1Y, get_val(XB1_LY));
        }
        set_val(XB1_LX, 0.0);
        set_val(XB1_LY, 0.0);
}
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: PS4/PS5 Touch-pad Gestures - from buttons

Postby SpecialEffect » Wed Sep 22, 2021 10:54 am

Many thanks to Jefferson. The code below is a huge stepping stone to what I'm looking for:

Code: Select all
#pragma  METAINFO("Glide Pad Simulation", 0, 01, "Jefferson Koppe / SpecialEffect")     // SLOT description
#include <ps4.gph>
 
 
uint8 axis;
 
fix32 start, end, value;
 
 
main {
 
    // BLANK D-PAD OUTPUT
    set_val(PS4_UP, 0);set_val(PS4_DOWN, 0);set_val(PS4_LEFT, 0);set_val(PS4_RIGHT, 0)
 
 
    // DETECT D-PAD AND SET ACCORDING SWIPE VALUES FOR UP, DOWN, LEFT or RIGHT
    if(event_active(PS4_UP)) {axis = PS4_TOUCH1Y;start = 100.0; end = -100.0; value = start;} else
    if(event_active(PS4_DOWN)) {axis = PS4_TOUCH1Y;start = -100.0; end = 100.0; value = start;} else
    if(event_active(PS4_LEFT)) {axis = PS4_TOUCH1X;start = 100.0; end = -100.0; value = start;} else
    if(event_active(PS4_RIGHT)) {axis = PS4_TOUCH1X;start = -100.0; end = 100.0; value = start;}
 
    // SWIPE!
    if(value != end) {
        set_val(PS4_TOUCH1, 100.0);
        set_val(axis, value);       
        value += (start >= end) ? -1.0 : 1.0;
        }
}



Next, is a method of tapping the touch-pad (not clicking but just a light touch) twice to turn the above mode ON/OFF, ideally with some sort of LED indication that a mode is on/off.
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: PS4/PS5 Touch-pad Gestures - from buttons

Postby SpecialEffect » Wed Sep 22, 2021 1:05 pm

Finished code below, with huge thanks to Jefferson.

Tap Touch lightly twice to turn on D-PAD SWIPE emulation. LED should turn white, and pressing the-pad should simulate swiping up, right, down or left. Tap Touch x2 again, to turn the mode off.



Code: Select all
 
// TAP TOUCH x2 = TOGGLE D-PAD SWIPE EMULATION MODE ON/OFF (WHITE LED = ON)
// Written by Jefferson Koppe (www.consoletuner.com) and modified by Barrie Ellis (www.specialeffect.org.uk)
// 22-9-2021
// viewtopic.php?f=26&t=18789
 
#pragma  METAINFO("D-PAD SWIPE EMULATION (TAP TOUCH x2)", 0, 01, "Jefferson Koppe / SpecialEffect")
#include <ps4.gph>
 
uint8 axis;
fix32 start, end, value;
bool toggle;
 
 
main {
 
    // IF "PS4_TOUCH1" is tapped twice within 500msecs - TOGGLE TOUCH-SWIPE MODE ON/OFF and change LEDs
    if(event_active(PS4_TOUCH1) && time_release(PS4_TOUCH1) <= 500) {start = end = value = 0.0;toggle = !toggle;
        if(toggle) {led_set(LED_1, 100.0, 0);led_set(LED_2, 100.0, 0);led_set(LED_3, 100.0, 0);} else {led_reset();}}
 
    if(toggle) {
 
    // BLANK D-PAD OUTPUT
    set_val(PS4_UP, 0);set_val(PS4_DOWN, 0);set_val(PS4_LEFT, 0);set_val(PS4_RIGHT, 0)
 
 
    // DETECT D-PAD AND SET ACCORDING SWIPE VALUES FOR UP, DOWN, LEFT or RIGHT
    if(event_active(PS4_UP)) {axis = PS4_TOUCH1Y;start = 100.0; end = -100.0; value = start;} else
    if(event_active(PS4_DOWN)) {axis = PS4_TOUCH1Y;start = -100.0; end = 100.0; value = start;} else
    if(event_active(PS4_LEFT)) {axis = PS4_TOUCH1X;start = 100.0; end = -100.0; value = start;} else
    if(event_active(PS4_RIGHT)) {axis = PS4_TOUCH1X;start = -100.0; end = 100.0; value = start;}
 
    // SWIPE!
    if(value != end) {
        set_val(PS4_TOUCH1, 100.0);
        set_val(axis, value);       
        value += (start >= end) ? -1.0 : 1.0;
        }
 
    }
 
 
}
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: PS4/PS5 Touch-pad Gestures - from buttons

Postby SpecialEffect » Wed Sep 22, 2021 1:29 pm

This version swipes from dead-centre, and might be the better version:

Code: Select all
 
// TAP TOUCH x2 = TOGGLE D-PAD SWIPE EMULATION MODE ON/OFF  (WHITE LED = ON)
// Written by Jefferson Koppe (www.consoletuner.com) and modified by Barrie Ellis (www.specialeffect.org.uk)
// Thanks to Vivek Gohil for the request
// 22-9-2021
// viewtopic.php?f=26&t=18789
 
#pragma  METAINFO("D-PAD SWIPE EMULATION (TAP TOUCH x2)", 0, 02, "Jefferson Koppe / SpecialEffect")
#include <ps4.gph>
 
uint8 axis;
fix32 start, end, value;
bool toggle;
 
 
main {
 
    // IF "PS4_TOUCH1" is tapped twice within 500msecs - TOGGLE TOUCH-SWIPE MODE ON/OFF and change LEDs
    if(event_active(PS4_TOUCH1) && time_release(PS4_TOUCH1) <= 500) {start = end = value = 0.0;toggle = !toggle;
        if(toggle) {led_set(LED_1, 100.0, 0);led_set(LED_2, 100.0, 0);led_set(LED_3, 100.0, 0);} else {led_reset();}}
 
    if(toggle) {
 
    // BLANK D-PAD OUTPUT
    set_val(PS4_UP, 0);set_val(PS4_DOWN, 0);set_val(PS4_LEFT, 0);set_val(PS4_RIGHT, 0);
    set_val(PS4_TOUCH1X,0.0);set_val(PS4_TOUCH1Y,0.0);   
 
 
    // DETECT D-PAD AND SET ACCORDING SWIPE VALUES FOR UP, DOWN, LEFT or RIGHT
    if(event_active(PS4_UP)) {axis = PS4_TOUCH1Y;start = 100.0; end = -100.0; value = start;} else
    if(event_active(PS4_DOWN)) {axis = PS4_TOUCH1Y;start = -100.0; end = 100.0; value = start;} else
    if(event_active(PS4_LEFT)) {axis = PS4_TOUCH1X;start = 100.0; end = -100.0; value = start;} else
    if(event_active(PS4_RIGHT)) {axis = PS4_TOUCH1X;start = -100.0; end = 100.0; value = start;}
 
    // SWIPE!
    if(value != end) {
        set_val(PS4_TOUCH1, 100.0);
        set_val(axis, value);       
        value += (start >= end) ? -1.0 : 1.0;
        }
 
    }
 
 
}
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: PS4/PS5 Touch-pad Gestures - from buttons

Postby antithesis » Thu Sep 23, 2021 12:27 am

Thanks for posting SpecialEffect. There are many disabled users who game via Titan Two. This kind of touchpad script is greatly appreciated!
Official Australian retailer for Titan One, Titan Two and XIM APEX at Mod Squad
User avatar
antithesis
Colonel
Colonel
 
Posts: 1912
Joined: Sat May 28, 2016 10:45 pm

Re: PS4/PS5 Touch-pad Gestures - from buttons

Postby SpecialEffect » Thu Sep 23, 2021 8:12 am

You're welcome. I'll upload a batch more accessibility related scripts soon.
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: PS4/PS5 Touch-pad Gestures - from buttons

Postby teddy18 » Sun Sep 26, 2021 8:03 am

Thank you
User avatar
teddy18
Lieutenant
Lieutenant
 
Posts: 346
Joined: Sun Jul 19, 2015 4:18 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 130 guests