Cool logitech G19 mod!

Soldato
Joined
8 Sep 2003
Posts
23,155
Location
Was 150 yds from OCUK - now 0.5 mile; they moved
Hey guys

Thought I would share this for anyone with a G19 keyboard. (You can speed up or slow down the pulse too)


To enable this you just load the G key profile software. Set the profile you want to colour pulse. Go to the Edit Menu then script editor.

Add the following code, and save. Then hold down right ctrl button and select the M1 button. (Holding down right shift and pressing left shift then speeds up pulse, and holding right shift and pressing the left crtl button slows it down)

Code:
               ---------------
    ----------||  CONTROLS:  ||--------------
    --         ---------------             --
    --                                     --
    --                                     --
    --  R-Ctrl +                           --
    --      M1      -   Cycle R<>G         --
    --      M2      -   Cycle G<>B         --
    --      M3      -   Cycle B<>R         --
    --                                     --
    --  R-Shift +                          --
    --      M1      -   Cycle RGB          --
    --      M2      -   Cycle RBG          --
    --      M3      -   Colour Picker      --
    --                                     --
    --  While Cycling:                     --
    --  R-Shift +                          --
    --      L-Shift -   Faster             --
    --      L-Ctrl  -   Slower             --
    --                                     --
    --  L-Shift +                          --
    --      R-Ctrl  -   Toggle LHC mode    --
    --                  (G19/G13 sync)     --
    --                                     --
    --  While Picking:                     --
    --  R-Shift/R-Ctrl (brighter/darker) + --
    --      L-Shift -   Red                --
    --      L-Ctrl  -   Green              --
    --      L-Alt   -   Blue               --
    --                                     --
    --  Press any other MKey to stop       --
    --  cycling or picking, and keep       --
    --  selected colour.                   --
    --                                     --
    --                                     --
    -----------------------------------------

--  **Cycle rate:
--  **(default = 150; red-to-red in ~23secs)
--  **(always set lower than mrate)
rate = 150

--  **Minimum delay:
--  **(default = 600; red-to-red in ~1.5mins)
--  **(higher is slower)
mrate = 600

--  **Static (RGB) Colour:
--  **(default = 140, 255, 150; white on my G19)
R, G, B = 140, 255, 150

function OnEvent(event,arg)

--    Cycle or set custom colour:
    if (event=="M_PRESSED") and IsModifierPressed("rshift") then

--        Cycle RGB:
        if arg==1 then Cycle(0, 5, 0, 1, arg)

--        Cycle RBG:
        elseif arg==2 then Cycle(255, -5, 2, -1, arg)

        else

--            Set custom static colour.  Right Shift/Ctrl(+/-) plus Left-Shift/Ctrl/Alt(R/G/B).
            run=1
            while run~=null do
                if IsModifierPressed("rshift") then
                    if IsModifierPressed("lshift") then R=R+.1
                        if R>255 then R=255; end
                    end
                    if IsModifierPressed("lctrl") then G=G+.1 
                        if G>255 then G=255; end
                    end
                    if IsModifierPressed("lalt") then B=B+.1
                        if B>255 then B=255; end
                    end
                elseif IsModifierPressed("rctrl") then
                    if IsModifierPressed("lshift") then R=R-.1
                        if R<0 then R=0; end
                    end
                    if IsModifierPressed("lctrl") then G=G-.1
                        if G<0 then G=0; end
                    end
                    if IsModifierPressed("lalt") then B=B-.1
                        if B<0 then B=0; end
                    end
                end
                SetBacklightColor(math.floor(R),math.floor(G),math.floor(B))
                if (IsModifierPressed("lalt") and IsModifierPressed("ralt")) or GetMKeyState()~=3 then run=null; break; end
            end

--            All done?  Re-set new static colour after profiler applies default one.
            Sleep(350)
            SetBacklightColor(math.floor(R),math.floor(G),math.floor(B))
        end

    end

--    Reciprocating fade; Red <> Green or Green <> Blue or Blue <> Red:
    if (event=="M_PRESSED") and IsModifierPressed("rctrl") then Fade(arg); end

end

function Fade(ks)
    fs=0; fj=5; fd=0; run=1
    while run~=null do

--        Ramp colour value 0-255 (and back), or full-off to full-on.
        for col = fs, 255-fs, fj do

