HID Scripting help needed
44 posts
• Page 3 of 5 • 1, 2, 3, 4, 5
Re: HID Scripting help needed
oh great
how do i add this into my script?
how do i add this into my script?
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
oh this is genius
i have figured it out
amazing
i have figured it out
amazing
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
how do I code if I include the ps3 navigation as well now?
can they cross talk? for example, can I say "if get_val(button_3) & mouse_event_active(MBUTTON_1) run combo" ?
can they cross talk? for example, can I say "if get_val(button_3) & mouse_event_active(MBUTTON_1) run combo" ?
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
yes, you can combine them. you have to select the function according to the type of the input or the output.
So if you want to read the input of a controller use "get_val" and all the normal functions.
For output with HID mode it depends on the output:
If you want to output as keyboard use key_set if your want to output as mouse use mouse_set, if you want to output as joystick (not console compatible gamepad) use set_val.
So if you want to read the input of a controller use "get_val" and all the normal functions.
For output with HID mode it depends on the output:
If you want to output as keyboard use key_set if your want to output as mouse use mouse_set, if you want to output as joystick (not console compatible gamepad) use set_val.
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: HID Scripting help needed
HEY SACHI
sorry been away on work
thank you for the explanation that cleared it up a lot.
so I got the recoil just right and even managed to make rapid-fire mode work but I got two issues.
1. is trying to map wasd to the stick_2 (it only seems to go forward if I move the stick forward or backwards) i used to be able to define it using > 90 or <80.
2. is id like to activate the combo only if a button is held for a period of time for example [ if (get_val(PS4_L2) && (get_ptime(PS4_L2) >= 70)) {combo_run(c_HB);}]
here is my attempt so far
bonus question (if i may be cheeky) how do i block input for certain time like if(get_val(PS4_L2)) {
block(PS4_L3, 320);}
sorry been away on work
thank you for the explanation that cleared it up a lot.
so I got the recoil just right and even managed to make rapid-fire mode work but I got two issues.
1. is trying to map wasd to the stick_2 (it only seems to go forward if I move the stick forward or backwards) i used to be able to define it using > 90 or <80.
2. is id like to activate the combo only if a button is held for a period of time for example [ if (get_val(PS4_L2) && (get_ptime(PS4_L2) >= 70)) {combo_run(c_HB);}]
here is my attempt so far
- Code: Select all
#pragma METAINFO("USH-HID_AntiRecoil_Fix32 Extended", 1, 0, "Scachi")
#include <keyboard.gph>
#include <mouse.gph>
#include <mouse_events.gph>
#include <key_events.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 < 200) { antirecoil_X = -0.2; antirecoil_Y = 3.0; }
else if (mb1timer < 900) { antirecoil_X = -0.55; antirecoil_Y = 3.0; }
else if (mb1timer < 1300) { antirecoil_X = -0.55; antirecoil_Y = 3.0; }
else if (mb1timer < 5000) { antirecoil_X = -0.55; antirecoil_Y = 3.0; }
else if (mb1timer < 6000) { antirecoil_X = -100.55; 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_event_active(MBUTTON_1)) {
combo_run(ping);}
if(mouse_status(MBUTTON_1)) {
combo_run(RF);}
if (get_val(STICK_2_Y)) {
combo_run(W);}
}
combo ping {
key_set(KEY_LEFTALT, 100);
wait(30);
key_set(KEY_LEFTALT, 0);
wait(80);
key_set(KEY_LEFTALT, 100);
wait(30);
key_set(KEY_LEFTALT, 0);
wait(1000);
}
combo RF {
mouse_set(MBUTTON_1, 100);
wait(20);
mouse_set(MBUTTON_1, 0);
wait(20);
}
combo W {
key_set(KEY_W, 100);
}
bonus question (if i may be cheeky) how do i block input for certain time like if(get_val(PS4_L2)) {
block(PS4_L3, 320);}
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
Take a look at the device monitor when you move the stick.
Up is Y < 0, Down is Y > 0, left is X < 0 and right is X > 0.
You want to add some deadzone to that to make sure to trigger moving in a direction/pressing only a key when you are moving the stick more than 8.0 or something in a direction.
you can give the "inhibit" function a try to block the output of a button for some specific time.
or use some combination of time_active and get_val or check_active. Then use set_val(BUTTTON_NR,0); to set that button for that time check to unpressed.
all code untested so you have all the fun ;-)
Up is Y < 0, Down is Y > 0, left is X < 0 and right is X > 0.
You want to add some deadzone to that to make sure to trigger moving in a direction/pressing only a key when you are moving the stick more than 8.0 or something in a direction.
- Code: Select all
if(get_actual(STICK_2_Y) < -8.0) {
... press key for up
}
if(get_actual(STICK_2_Y) > 8.0) {
...press key for down
}
you can give the "inhibit" function a try to block the output of a button for some specific time.
- Code: Select all
if(get_val(BUTTON_8)) inhibit(BUTTON_9,320);
or use some combination of time_active and get_val or check_active. Then use set_val(BUTTTON_NR,0); to set that button for that time check to unpressed.
- Code: Select all
if (! check_active(BUTTON_8,320)) set_val(BUTTON_9,0);
all code untested so you have all the fun ;-)
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: HID Scripting help needed
thank you so much scachi i will try em all out.
i also looked into your other works
some of the mods you've done are crazyyyyy
especially the 3d printed stuff
keep up the great work
i also looked into your other works
some of the mods you've done are crazyyyyy
especially the 3d printed stuff
keep up the great work
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
Hey, so I've been playing around with the codes for a few hours now and got the whole gamepad mapped out thank you.
but how do I add timed button press events? such as if I press and hold key_W for 50ms deactivate or ignore key_W and activate key_M or activate a combo for instance?
but how do I add timed button press events? such as if I press and hold key_W for 50ms deactivate or ignore key_W and activate key_M or activate a combo for instance?
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
Ignore me i just discovered the xkeys you were talking about
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
the script is almost ready but
is there some way I could disable it if I hold down a button say (Key_Y)? So I could hold the key Y for navigating menu.
also, could I get this combo to run only when I fully press the forward key but the combo should only run once?
I tried all the codes you've shown so far and no luck
here is the full script so far
- Code: Select all
is there some way I could disable it if I hold down a button say (Key_Y)? So I could hold the key Y for navigating menu.
also, could I get this combo to run only when I fully press the forward key but the combo should only run once?
I tried all the codes you've shown so far and no luck
- Code: Select all
if(get_actual(STICK_2_Y) < -98.0) {
combo_run(TS);}
here is the full script so far
- Code: Select all
#pragma METAINFO("Mouse Amax", 1, 0, "Scachi")
#include <keyboard.gph>
#include <mouse.gph>
#include <mouse_events.gph>
#include <key_events.gph>
#include <ps4.gph>
#define XKEYS_TO_MONITOR_MAX 5 // change 2 to the maximum number of keys you want to keep track of
#include "xkeys.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;
uint8 KEY1, KEY2; // or any other name, this will get an index number assigned by the xkeys_add function
init {
port_connect(PORT_USB_C, PROTOCOL_HID);
keymapping();
mousemapping();
// use xkeys_add to add each key to monitor, it returns an uint8 number that has to be used with the functions
KEY1=xkeys_add(KEY_1); // add key KEY_A to monitoring
KEY2=xkeys_add(KEY_F); // add key KEY_S to monitoring
}
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 = 2.0; antirecoil_Y = 5.0; }
else if (mb1timer < 300) { antirecoil_X = -0.0; antirecoil_Y = 8.0; }
else if (mb1timer < 900) { antirecoil_X = -0.0; antirecoil_Y = 8.0; }
else if (mb1timer < 1300) { antirecoil_X = -0.55; antirecoil_Y = 3.0; }
else if (mb1timer < 5000) { antirecoil_X = -0.55; antirecoil_Y = 3.0; }
else if (mb1timer < 6000) { antirecoil_X = -0.55; antirecoil_Y = 3.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
}
//PING
if(mouse_event_active(MBUTTON_1)) {
combo_run(ping);}
//RAPID FIRE
if(key_status(KEY_Y) & (mouse_status(MBUTTON_1))) {
combo_run(RF);}
// RELOAD & ACTION
if (xkeys_is_active(KEY2) && xkeys_time_active(KEY2) > 300) {
key_set(KEY_R, 100);}
//TAC SPRINT
if(event_active (STICK_2_Y)) {
combo_run(TS);}
//weapon switch & armor key
if (xkeys_is_active(KEY1) && xkeys_time_active(KEY1) > 200) {
key_set(KEY_1, 0);
key_set(KEY_4, 100);}
// REMAPING
// STICK FORWARD
if(get_actual(STICK_2_Y) < -20.0) {
key_set(KEY_W, 100);}
if(get_actual(STICK_2_Y) < -98.0) {
key_set(KEY_LEFTSHIFT , 100);}
// STICK BACKWARD
if(get_actual(STICK_2_Y) > 50.0) {
key_set(KEY_S, 100);}
// STICK RIGHT
if(get_actual(STICK_2_X) > 50.0) {
key_set(KEY_D, 100);}
// STICK LEFT
if(get_actual(STICK_2_X) < -50.0) {
key_set(KEY_A, 100);}
// PS3 NAV L2
if(get_val(BUTTON_8)) {
key_set(KEY_SPACEBAR, 100);}
// PS3 NAV L1
if(get_val(BUTTON_7)) {
key_set(KEY_C, 100);}
// PS3 NAV L3
if(get_val(BUTTON_9)) {
key_set(KEY_LEFTSHIFT, 0);}
// PS3 NAV CIRCLE
if(get_val(BUTTON_15)) {
key_set(KEY_ESCAPE, 100);}
// PS3 NAV CROSS
if(get_val(BUTTON_16)) {
key_set(KEY_RETURNORENTER, 100);}
// PS3 NAV PS BUTTON
if(get_val(BUTTON_1)) {
key_set(KEY_M, 100);}
// PS3 NAV DOWN
if(get_val(BUTTON_11)) {
key_set(KEY_L, 100);}
// PS3 NAV UP
if(get_val(BUTTON_10)) {
key_set(KEY_LEFTALT, 100);}
// PS3 NAV RIGHT
if(get_val(BUTTON_13)) {
key_set(KEY_3, 100);}
// PS3 NAV LEFT
if(get_val(BUTTON_12)) {
key_set(KEY_M, 0);}
}
combo ping {
key_set(KEY_LEFTALT, 100);
wait(30);
key_set(KEY_LEFTALT, 0);
wait(80);
key_set(KEY_LEFTALT, 100);
wait(30);
key_set(KEY_LEFTALT, 0);
wait(1000);
}
combo RF {
mouse_set(MBUTTON_1, 100);
wait(20);
mouse_set(MBUTTON_1, 0);
wait(20);
}
combo TS {
key_set(KEY_LEFTSHIFT, 100);
wait(10);
key_set(KEY_LEFTSHIFT, 0);
wait(20);
key_set(KEY_LEFTSHIFT, 100);
wait(10);
key_set(KEY_LEFTSHIFT, 0);
wait(20);
}
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
44 posts
• Page 3 of 5 • 1, 2, 3, 4, 5
Return to GPC2 Script Programming
Who is online
Users browsing this forum: AZOV_ops and 119 guests