Reply
Logi Nu
GravityDK
Posts: 3
Registered: ‎08-12-2010

How to disable diagonal movement on G13 joystick?

[ Edited ]

Hi all,

after searching here and google extensively, I've not been able to find the answer.

 

I would like to disable the diagonal movements on the G13 joystick, so the result is I can only use the NESW directions. This is so I can bind forward/backward and strafe left/right without the diagonal sending a combination of, eg,  forward and strafe left.

 

I think it's done via scripting (from the few inconclusive posts I found), but I can't work out how to detect if both buttons are pressed at the same then, and then to do nothing.

 

Related posts 1 and 2.

 

Lastly, in case it's of help to others I have some powerpoint/pdf technical diagrams of the G13 which I've printed out, to help me remember them. Download from here.

kgober
Posts: 5,722
Kudos: 772
Solutions: 470
Registered: ‎05-28-2009

Re: How to disable diagonal movement on G13 joystick?

yes, it's done via scripting:

 

function OnEvent(event, arg, family)
    if event == "G_PRESSED" and arg == 26 then
        if not kLR then PressKey("w"); kLR = true end
        gUp = true
    elseif event == "G_PRESSED" and arg == 27 then
        if not kUD then PressKey("d"); kUD = true end
        gRt = true
    elseif event == "G_PRESSED" and arg == 28 then
        if not kLR then PressKey("s"); kLR = true end
        gDn = true
    elseif event == "G_PRESSED" and arg == 29 then
        if not kUD then PressKey("a"); kUD = true end
        gLf = true
    elseif event == "G_RELEASED" and arg == 26 then
        if kUD then ReleaseKey("w"); kUD = false end
        gUp = false
        if gLf and not kLR then PressKey("a"); kLR = true end
        if gRt and not kLR then PressKey("d"); kLR = true end
    elseif event == "G_RELEASED" and arg == 27 then
        if kLR then ReleaseKey("d"); kLR = false end
        gRt = false
        if gUp and not kUD then PressKey("w"); kUD = true end
        if gDn and not kUD then PressKey("s"); kUD = true end
    elseif event == "G_RELEASED" and arg == 28 then
        if kUD then ReleaseKey("s"); kUD = false end
        gDn = false
        if gLf and not kLR then PressKey("a"); kLR = true end
        if gRt and not kLR then PressKey("d"); kLR = true end
    elseif event == "G_RELEASED" and arg == 29 then
        if kLR then ReleaseKey("a"); kLR = false end
        gLf = false
        if gUp and not kUD then PressKey("w"); kUD = true end
        if gDn and not kUD then PressKey("s"); kUD = true end
    end
end

 

 

this script binds the thumbstick to the WASD keys, with diagonals disabled.  if you want to bind the thumbstick to other keys, change all the "w", "a", "s" and "d" values with the keys you want instead.

 

untested, but it should work.  don't forget to assign the thumbstick directions to the 'Script' action in Key Profiler, otherwise the script won't be invoked for them.

 

-ken

________________________________
I do not work for Logitech. I'm just a user.
Logi Nu
GravityDK
Posts: 3
Registered: ‎08-12-2010

Re: How to disable diagonal movement on G13 joystick?

[ Edited ]

Thank you.

I found it made my character run non-stop in a line and would not work intermittently, but now that you've provided a code base I hope I can bugfix it. 

Logi Nu
GravityDK
Posts: 3
Registered: ‎08-12-2010

Re: How to disable diagonal movement on G13 joystick?

Ah, fixed it. You'd just transposed kUD and kLR.

Here's the working version. 

 

I'm sure there will be other people who want this, thanks Ken!

 

 

function OnEvent(event, arg, family)
    if event == "G_PRESSED" and arg == 26 then
        if not kLR then PressKey("w"); kUD = true end
        gUp = true
    elseif event == "G_PRESSED" and arg == 27 then
        if not kUD then PressKey("d"); kLR = true end
        gRt = true
    elseif event == "G_PRESSED" and arg == 28 then
        if not kLR then PressKey("s"); kUD = true end
        gDn = true
    elseif event == "G_PRESSED" and arg == 29 then
        if not kUD then PressKey("a"); kLR = true end
        gLf = true
    elseif event == "G_RELEASED" and arg == 26 then
        if kUD then ReleaseKey("w"); kUD = false end
        gUp = false
        if gLf and not kLR then PressKey("a"); kLR = true end
        if gRt and not kLR then PressKey("d"); kLR = true end
    elseif event == "G_RELEASED" and arg == 27 then
        if kLR then ReleaseKey("d"); kLR = false end
        gRt = false
        if gUp and not kUD then PressKey("w"); kUD = true end
        if gDn and not kUD then PressKey("s"); kUD = true end
    elseif event == "G_RELEASED" and arg == 28 then
        if kUD then ReleaseKey("s"); kUD = false end
        gDn = false
        if gLf and not kLR then PressKey("a"); kLR = true end
        if gRt and not kLR then PressKey("d"); kLR = true end
    elseif event == "G_RELEASED" and arg == 29 then
        if kLR then ReleaseKey("a"); kLR = false end
        gLf = false
        if gUp and not kUD then PressKey("w"); kUD = true end
        if gDn and not kUD then PressKey("s"); kUD = true end
    end
end

 

 

kgober
Posts: 5,722
Kudos: 772
Solutions: 470
Registered: ‎05-28-2009

Re: How to disable diagonal movement on G13 joystick?

I'm glad to hear you got it fixed.  thanks for sharing the correction; I'm sure this topic will come up again.

 

-ken

________________________________
I do not work for Logitech. I'm just a user.