HID Scripting help needed
44 posts
• Page 2 of 5 • 1, 2, 3, 4, 5
Re: HID Scripting help needed
oh hold on i can see the wait command being used ignore me lol
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
is there a reason why this doesn't work?
- Code: Select all
#include <keyboard.gph>
#include <mouse.gph>
init {
port_connect(PORT_USB_C, PROTOCOL_HID);
keymapping();
mousemapping();
}
main {
if(mouse_get(MBUTTON_2)) {
combo_run(turbo);
}
}
combo turbo {
mouse_set(MBUTTON_2, 100)
wait (20);
mouse_set(MBUTTON_2, 0)
wait (20);
}
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
missing ";"
you have to be careful when coding/scripting/programming .. missing a single character may cause a lot of trouble.
always add line by line and try to compile. when it fails to compile you know the amount of lines changed to your last successful compile and try to track down the issue a lot easier.
double clicking on the error output line will jump you to the line with the error. take a look at the lines before that and the line itself.
you have to be careful when coding/scripting/programming .. missing a single character may cause a lot of trouble.
always add line by line and try to compile. when it fails to compile you know the amount of lines changed to your last successful compile and try to track down the issue a lot easier.
double clicking on the error output line will jump you to the line with the error. take a look at the lines before that and the line itself.
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: HID Scripting help needed
holly sh** (facepalm)
thank you for being patient with me
thank you for being patient with me
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
what am i doing wrong here? does the "if combo is running" command not work?
- Code: Select all
#pragma METAINFO("USH-HID_AntiRecoil_Fix32 Extended", 1, 0, "Scachi")
#include <keyboard.gph>
#include <mouse.gph>
// configuration
// advanced configuration
const int MOUSE_SPEED = 10; // <- should be around 10 or higher, a value too low can stop the mouse from working
// internal
fix32 antirecoil_X;
fix32 antirecoil_Y;
uint32 ARTIMER;
int32 X, Y, WHEEL;
int32 RX, RY;
fix32 ARX, ARY;
// mouse press time tracker for staged anti recoil
uint32 mb1timer;
init {
port_connect(PORT_USB_C, PROTOCOL_HID);
keymapping();
mousemapping();
}
main {
key_passthru();
mouse_passthru();
X = 0; Y = 0; WHEEL = 0;
RX = 0; RY = 0;
if(mouse_status(MREPORT_UPDATED)) {
mouse_passthru(); // only passthru when there is data to send
X = mouse_status(MOUSE_X);
Y = mouse_status(MOUSE_Y);
WHEEL = mouse_status(MOUSE_WHEEL);
}
if(mouse_status(MBUTTON_1))
{
ARTIMER += elapsed_time(); // mouse speed timer
mb1timer += elapsed_time(); // mouse button press timer
// ADJUST VALUES & TIME and add more here as required
// !! example only.. you need to retune the anti recoil values as gamepad values don't apply 1:1 to mouse values !!
if (mb1timer < 95) { antirecoil_X = 1.0; antirecoil_Y = 2.0; }
else if (mb1timer < 300) { antirecoil_X = 0.0; antirecoil_Y = 3.0; }
else if (mb1timer < 900) { antirecoil_X = -0.5; antirecoil_Y = 2.0; }
else if (mb1timer < 1300) { antirecoil_X = -0.5; antirecoil_Y = 2.0; }
if(!(ARTIMER%MOUSE_SPEED)) {
ARX += (fix32)(antirecoil_X);
ARY += (fix32)(antirecoil_Y);
if (antirecoil_X < 0.0) RX += (int)ceil((ARX));
else RX += (int)floor((ARX));
if (antirecoil_Y < 0.0) RY += (int)ceil((ARY));
else RY += (int)floor((ARY));
mouse_set(MOUSE_X, X+RX);
mouse_set(MOUSE_Y, Y+RY);
mouse_set(MOUSE_WHEEL,WHEEL);
ARX = mod(ARX,1.0);
ARY = mod(ARY,1.0);
}
} else {
ARTIMER = MOUSE_SPEED; // reset mouse speed timer
ARX = 0.0; ARY = 0.0;
mb1timer = 0; // reset mouse button press timer
}
if(mouse_get(MBUTTON_1)) {
combo_run(ping);}
else if(combo_running(ping)) {
combo_stop(ping);}
}
combo ping {
key_set(KEY_LEFTALT, 100);
wait (10);
key_set(KEY_LEFTALT, 0);
wait (50);
key_set(KEY_LEFTALT, 100);
wait (10);
key_set(KEY_LEFTALT, 0);
wait (10);
}
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
Read the output panel message.
"Identifier not declared" is sayign that this function does not exists.
To check if a combo is running just do "if (comboname)" like that :
GPC error: t2_dont_cryaa.gpc(79): Identifier not declared 'combo_running'.
GPC error: t2_dont_cryaa.gpc(79): Illegal operation 'arg:1'.
GPC error: t2_dont_cryaa.gpc(79): Illegal function call, near ')'
"Identifier not declared" is sayign that this function does not exists.
To check if a combo is running just do "if (comboname)" like that :
- Code: Select all
else if (ping)
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: HID Scripting help needed
ah gotcha
what I was trying to do was to make it run the combo once when I initially click and then stop until I release and click again like had it here.
but now this compiles but its just constantly spamming
what I was trying to do was to make it run the combo once when I initially click and then stop until I release and click again like had it here.
- Code: Select all
if((get_val(PS4_R2)) && (get_val(PS4_L2))) {
combo_run(pp);}
else if(combo_running(pp)) {
combo_stop(pp);}
but now this compiles but its just constantly spamming
- Code: Select all
#pragma METAINFO("USH-HID_AntiRecoil_Fix32 Extended", 1, 0, "Scachi")
#include <keyboard.gph>
#include <mouse.gph>
// configuration
// advanced configuration
const int MOUSE_SPEED = 10; // <- should be around 10 or higher, a value too low can stop the mouse from working
// internal
fix32 antirecoil_X;
fix32 antirecoil_Y;
uint32 ARTIMER;
int32 X, Y, WHEEL;
int32 RX, RY;
fix32 ARX, ARY;
// mouse press time tracker for staged anti recoil
uint32 mb1timer;
init {
port_connect(PORT_USB_C, PROTOCOL_HID);
keymapping();
mousemapping();
}
main {
key_passthru();
mouse_passthru();
X = 0; Y = 0; WHEEL = 0;
RX = 0; RY = 0;
if(mouse_status(MREPORT_UPDATED)) {
mouse_passthru(); // only passthru when there is data to send
X = mouse_status(MOUSE_X);
Y = mouse_status(MOUSE_Y);
WHEEL = mouse_status(MOUSE_WHEEL);
}
if(mouse_status(MBUTTON_1))
{
ARTIMER += elapsed_time(); // mouse speed timer
mb1timer += elapsed_time(); // mouse button press timer
// ADJUST VALUES & TIME and add more here as required
// !! example only.. you need to retune the anti recoil values as gamepad values don't apply 1:1 to mouse values !!
if (mb1timer < 95) { antirecoil_X = 1.0; antirecoil_Y = 2.0; }
else if (mb1timer < 300) { antirecoil_X = 0.0; antirecoil_Y = 3.0; }
else if (mb1timer < 900) { antirecoil_X = -0.5; antirecoil_Y = 2.0; }
else if (mb1timer < 1300) { antirecoil_X = -0.5; antirecoil_Y = 2.0; }
if(!(ARTIMER%MOUSE_SPEED)) {
ARX += (fix32)(antirecoil_X);
ARY += (fix32)(antirecoil_Y);
if (antirecoil_X < 0.0) RX += (int)ceil((ARX));
else RX += (int)floor((ARX));
if (antirecoil_Y < 0.0) RY += (int)ceil((ARY));
else RY += (int)floor((ARY));
mouse_set(MOUSE_X, X+RX);
mouse_set(MOUSE_Y, Y+RY);
mouse_set(MOUSE_WHEEL,WHEEL);
ARX = mod(ARX,1.0);
ARY = mod(ARY,1.0);
}
} else {
ARTIMER = MOUSE_SPEED; // reset mouse speed timer
ARX = 0.0; ARY = 0.0;
mb1timer = 0; // reset mouse button press timer
}
if(mouse_get(MBUTTON_1)) {
combo_run(ping);}
else if (ping) {
combo_stop(ping);}
}
combo ping {
key_set(KEY_LEFTALT, 100);
wait (10);
key_set(KEY_LEFTALT, 0);
wait (50);
key_set(KEY_LEFTALT, 100);
wait (10);
key_set(KEY_LEFTALT, 0);
wait (10);
}
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
get_val(button) return a value != 0 as long as the button is pressed.
event_active(button) returns TRUE in the moment the button is pressed only.
When you want the combo to be run once only on press of one button use event_active.
If you want a combo of two buttons instead use a combination of get_val(buttonToHold) and event_active(buttonToPress)
event_active(button) returns TRUE in the moment the button is pressed only.
When you want the combo to be run once only on press of one button use event_active.
If you want a combo of two buttons instead use a combination of get_val(buttonToHold) and event_active(buttonToPress)
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: HID Scripting help needed
ok but those commands don't work on HID right?
so if I do this for example
it won't do anything?
so if I do this for example
- Code: Select all
if(event_active(MBUTTON_1)) {
combo_run(ping);}
it won't do anything?
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
Sorry ... get_val and event_active and alike works with controller button inputs only.
You can track the mouse button state manually so get your own mouse_event_active or stick to a header file.
Search for mouse_events in the gtuner IV online resources for an easy to use header file.
You can track the mouse button state manually so get your own mouse_event_active or stick to a header file.
- Code: Select all
#include <mouse.gph>
bool mb1=FALSE;
init {
port_connect(PORT_USB_C, PROTOCOL_HID);
keymapping();
mousemapping();
}
main {
key_passthru();
mouse_passthru();
if (mouse_get(MBUTTON_1)) {
if (!mb1) {
mb1=TRUE;
printf("event active mouse");
}
} else {
mb1 = FALSE;
}
}
Search for mouse_events in the gtuner IV online resources for an easy to use header file.
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
44 posts
• Page 2 of 5 • 1, 2, 3, 4, 5
Return to GPC2 Script Programming
Who is online
Users browsing this forum: alanmcgregor and 81 guests