--            Call for delay before next colour change.
            Dlay(ks)

            if ks==1 then SetBacklightColor(255-col,col,0,"kb"); if lmode~="1" then SetBacklightColor(255-col,col,0,"lhc") else SetBacklightColor(col,255-col,0,"lhc") end
            elseif ks==2 then SetBacklightColor(0,255-col,col,"kb"); if lmode~="1" then SetBacklightColor(0,255-col,col,"lhc") else SetBacklightColor(0,col,255-col,"lhc") end
            elseif ks==3 then SetBacklightColor(col,0,255-col,"kb"); if lmode~="1" then SetBacklightColor(col,0,255-col,"lhc") else SetBacklightColor(255-col,0,col,"lhc") end
            end

--            Skip out of ramps...
            if run==null then break; end

        end

--        Change direction...
        if fd==0 then fd=1; fs=255; fj=-5
        else fd=0; fs=0; fj=5

--        Skip out of reciprocating fade...
        if run==null then break; end
        end
    end
end

function Cycle(cs, cj, rs, rj, ks)
    run=1
    while run~=null do

--        Loop through each of R, G, and B.
        for rgb = rs, 2-rs, rj do

--            Ramp colour value 0-255, or full-off to full-on.
            for col = cs, 255-cs, cj do

--                Call for delay before next colour change.
                Dlay(ks)

                if rgb==0 then SetBacklightColor(255-col,col,0,"kb"); if lmode~="1" then SetBacklightColor(255-col,col,0,"lhc") else SetBacklightColor(col,0,255-col,"lhc") end
                elseif rgb==1 then SetBacklightColor(0,255-col,col,"kb"); if lmode~="1" then SetBacklightColor(0,255-col,col,"lhc") else SetBacklightColor(255-col,col,0,"lhc") end
                elseif rgb==2 then SetBacklightColor(col,0,255-col,"kb"); if lmode~="1" then SetBacklightColor(col,0,255-col,"lhc") else SetBacklightColor(0,255-col,col,"lhc") end
                end

                if run==null then break; end
            end

--            Skip out of RGB loops...
            if run==null then break; end
        end

    end
end

function Dlay(ks)
--    Throttle controls during sleep.
    for z = 1, rate, 1 do

--        Faster...
        if IsModifierPressed("lshift") and IsModifierPressed("rshift") then rate=(rate-(mrate/6000))
            if rate<2 then rate=2
                if limit~=0 then limit=0; OutputLCDMessage("\n"..(string.rep(" ",37)).."MAXIMUM SPEED!!!", 3000); end
            end
--            Increments for display...
            dup=math.floor((60/mrate)*rate)
            if nup~=dup then Disp(); end

--        Slower...
        elseif IsModifierPressed("lctrl") and IsModifierPressed("rshift") then rate=(rate+(mrate/6000))
            if rate>mrate then rate=mrate; end
--            Increments for display...
            dup=math.floor((60/mrate)*rate)
            if nup~=dup or limit~=1 then Disp(); limit=1; end
        end

--        ~333ms control delay...
        if tt==null then tt=0 elseif tt<334 then tt=tt+1 end
        if tt>333 and IsModifierPressed("rctrl") and IsModifierPressed("lshift") then tt=0
            if lmode~="1" then lmode="1" else lmode="0" end
        end

--        Don't wait for delay if another M-key is pressed.
        if GetMKeyState()~=ks or (IsModifierPressed("lalt") and IsModifierPressed("ralt")) then run=null; break; end
        Sleep(1)

    end
end

function Disp()
--    Draw an incremental slider to G19 LCD output.  It grabs/drops focus rapidly.  :S
    text="\n\n\n\n\n\n        <["..(string.rep("||",60-dup)).."|||"..(string.rep("-",dup)).."]>"
    ClearLCD(); OutputLCDMessage(text, 2000)
    nup=dup
end

The controls are explained on the first few lines of the coding you have just added.
 
I do like that effect, is this mod only limited to the G19? Can it be used on other keyboards? IMO the G19 is waay too overpriced
 
Hi, sorry for bringing this back up, but does anyone know how I can change the code so that it cycles through a spectrum at roughly the same speed as my mamba docking station?
 
Back
Top Bottom