HID Scripting help needed
44 posts
• Page 1 of 5 • 1, 2, 3, 4, 5
HID Scripting help needed
hi
I have been putting together my own codes in gpc for a few months now for ps4 controller.
but having built a new pc and trying out M&K gaming I wanted to use the T2 to make some of my old mods but for a mouse and ps3 navigation controller combo (the nav controller will replace my keyboard) my number one needed mod is the anti-recoil I use which isn't a simple "PULL DOWN 30% FOREVER" script. the script I use at the moment pulls down a certain amount for certain mili seconds and then changes to a different amount for a different amount of seconds. ill leave a sample code below.
is there any way I can replicate these mods on an HID mouse and keyboard mode but also having my navigation controller remapped as keyboard all on the same script?
my mod
I have been putting together my own codes in gpc for a few months now for ps4 controller.
but having built a new pc and trying out M&K gaming I wanted to use the T2 to make some of my old mods but for a mouse and ps3 navigation controller combo (the nav controller will replace my keyboard) my number one needed mod is the anti-recoil I use which isn't a simple "PULL DOWN 30% FOREVER" script. the script I use at the moment pulls down a certain amount for certain mili seconds and then changes to a different amount for a different amount of seconds. ill leave a sample code below.
is there any way I can replicate these mods on an HID mouse and keyboard mode but also having my navigation controller remapped as keyboard all on the same script?
my mod
- Code: Select all
#pragma METAINFO("BR NEW", 1, 0, "tt3000")
#include <titanone.gph>
define Release = 13;
int ARV;
int ARH;
int arv;
int arh;
main {
if ((get_val(PS4_L2)) && (get_val(PS4_R2))) {
if(get_ptime(PS4_R2) <= 95)
{
ARV = 31;
ARH = 7;
}
if(get_ptime(PS4_R2) >= 95)
{
ARV = 31;
ARH = 5;
}
if(get_ptime(PS4_R2) > 300)
{
ARV = 29;
ARH = 3;
}
if(get_ptime(PS4_R2) > 900)
{
ARV = 21;
ARH = -7;
}
if(get_ptime(PS4_R2) > 1300)
{
ARV = 19;
ARH = -5;
}
if(get_ptime(PS4_R2) > 2000)
{
ARV = 19;
ARH = -2;
}
combo_run(c_AntiRecoilak);
}
else combo_stop(c_AntiRecoilak);
if (abs(get_val(PS4_RY)) > Release|| abs(get_val(PS4_RX)) > Release) combo_stop(c_AntiRecoilak);
}
combo c_AntiRecoilak {
arv = get_val(PS4_RY) + ARV;
if (arv > 100) arv = 100;
set_val(PS4_RY, arv);
arh = get_val(PS4_RX) + ARH;
if (arh > 100) arh = 100;
set_val(PS4_RX, arh);
}
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
USB HID requires other functions to be called. you can't use set_val anymore.
you have to use mouse_set and key_set and other functions.
Some usb hid instructions/examples:
https://www.consoletuner.com/wiki/index ... il_decimal
Modifying this anti recoil script for changing values over button/key press time you can use the same approach as you did in your code (removing the const).
For mapping controller inputs to keys take a look at some of the usb hid scripts source code in the online resource,
search for "gamepad to mouse", the thread about the script: viewtopic.php?f=23&t=13612#p89885
I haven't added examples for mapping like that to the wiki, I will try to do so soon.
you have to use mouse_set and key_set and other functions.
Some usb hid instructions/examples:
https://www.consoletuner.com/wiki/index ... il_decimal
Modifying this anti recoil script for changing values over button/key press time you can use the same approach as you did in your code (removing the const).
For mapping controller inputs to keys take a look at some of the usb hid scripts source code in the online resource,
search for "gamepad to mouse", the thread about the script: viewtopic.php?f=23&t=13612#p89885
I haven't added examples for mapping like that to the wiki, I will try to do so soon.
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: HID Scripting help needed
Thank you for this
I will keep digging into this
But is it possible for you to change the decimal script and remove the const for me?
All I need is one instance with under 94ms and on after 94ms and I should be able to built from there.
I will keep digging into this
But is it possible for you to change the decimal script and remove the const for me?
All I need is one instance with under 94ms and on after 94ms and I should be able to built from there.
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
Looks like gpc2 is still allowing to modify variables declared using the const keyword, so you don't need to remove that word "const"from the line when you want to change that value later on in the code.
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: HID Scripting help needed
ok, but how do I then get the value to change after say 100ms.... could I use "if(get_ptime"?
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
OK I am sure this isn't the way to go about it but I gave it a shot and it isn't compiling.
- Code: Select all
#pragma METAINFO("BR NEW", 1, 0, "tt3000")
#include <keyboard.gph>
#include <mouse.gph>
#include <titanone.gph>
#define Release = 13
#define get_ptime
int ARV;
int ARH;
int arv;
int arh;
main {
if ((mouse_status(MBUTTON_1)) && (mouse_status(MBUTTON_2))) {
if(get_ptime(mouse_status(MBUTTON_1) <= 95)
{
ARV = 31;
ARH = 7;
}
if(get_ptime(mouse_status(MBUTTON_1) >= 95)
{
ARV = 31;
ARH = 5;
}
if(get_ptime(mouse_status(MBUTTON_1) > 300)
{
ARV = 29;
ARH = 3;
}
if(get_ptime(mouse_status(MBUTTON_1) > 900)
{
ARV = 21;
ARH = -7;
}
if(get_ptime(mouse_status(MBUTTON_1) > 1300)
{
ARV = 19;
ARH = -5;
}
if(get_ptime(mouse_status(MBUTTON_1) > 2000)
{
ARV = 19;
ARH = -2;
}
combo_run(c_AntiRecoilak);
}
else combo_stop(c_AntiRecoilak);
if (abs(mouse_status(MOUSE_Y)) > Release|| abs(mouse_status(MOUSE_X)) > Release) combo_stop(c_AntiRecoilak);
}
combo c_AntiRecoilak {
arh = mouse_status(MOUSE_Y) + ARV;
if (arv > 100) arv = 100;
mouse_set(MOUSE_Y, arv);
arh = mouse_status(MOUSE_X) + ARH;
if (arh > 100) arh = 100;
mouse_set(MOUSE_X, arh);
}
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
Forget your current script. You can't use get_ptime (thats T1 code and not usable for mouse in HID mode).
Take a look at https://www.consoletuner.com/wiki/index ... _functions for list of functions to handle mouse/keyboard input/output in hid mode.
Use that linked on as a new base and extend it to support multiple values over time and you are done:
https://www.consoletuner.com/wiki/index ... il_decimal
You should not mix t1 code and T2 code.. do not use the titanone.gph header file when you are doing new scripts, you are asking for trouble sooner or later when mxing t1 and t2 code.
This may work for mouse anti recoil with multiple values depending on the mouse button press time:
To add controller to keyboard mappings I have added a wiki entry: https://www.consoletuner.com/wiki/index ... o_keyboard
Take a look at https://www.consoletuner.com/wiki/index ... _functions for list of functions to handle mouse/keyboard input/output in hid mode.
Use that linked on as a new base and extend it to support multiple values over time and you are done:
https://www.consoletuner.com/wiki/index ... il_decimal
You should not mix t1 code and T2 code.. do not use the titanone.gph header file when you are doing new scripts, you are asking for trouble sooner or later when mxing t1 and t2 code.
This may work for mouse anti recoil with multiple values depending on the mouse button press time:
- Code: Select all
#pragma METAINFO("USH-HID_AntiRecoil_Fix32 Extended", 1, 0, "Scachi")
#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 {
keymapping();
mousemapping();
}
main {
key_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 = 7.0; antirecoil_Y = 31.0; }
else if (mb1timer < 300) { antirecoil_X = 5.0; antirecoil_Y = 31.0; }
else if (mb1timer < 900) { antirecoil_X = 3.0; antirecoil_Y = 29.0; }
else if (mb1timer < 1300) { antirecoil_X = -7.0; antirecoil_Y = 21.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
}
}
To add controller to keyboard mappings I have added a wiki entry: https://www.consoletuner.com/wiki/index ... o_keyboard
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: HID Scripting help needed
wow ok
this works
I gotta play around with this.
now can I still do combo?
thanks for this btw I wouldn't have gotten far at all trying to modify t1 coding.
you are a star
this works
I gotta play around with this.
now can I still do combo?
thanks for this btw I wouldn't have gotten far at all trying to modify t1 coding.
you are a star
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
Re: HID Scripting help needed
You can still use combos, but instead of set_val you need to call mouse_set for mouse or key_set for keyboard.
Look up those function in the reference.. it has examples for all available functions:
https://www.consoletuner.com/wiki/index ... :mouse_set
https://www.consoletuner.com/wiki/index ... t2:key_set
Look up those function in the reference.. it has examples for all available functions:
https://www.consoletuner.com/wiki/index ... :mouse_set
https://www.consoletuner.com/wiki/index ... t2:key_set
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: HID Scripting help needed
oh got it so do the commands like "wait" "if" still work?
-
TT3000 - Master Sergeant
- Posts: 35
- Joined: Fri Nov 20, 2020 7:58 pm
44 posts
• Page 1 of 5 • 1, 2, 3, 4, 5
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 153 guests