GPC Learning
7 posts
• Page 1 of 1
GPC Learning
Hi
I started learning to code GPC scripts thought it may help understand the device and usage much better. I like to get clarified below questions?
1. 'main' method will be running in loop?
2. Do we have a command to stop all running combo's?
Tried a small example.
In the above example, do I need to set BUTTON-9 to 0 after event triggered?
Thanks
Badri M
I started learning to code GPC scripts thought it may help understand the device and usage much better. I like to get clarified below questions?
1. 'main' method will be running in loop?
2. Do we have a command to stop all running combo's?
Tried a small example.
- Code: Select all
#pragma METAINFO("<badmn>", 1, 0, "")
#include <ps4.gph>
bool sprint = FALSE;
init {
pmem_load();
sprint = pmem_read(0);
}
main {
if (event_active(STICK_2_Y) && get_val(STICK_2_Y)!=1.0) {
sprint = TRUE;
} else {
sprint = FALSE;
//need command to stop all combo
combo_stop(AutoRun);
}
if(sprint) {
combo_run(AutoRun);
}
}
combo AutoRun{
set_val(BUTTON_9, 100);
wait(40);
wait(40);
}
In the above example, do I need to set BUTTON-9 to 0 after event triggered?
Thanks
Badri M
-
badrisuper - Sergeant First Class
- Posts: 16
- Joined: Fri Aug 04, 2017 3:18 am
Re: GPC Learning
1.Yes
2.There is no command to stop all combos, you must stop each ones.
2.There is no command to stop all combos, you must stop each ones.
Console tuner since my 1st controller.
Scripting, a game in the game.
Believe or dare, It's Titanic!
Scripting, a game in the game.
Believe or dare, It's Titanic!
-
Prototype - Major General
- Posts: 3252
- Joined: Sun Dec 16, 2012 1:43 pm
Re: GPC Learning
There's rarely a need to stop a combo unless attempting to override it, for example, overriding a rapid-fire combo by holding a button.
In most use cases, if the button hold or press condition is no longer true for that combo, the combo will stop by itself. In other words, this isn't needed -
In most use cases, if the button hold or press condition is no longer true for that combo, the combo will stop by itself. In other words, this isn't needed -
- Code: Select all
else {
sprint = FALSE;
//need command to stop all combo
combo_stop(AutoRun);
}
-
antithesis - Colonel
- Posts: 1912
- Joined: Sat May 28, 2016 10:45 pm
Re: GPC Learning
Thanks prototype, antithesis. Need one more clarification.
I want to start an action on press of a button. But action has to be continued until another button press registered. Is this possible?
For example, I want to press 'w' button to move forward instead of holding it and stop it by pressing 's' button.
Here referring 'w' to keyboard mapped to move forward in stick and 's' to move backward.
Something similar like below will work?
Thanks
Badri M
I want to start an action on press of a button. But action has to be continued until another button press registered. Is this possible?
For example, I want to press 'w' button to move forward instead of holding it and stop it by pressing 's' button.
Here referring 'w' to keyboard mapped to move forward in stick and 's' to move backward.
Something similar like below will work?
- Code: Select all
#pragma METAINFO("Badri M", 1, 0, "")
#include <ps4.gph>
bool moveForward;
bool moveBackward;
bool straffLeft;
bool straffRight;
main {
if(get_actual(STICK_2_X)>20.0 && get_prev(STICK_2_X)>20.0) {
set_val(STICK_2_X, 0.0);
set_val(STICK_2_Y, 0.0);
moveBackward = FALSE;
moveForward = FALSE;
straffLeft = FALSE;
straffRight = FALSE;
}
if(event_active(STICK_2_X) || moveForward || moveBackward) {
if(event_active(STICK_2_X)) {
if(get_actual(STICK_2_X)<-20.0) {
/*moveForward = TRUE;
moveBackward = FALSE;
straffLeft = FALSE;
straffRight = FALSE;*/
setMoveForward();
} else if(get_actual(STICK_2_X)>20.0) {
/*moveForward = FALSE;
moveBackward = TRUE;
straffLeft = FALSE;
straffRight = FALSE;*/
setMoveBackward();
}
}
if(moveForward) {
/*moveBackward = FALSE;
straffLeft = FALSE;
straffRight = FALSE;*/
setMoveForward();
combo_run(moveUp);
}
if(moveBackward) {
/*moveForward = FALSE;
straffLeft = FALSE;
straffRight = FALSE;*/
setMoveBackward();
combo_run(moveDown);
}
}
if(event_active(STICK_2_Y) || straffLeft || straffRight) {
if(event_active(STICK_2_Y)) {
if(get_actual(STICK_2_Y)<-20.0) {
/*straffRight = TRUE;
straffLeft = FALSE;
moveForward = FALSE;
moveBackward = FALSE;*/
setMoveRight();
} else if(get_actual(STICK_2_Y)>20.0) {
/*straffRight = FALSE;
straffLeft = TRUE;
moveForward = FALSE;
moveBackward = FALSE;*/
setMoveLeft();
}
}
if(straffRight) {
/*straffLeft = FALSE;
moveForward = FALSE;
moveBackward = FALSE;*/
setMoveRight();
combo_run(moveRight);
}
if(straffLeft) {
/*straffRight = FALSE;
moveForward = FALSE;
moveBackward = FALSE;*/
setMoveLeft();
combo_run(moveLeft);
}
}
}
combo moveUp {
set_val(STICK_2_X, -100.0);
}
combo moveDown {
set_val(STICK_2_X, 100.0);
}
combo moveRight {
set_val(STICK_2_Y, -100.0);
}
combo moveLeft {
set_val(STICK_2_X, 100.0);
}
/*combo halt {
set_val(STICK_2_X, 0.0);
}*/
void setMoveForward() {
moveForward = TRUE;
moveBackward = FALSE;
straffLeft = FALSE;
straffRight = FALSE;
}
void setMoveBackward() {
moveForward = FALSE;
moveBackward = TRUE;
straffLeft = FALSE;
straffRight = FALSE;
}
void setMoveRight() {
straffRight = TRUE;
straffLeft = FALSE;
moveForward = FALSE;
moveBackward = FALSE;
}
void setMoveLeft() {
straffRight = FALSE;
straffLeft = TRUE;
moveForward = FALSE;
moveBackward = FALSE;
}
Thanks
Badri M
-
badrisuper - Sergeant First Class
- Posts: 16
- Joined: Fri Aug 04, 2017 3:18 am
Re: GPC Learning
I'm not shure it will work, can't test it, written in notepad
If don't work, i know what to do for make it working
If don't work, i know what to do for make it working
- Code: Select all
#include "keyboard.gph"
int8 check_keycode_W; // W MAPED keys
int8 check_keycode_S; // S MAPED keys
uint8 keycode; // Keys keycode check
int more_forward;
int more_backward;
init {
check_keycode_W == 0;
check_keycode_S == 0;
const uint8 map[] = {
KEY_W, STICK_2_Y | KEYMAP_NEGATIVE,
KEY_S, STICK_2_Y,
KEY_A, STICK_2_X | KEYMAP_NEGATIVE,
KEY_D, STICK_2_X,
};
keymapping(map);
}
//=======================================================================================================================
main {
if (check_keycode_W == 0 && more_forward == 0){
if(key_status(KEY_W)){
keycode = key_get();
if(keycode) {
check_keycode_W = 1;
more_forward = 1;
more_backward = 0;
printf("more_forward: %d ", more_forward); // More fast debug
printf("more_backward: %d ", more_backward); // More fast debug
}
}
}
else if(!key_status(KEY_W) && check_keycode_W == 1) {
check_keycode_W = 0; // Return check
}
if (check_keycode_S == 0 && more_backward == 0){
if(key_status(KEY_S)){
keycode = key_get();
if(keycode) {
check_keycode_S = 1;
more_forward = 0;
more_backward = 1;
printf("more_forward: %d ", more_forward); // More fast debug
printf("more_backward: %d ", more_backward); // More fast debug
}
}
}
else if(!key_status(KEY_S) && check_keycode_S == 1) {
check_keycode_S = 0; // Return check
}
if (more_forward == 1 || more_backward == 1) {
move (STICK_2_Y, 100.0);
}
if(key_status(KEY_A) || key_status(KEY_D)) {
more_forward = 0;
more_backward = 0;
}
}
//=======================================================================================================================
void move (uint8 move_l, fix32 val){
if (more_forward == 1){
set_val(move_l, val);
}
if (more_backward == 1){
set_val(move_l, -val);
}
return;
}
Last edited by sky418 on Mon Aug 28, 2017 3:33 pm, edited 2 times in total.
-
sky418 - Command Sergeant Major
- Posts: 124
- Joined: Fri Nov 25, 2016 4:28 am
Re: GPC Learning
Thanks sky418.
If I am not wrong above code inherits T2's keyboard translator.
My setup is xim4->T2->ps4. I want to simply loop the movement on single button press and stop the movement by pressing deactivation key.
Thanks
Badri M
If I am not wrong above code inherits T2's keyboard translator.
My setup is xim4->T2->ps4. I want to simply loop the movement on single button press and stop the movement by pressing deactivation key.
Thanks
Badri M
-
badrisuper - Sergeant First Class
- Posts: 16
- Joined: Fri Aug 04, 2017 3:18 am
Re: GPC Learning
It can be done when you, in alternative settings, in XIM4 add one real keyboard button to two or three different DS4 buttons, and then in T2 script make rules for pressing this button to do something.
-
sky418 - Command Sergeant Major
- Posts: 124
- Joined: Fri Nov 25, 2016 4:28 am
7 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: midg3t2 and 211 guests