PS4 TouchPad Help
4 posts
• Page 1 of 1
PS4 TouchPad Help
Hey
I'd doing a simple test script to attempt to Detect touchpad swipes and direction - up, down, left, right.
But I'm getting an odd bug where if the touch swipe crosses the origin, I get an unexpected reversed +-signed result.
Note the Trace Values 4 and 5. keying on these to determine the touch swipe direction.
Can anyone see what I might have missed?
Thanks
I'd doing a simple test script to attempt to Detect touchpad swipes and direction - up, down, left, right.
But I'm getting an odd bug where if the touch swipe crosses the origin, I get an unexpected reversed +-signed result.
Note the Trace Values 4 and 5. keying on these to determine the touch swipe direction.
Can anyone see what I might have missed?
Thanks
- Code: Select all
/* *
* GPC SCRIPT
*
* GPC is a scripting language with C-like syntax.
* To learn more access GPC Language Reference on Help menu.
* *********************************************************** */
int TOUCHING=0;
int tx1,tx2,txd;
int ty1,ty2,tyd;
main {
if(ps4_touchpad(PS4T_P1)) {
set_val(TRACE_1, 100);
set_val(TRACE_2, ps4_touchpad(PS4T_P1X));
set_val(TRACE_3, ps4_touchpad(PS4T_P1Y));
} else set_val(TRACE_1, 0);
//DETECT and save first touch point
if(!TOUCHING){
if(ps4_touchpad(PS4T_P1)) {
TOUCHING=1;
tx1=ps4_touchpad(PS4T_P1X);
ty1=ps4_touchpad(PS4T_P1Y);
}
}
if(TOUCHING){
//Continued touch input held (in motion)
if(ps4_touchpad(PS4T_P1)){
tx2=ps4_touchpad(PS4T_P1X);
ty2=ps4_touchpad(PS4T_P1Y);
}
//DETECT touch ending point
if(!ps4_touchpad(PS4T_P1)){
TOUCHING=0;
txd=tx2-tx1;
tyd=ty2-ty1;
//FIND DIRECTION
if(abs(txd)>abs(tyd)){
//horizontal sweep
if(txd>0){
}else{
}
}else{
//vertical sweep
if(tyd>0){
}else{
}
}
}
}
set_val(TRACE_4,txd);
set_val(TRACE_5,tyd);
}
//blue,red,green,purple
function LED(a, b, c, d){
set_led(0, a);
set_led(1, b);
set_led(2, c);
set_led(3, d);
}
Last edited by xenologer on Thu Jun 07, 2018 2:50 am, edited 1 time in total.
-
xenologer - Command Sergeant Major
- Posts: 147
- Joined: Thu Dec 29, 2016 12:31 am
Re: PS4 TouchPad Help
I'm just using straightforward vector math:
mark the coordinates of touch start
mark coordinates of touch stopping
then subtract the difference, and check +-signage to determine direction
fairly clear cut
so most likely, I'm misinterpreting how the touchpad states work or something; if there is something I'm missing, I haven't found it in the GPC docs....
mark the coordinates of touch start
mark coordinates of touch stopping
then subtract the difference, and check +-signage to determine direction
fairly clear cut
so most likely, I'm misinterpreting how the touchpad states work or something; if there is something I'm missing, I haven't found it in the GPC docs....
-
xenologer - Command Sergeant Major
- Posts: 147
- Joined: Thu Dec 29, 2016 12:31 am
Re: PS4 TouchPad Help
Your script seems to be correct and should work.
Maybe because the value on TRACE_* is overflowing, TRACE_ can only display signed 8bits integers (-128 to 127), and your math can potentially result on values out of this range (up to 200), which overflows. however the variables txd and tyd have the correct value and the script should work as expected.
xenologer wrote:But I'm getting an odd bug where if the touch swipe crosses the origin, I get an unexpected reversed +-signed result.
Maybe because the value on TRACE_* is overflowing, TRACE_ can only display signed 8bits integers (-128 to 127), and your math can potentially result on values out of this range (up to 200), which overflows. however the variables txd and tyd have the correct value and the script should work as expected.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: PS4 TouchPad Help
Yes that was exactly it!
scaling the values before display results in the correct signage
Thanks very much
scaling the values before display results in the correct signage
Thanks very much
-
xenologer - Command Sergeant Major
- Posts: 147
- Joined: Thu Dec 29, 2016 12:31 am
4 posts
• Page 1 of 1
Return to GPC1 Script Programming
Who is online
Users browsing this forum: No registered users and 106 guests