Detecting quadrant/corner of TouchPad being pressed?
6 posts
• Page 1 of 1
Detecting quadrant/corner of TouchPad being pressed?
Hi
Is there a way to determine when separate corners/quadrants of the PS5 touchpad are pressed?
I would find this extremely helpful in my current script.
Even just to be able to determine whether the left or right side of the touchpad was pressed would be extremely helpful.
PS/BTW: This is an implemented in-game feature for Elite Dangerous. Am really hoping that we can do this in gpc for T2.
Many thanks
Is there a way to determine when separate corners/quadrants of the PS5 touchpad are pressed?
I would find this extremely helpful in my current script.
Even just to be able to determine whether the left or right side of the touchpad was pressed would be extremely helpful.
PS/BTW: This is an implemented in-game feature for Elite Dangerous. Am really hoping that we can do this in gpc for T2.
Many thanks
Last edited by Sparky101 on Mon Mar 04, 2024 10:06 am, edited 6 times in total.
-
Sparky101 - Command Sergeant Major
- Posts: 114
- Joined: Sun Sep 24, 2017 11:54 am
Re: Detecting quadrant/corner of TouchPad being pressed?
Perhaps there is a way that works with event_release() ?
Perhaps there is an array of (x,y) co-ordinates of the 'pixels' on the touchpad that were 'touched' by thumb/finger "a few ms" (20ms??) before the touchpad button was released?
If so, I could write a function to determine the quadrant that was pressed using that information...
Any help or pointers would be much appreciated.
Perhaps there is an array of (x,y) co-ordinates of the 'pixels' on the touchpad that were 'touched' by thumb/finger "a few ms" (20ms??) before the touchpad button was released?
If so, I could write a function to determine the quadrant that was pressed using that information...
- Code: Select all
#include <ps4.gph>
main {
if(event_release(PS4_TOUCH)) {
// todo: determine which quadrant the press was made in
}
}
Any help or pointers would be much appreciated.
-
Sparky101 - Command Sergeant Major
- Posts: 114
- Joined: Sun Sep 24, 2017 11:54 am
Re: Detecting quadrant/corner of TouchPad being pressed?
This is what I have done in some of my scripts to get the position of the finger when finger is active on the touchpad for 300ms (only touch, not clicking the touchpad)
- Code: Select all
#pragma METAINFO("touch", 1, 0, "Scachi")
#include <ps4.gph>
bool TouchSwitched; // result evalution flag
fix32 x1, y1;
main {
// Use : toggle stuff via touchpad fingertip hold (not click!)
if ( time_active(PS4_TOUCH1) > 300 && TouchSwitched==FALSE && get_val(PS4_TOUCH1)) {
TouchSwitched=TRUE; // set touch pad result flag
// get current locations
x1 = get_val(PS4_TOUCH1X);
y1 = get_val(PS4_TOUCH1Y);
if ( x1 < -60f && y1 < -50f ) { // upper left
// code here
}
else if ( x1 > -40f && x1 < 40f && y1 < -50f) { // upper-mid - pistol recoil
// code here
}
else if ( x1 > 60f && y1 < -50f ) { // upper-right
// code here
}
else if ( x1 < -60f && y1 > 60f ) { // lower-left
// code here
}
else if ( x1 > 60f && y1 > 60f ) { // lower-right
// code here
}
else if ( x1 > -40f && x1 < 40f && y1 > 60f) { // lower-mid
// code here
}
}
if ( event_release(PS4_TOUCH1) ) TouchSwitched = FALSE; // reset result flag for next touch hold
}
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: Detecting quadrant/corner of TouchPad being pressed?
Thank you so much!
If I am able to work out how to convert this with touchpad presses then I'll post the code here.
If I am able to work out how to convert this with touchpad presses then I'll post the code here.
-
Sparky101 - Command Sergeant Major
- Posts: 114
- Joined: Sun Sep 24, 2017 11:54 am
Re: Detecting quadrant/corner of TouchPad being pressed?
Here is a another version of the code for 4 quadrants (rather than 6 areas) with touch and not pressing being the trigger.
Intended as template code.
Intended as template code.
- Code: Select all
#pragma METAINFO("touch quadrants, not press", 1, 0, "")
#include <ps4.gph>
bool TouchSwitched; // result evalution flag
fix32 x1, y1;
main {
// Use : toggle stuff via touchpad fingertip hold (not click!)
if ( time_active(PS4_TOUCH1) > 300 && TouchSwitched==FALSE && get_val(PS4_TOUCH1)) {
TouchSwitched=TRUE; // set touch pad result flag
// get current locations
x1 = get_val(PS4_TOUCH1X);
y1 = get_val(PS4_TOUCH1Y);
if ( x1 <= -1f && y1 <= -1f) { // upper left
// code here
printf ("upper left");
}
else if ( x1 >= 1f && y1 <= -1f) { // upper-right
// code here
printf ("upper right");
}
else if ( x1 <= -1f && y1 >= 1f) { // lower-left
// code here
printf ("lower-left");
}
else if ( x1 >= 1f && y1 >= 1f) { // lower-right
// code here
printf ("lower-right");
}
}
if ( event_release(PS4_TOUCH1) ) TouchSwitched = FALSE; // reset result flag for next touch hold
}
-
Sparky101 - Command Sergeant Major
- Posts: 114
- Joined: Sun Sep 24, 2017 11:54 am
Re: Detecting quadrant/corner of TouchPad being pressed?
And here is another version where the trigger is pressing the touchpad (not touching) for 4 quadrants.
This code disables the passthrough of the touchpad press, so it can manage it directly; the combo for which is included.
Intended as template code.
This code disables the passthrough of the touchpad press, so it can manage it directly; the combo for which is included.
Intended as template code.
- Code: Select all
#pragma METAINFO("touchpad quadrant presses", 1, 0, "")
#include <ps4.gph>
// touchpad variables
bool bTouchpadComboInProgress = 0;
uint32 msMinWaitTimeBetweenTouchpadCombos = 200;
uint32 msLastTimeStartedTouchpadCombo;
fix32 x1, y1;
// misc
uint32 msButtonPressTime = 1000; // use 1000 for testing (to see in Device Monitor); use 20-50 for production
main {
// NOTE: event_active() — I/O changed to active state [event handler for when button-down occurs]
if (event_active(PS4_TOUCH)
&& (system_time() > (msLastTimeStartedTouchpadCombo + msMinWaitTimeBetweenTouchpadCombos))) {
// get current x/y locations on touchpad (where thumb is pressing)
x1 = get_val(PS4_TOUCH1X);
y1 = get_val(PS4_TOUCH1Y);
// update time marker
msLastTimeStartedTouchpadCombo = system_time();
if ( x1 <= -1f && y1 <= -1f) { // upper left
// code here
printf ("upper left");
combo_run (cTestOutput_Cross_b16);
}
else if ( x1 >= 1f && y1 <= -1f) { // upper right
// code here
printf ("upper right");
combo_run (cTestOutput_Circle_b15);
}
else if ( x1 <= -1f && y1 >= 1f) { // lower left
// code here
printf ("lower left");
combo_run (cShortTouchpadPress);
}
else if ( x1 >= 1f && y1 >= 1f) { // lower right
// code here
printf ("lower right");
combo_run (cShortTouchpadPress);
}
else {
// code here
printf("x and/or y not detected");
combo_run (cShortTouchpadPress);
}
}
/* CAUTION: disabling touchpad button press passthrough.
The intention is for this script to handle this output manually with the combo cShortTouchpadPress
*/
set_val (PS4_TOUCH, 0);
}
combo cShortTouchpadPress {
set_val (PS4_TOUCH, 100);
wait (msButtonPressTime);
wait (20);
}
combo cTestOutput_Cross_b16 {
set_val (PS4_CROSS, 100);
wait (msButtonPressTime);
}
combo cTestOutput_Circle_b15 {
set_val (PS4_CIRCLE, 100);
wait (msButtonPressTime);
}
-
Sparky101 - Command Sergeant Major
- Posts: 114
- Joined: Sun Sep 24, 2017 11:54 am
6 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 141 guests