Throttle on a PS4 Button
2 posts
• Page 1 of 1
Throttle on a PS4 Button
Hi there.
Short version: does PS4 buttons hold negative analog values, in range -100 to 100?
Background:
Still improving my project, which I published here https://www.consoletuner.com/greslib/?0&F&0&0&&dmlycGls
I have mapped the Virpil throttle to PS4_R2 button.
In the ConsoleTunner, it shows the PS4_R2 button moving from -100 to 100 as I move the throttle, which is just as I expect.
I have mapped the throttle to ACCEL_2_X and then scripted this to get me values between -100 and 100:
I also tried round numbers:
The problem:
In game, once I move throttle from maximum speed, to zero, and keep reverting to negative values/speed, the throttle jumps to full again. One full throttle travel (from max ahead to full reverse) gives two throttle's travels in game. And never reversing - always in the positive range.
Seeing the behaviour, I am assuming that, as I move the throttle, PS4_R2 goes from 100 --> 0 --> 100 -> 0
Make sense?
If it went 100 --> 0 --> 100 I would say that PS4_R2 does not hold negative numbers - but this is not happening.
Could be a bug in my code? Or in the the GPC2 language?
Short version: does PS4 buttons hold negative analog values, in range -100 to 100?
Background:
Still improving my project, which I published here https://www.consoletuner.com/greslib/?0&F&0&0&&dmlycGls
I have mapped the Virpil throttle to PS4_R2 button.
In the ConsoleTunner, it shows the PS4_R2 button moving from -100 to 100 as I move the throttle, which is just as I expect.
I have mapped the throttle to ACCEL_2_X and then scripted this to get me values between -100 and 100:
- Code: Select all
set_val(PS4_R2, (get_actual(ACCEL_2_X)*2.0)-100.0);
I also tried round numbers:
- Code: Select all
set_val(PS4_R2, floor((get_actual(ACCEL_2_X)*2.0)-100.0));
The problem:
In game, once I move throttle from maximum speed, to zero, and keep reverting to negative values/speed, the throttle jumps to full again. One full throttle travel (from max ahead to full reverse) gives two throttle's travels in game. And never reversing - always in the positive range.
Seeing the behaviour, I am assuming that, as I move the throttle, PS4_R2 goes from 100 --> 0 --> 100 -> 0
Make sense?
If it went 100 --> 0 --> 100 I would say that PS4_R2 does not hold negative numbers - but this is not happening.
Could be a bug in my code? Or in the the GPC2 language?
-
thedude - Staff Sergeant
- Posts: 12
- Joined: Wed Apr 10, 2019 8:09 pm
Re: Throttle on a PS4 Button
It seems the resulting values are overflowing. You can prevent that with the GPC function "clamp", example:
This will restrict the values from 0 .. to 100, which is the valid range for the triggers.
- Code: Select all
main {
set_val(BUTTON_5, clamp(2.0 * get_actual(ACCEL_2_X) - 100.0, 0.0, 100.0));
}
This will restrict the values from 0 .. to 100, which is the valid range for the triggers.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
2 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 93 guests