Page 1 of 1

Titan 2 - Logitech Mouse/Keyboard scripting (AntiRecoil)

PostPosted: Tue Nov 20, 2018 12:39 pm
by Shaag7
Hey All,

I was using XIM4 for years together with T1/T2 but latest XIM Apex made me to stay just with T2 for Mouse/Keyboard gameplay.

I was using T2 scripting with XIM4 for all games but with direct T2 M/KB capture I left most of the T2 scripting and I tried Logitech LUA scripting on my mouse.

I'll add brief guide how to add scripting to your Logitech device (let it be headset or mouse). Simply rightclick on your logitech profile and click on Scripting. Paste code bellow and play with it to fit your play style/weapons.

As I rly like our Titan community, there is my script which I use for Battlefield series.
It offers two stages configurable Anti-Recoil (standard is with scroll-lock and for bipod u have to have scroll-lock on and also caps-lock on). Adjust can be done via holding left alt and pressing 4th / 5th mouse button (side buttons).

I feel this as the best way how to deal with scripting right now as it is just in the input device driver and T2 offers awesome speed in direct capture communication.

You can adjust dynamic Anti-recoil by usiong wmulti1 parameter. It will dynamicaly inrease/decrease antirecoil strength which is rly usefull for Battlefield LMGs.

Let me know if you need any advice or customization.

Code: Select all
EnablePrimaryMouseButtonEvents (true)
local step = 12.0
local wait = 32.0
local wmulti1 = 1
 
 
local wait1
local step1
 
 
function OnEvent(event, arg)   
      if IsKeyLockOn("scrolllock")and not IsModifierPressed('lshift') then
          if not IsKeyLockOn("capslock")then
                if IsMouseButtonPressed(1) then
                        wait1 = wait
                        OutputLogMessage("step1 = %s, wait1 = %s\n", step, wait1)
                            repeat                           
                                MoveMouseRelative(0,step)
                                --wait1 = wait1 * (wmulti1 + rng3) * (wmulti2 +rng3)
                                wait1 = wait1 * (wmulti1)
                                Sleep(wait1)
                                --OutputLogMessage("step1 = %s, wait1 = %s\n", step, wait1)
                        until not IsMouseButtonPressed(1)
                end             
                if IsMouseButtonPressed(3) then
                    repeat
                        if IsMouseButtonPressed(1) then
                        wait1 = wait
                        OutputLogMessage("step1 = %s, wait1 = %s\n", step, wait1)
                            repeat                           
                                MoveMouseRelative(0,step)
                                --wait1 = wait1 * (wmulti1 + rng3) * (wmulti2 +rng3)
                                wait1 = wait1 * (wmulti1)
                                Sleep(wait1)
                                --OutputLogMessage("step1 = %s, wait1 = %s\n", step, wait1)
                            until not IsMouseButtonPressed(1)
                        end
                    until not IsMouseButtonPressed(3)                       
                end
            end
 
        if IsKeyLockOn("capslock")then
                        if IsMouseButtonPressed(1) then
 
--                        wait1 = wait
                        wait1 = 5*wait
                        step1 = step
                                    OutputLogMessage("event = %s, arg = %d, step = %s\n", event, arg, step)
 
                            repeat                           
                                MoveMouseRelative(0,step1)
                                --wait1 = wait1 * (wmulti1 + rng3) * (wmulti2 +rng3)
                                wait1 = wait1 * (wmulti1)
                                Sleep(wait1)
                                OutputLogMessage("step1 = %s, wait1 = %s\n", step, wait)
                            until not IsMouseButtonPressed(1)
                        end           
                if IsMouseButtonPressed(3) then
                    repeat
                        if IsMouseButtonPressed(1) then
                        wait1 = 5*wait
                        step1 = step                       
