Coding Question
5 posts
• Page 1 of 1
Coding Question
I am trying to write some code at the start of a macro for my Ps4 controller that will not allow the right stick (RY and RX) to send a command to the game, but still allow moving the right stick to activate different actions in my macro.
Example: In game the right stick is used to control the camera, and cannot be unbound. I do not really use the camera for anything in this game, but would like to be able to use the right stick to run combos with my titanone. An example of this would be RX>30 and RY>30 then run a combo within my script.
Thanks!
Example: In game the right stick is used to control the camera, and cannot be unbound. I do not really use the camera for anything in this game, but would like to be able to use the right stick to run combos with my titanone. An example of this would be RX>30 and RY>30 then run a combo within my script.
Thanks!
-
mttgbsn - Master Sergeant
- Posts: 39
- Joined: Tue Apr 05, 2016 6:07 pm
Re: Coding Question
my first thought would be to simply set_val(PS4_RX,0) at the very end of main() after you're done reading the input
but maybe there's a more elegant, method? I haven't done much with the lower level input binding functions... maybe one of the mods can comment on that
but maybe there's a more elegant, method? I haven't done much with the lower level input binding functions... maybe one of the mods can comment on that
-
xenologer - Command Sergeant Major
- Posts: 147
- Joined: Thu Dec 29, 2016 12:31 am
Re: Coding Question
What you are describing -I believe- can be achieved with this code:
- Code: Select all
int up_flag, down_flag, left_flag, right_flag;
main {
// UP
if(get_val(PS4_RY) < -50) {
if(!up_flag) {
up_flag = 1;
combo_run(ComboUP);
}
} else up_flag = 0;
// DOWN
if(get_val(PS4_RY) > 50) {
if(!down_flag) {
down_flag = 1;
combo_run(ComboDOWN);
}
} else down_flag = 0;
// LEFT
if(get_val(PS4_RX) < -50) {
if(!left_flag) {
left_flag = 1;
combo_run(ComboLEFT);
}
} else left_flag = 0;
// RIGHT
if(get_val(PS4_RX) > 50) {
if(!right_flag) {
right_flag = 1;
combo_run(ComboRIGHT);
}
} else right_flag = 0;
set_val(PS4_RY, 0);
set_val(PS4_RX, 0);
}
combo ComboUP {
//
// combo code here
//
}
combo ComboDOWN {
//
// combo code here
//
}
combo ComboLEFT {
//
// combo code here
//
}
combo ComboRIGHT {
//
// combo code here
//
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Coding Question
so J2Kbr
you're just clearing the values to 0 at the end after reading them?
there's no method to just 'unlink' or 'block' those inputs so they simply don't forward to the console yet are still accessible to the script?
..I suppose not since for the TitanOne In and Out are all the same memory right?
I'd guess the TitanTwo could do it a lot nicer...
you're just clearing the values to 0 at the end after reading them?
there's no method to just 'unlink' or 'block' those inputs so they simply don't forward to the console yet are still accessible to the script?
..I suppose not since for the TitanOne In and Out are all the same memory right?
I'd guess the TitanTwo could do it a lot nicer...
-
xenologer - Command Sergeant Major
- Posts: 147
- Joined: Thu Dec 29, 2016 12:31 am
Re: Coding Question
xenologer wrote:so J2Kbr you're just clearing the values to 0 at the end after reading them?
Correct.
xenologer wrote:there's no method to just 'unlink' or 'block' those inputs so they simply don't forward to the console yet are still accessible to the script? ..I suppose not since for the TitanOne In and Out are all the same memory right?
On Titan One it is possible use the unmap built-in function, like this:
- Code: Select all
unmap PS4_RY;
unmap PS4_RX;
int up_flag, down_flag, left_flag, right_flag;
main {
// UP
if(get_val(PS4_RY) < -50) {
if(!up_flag) {
up_flag = 1;
combo_run(ComboUP);
}
} else up_flag = 0;
// DOWN
if(get_val(PS4_RY) > 50) {
if(!down_flag) {
down_flag = 1;
combo_run(ComboDOWN);
}
} else down_flag = 0;
// LEFT
if(get_val(PS4_RX) < -50) {
if(!left_flag) {
left_flag = 1;
combo_run(ComboLEFT);
}
} else left_flag = 0;
// RIGHT
if(get_val(PS4_RX) > 50) {
if(!right_flag) {
right_flag = 1;
combo_run(ComboRIGHT);
}
} else right_flag = 0;
}
combo ComboUP {
//
// combo code here
//
}
combo ComboDOWN {
//
// combo code here
//
}
combo ComboLEFT {
//
// combo code here
//
}
combo ComboRIGHT {
//
// combo code here
//
}
The final result will be the same, the advantage of unmap is it does not consume processing time once set.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
5 posts
• Page 1 of 1
Return to GPC1 Script Programming
Who is online
Users browsing this forum: No registered users and 82 guests