PS4/PS5 Touch-pad Gestures - from buttons
7 posts
• Page 1 of 1
PS4/PS5 Touch-pad Gestures - from buttons
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):
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);
}
-
SpecialEffect - Sergeant Major of the Army
- Posts: 203
- Joined: Mon Apr 07, 2014 3:26 pm
Re: PS4/PS5 Touch-pad Gestures - from buttons
Many thanks to Jefferson. The code below is a huge stepping stone to what I'm looking for:
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.
- 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.
-
SpecialEffect - Sergeant Major of the Army
- Posts: 203
- Joined: Mon Apr 07, 2014 3:26 pm
Re: PS4/PS5 Touch-pad Gestures - from buttons
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.
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;
}
}
}
-
SpecialEffect - Sergeant Major of the Army
- Posts: 203
- Joined: Mon Apr 07, 2014 3:26 pm
Re: PS4/PS5 Touch-pad Gestures - from buttons
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;
}
}
}
-
SpecialEffect - Sergeant Major of the Army
- Posts: 203
- Joined: Mon Apr 07, 2014 3:26 pm
Re: PS4/PS5 Touch-pad Gestures - from buttons
Thanks for posting SpecialEffect. There are many disabled users who game via Titan Two. This kind of touchpad script is greatly appreciated!
-
antithesis - Colonel
- Posts: 1912
- Joined: Sat May 28, 2016 10:45 pm
Re: PS4/PS5 Touch-pad Gestures - from buttons
You're welcome. I'll upload a batch more accessibility related scripts soon.
-
SpecialEffect - Sergeant Major of the Army
- Posts: 203
- Joined: Mon Apr 07, 2014 3:26 pm
7 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 130 guests