--                        step1 = step/6
                                    OutputLogMessage("event = %s, arg = %d, step = %s\n", event, arg, step)
 
                            repeat                           
                                MoveMouseRelative(0,step1)
                                --wait1 = wait1 * (wmulti1 + rng3) * (wmulti2 +rng3)
                                wait1 = wait1 * (wmulti1)
                                Sleep(wait1)
                                OutputLogMessage("step1 = %s, wait1 = %s\n", step, wait1)
                            until not IsMouseButtonPressed(1)
                        end
                    until not IsMouseButtonPressed(3)
                end
 
        end
    end
    if IsModifierPressed('lalt')then
                if IsMouseButtonPressed(5) then
                    step = step - 1
                                    OutputLogMessage("event = %s, arg = %d, step = %s\n", event, arg, step)
                end
                if IsMouseButtonPressed(4) then
                    step = step + 1
                                    OutputLogMessage("event = %s, arg = %d, step = %s\n", event, arg, step)
                end   
    end
end
 
 

Re: Titan 2 - Logitech Mouse/Keyboard scripting

PostPosted: Wed Nov 21, 2018 9:04 am
by J2Kbr
Thank you for sharing your experience and finding with Logitech LUA.

For this to work you need use Gtuner's KMG Capture right? I mean, the mouse can't run the script by itself, right?

Re: Titan 2 - Logitech Mouse/Keyboard scripting

PostPosted: Wed Nov 21, 2018 9:18 am
by Shaag7
J2Kbr wrote:Thank you for sharing your experience and finding with Logitech LUA.

For this to work you need use Gtuner's KMG Capture right? I mean, the mouse can't run the script by itself, right?


LUA script is ran by Logitech Gaming Software and it cannot be stored in mouse itself.
So Gtuner's KMG Capture is really needed.

Re: Titan 2 - Logitech Mouse/Keyboard scripting (AntiRecoil)

PostPosted: Sun Aug 11, 2019 1:26 am
by Gjin Yuko
Whats the correct setup to use it like this?

how can i use the KMG Capture and my Xim Apex at the same time?

And also can i then use AHK Scipts and Scripts on the Logitech Gaming Software like anti recoil on my Xim Apex
without useing the Titan Two for Scripts?

Thanks

Re: Titan 2 - Logitech Mouse/Keyboard scripting (AntiRecoil)

PostPosted: Thu Sep 05, 2019 10:51 pm
by Gjin Yuko
COuld you maybe add rapidfire to that Code?

Re: Titan 2 - Logitech Mouse/Keyboard scripting (AntiRecoil)

PostPosted: Fri Sep 06, 2019 9:53 am
by J2Kbr
Gjin Yuko wrote:how can i use the KMG Capture and my Xim Apex at the same time? And also can i then use AHK Scipts and Scripts on the Logitech Gaming Software like anti recoil on my Xim Apex without useing the Titan Two for Scripts?

This may be possible. For that you will need configure the Titan Two to output as USB Multi HID Interface, connect the Titan Two output to XIM and XIM to the console. You will also need run a script to forward the keyboard and mouse inputs, coming from Gtuner's KMG Capture, to XIM. I saw in other topic you have already found such script.

Re: Titan 2 - Logitech Mouse/Keyboard scripting (AntiRecoil)

PostPosted: Fri Sep 06, 2019 9:38 pm
by Gjin Yuko
Yes J2 but it doesnt work for me because i cant look around withou useing this script
Code: Select all
init {
  mousemapping();
}
 
main {
  mouse_passthru();
  key_passthru();
}


I just want this with rapidfire nothing more

Re: Titan 2 - Logitech Mouse/Keyboard scripting (AntiRecoil)

PostPosted: Fri Sep 06, 2019 9:52 pm
by J2Kbr
Please note that regular Gamepacks and scripts will not work when the device is working in this mode of operation. You can, however, extend the above script to add any functionality using the keyboard and mouse dedicated GPC functions such as key_set() and mouse_set(). Unfortunately, I am not in my main computer at the moment to send you an example of that. If you can wait, I will be able post here an example by Sunday night/ Monday morning. thanks.

Re: Titan 2 - Logitech Mouse/Keyboard scripting (AntiRecoil)

PostPosted: Fri Sep 06, 2019 10:01 pm
by Gjin Yuko
I will do that tanks J2