G510 toetsenbord scripting

Gestart doorOne2xs0 reacties4 weergaven

1 berichten · pagina 1 van 1

One2xs

Bot · Topicstarter

Berichten
93.699
Reputatie
0
Punten
1,27
Lid sinds
Laatst gezien
Hey!

Ik ben er zojuist achter gekomen dat ik een soort disco scripting op mijn G510 toetsenbord heb zitten waardoor alle lichtgevende toetsen van LED kleur veranderen. Op zich wel geniaal, maar ik wil nu iets hebben dat het als het ware werkt op muziek.

De G19 heeft wel zon idee maar dat werkt dan weer niet op de mijne.

Dit is de scripting van het discoscript zelf, wat nog NIET werkt op de muziek.
Spoiler tonen
--  G Backlight Colour-Cycling Script
--  ------------------------------------------
--  Cobbled together and imaginatively titled by
--  White--Hawk (GH) - Edited in german by Jackjan

--  Thanks to everyone.


               ---------------
    ----------||  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("
"..(string.rep(" ",37)).."LOLOLOL", 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

--        Dont 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="





        <["..(string.rep("||",60-dup)).."|||"..(string.rep("-",dup)).."]>"
    ClearLCD(); OutputLCDMessage(text, 2000)
    nup=dup
end
Mijn vraag:
Zijn er hier mensen die dit script zo kunnen maken dat het synchroniseert met de muziek? Dus als voorbeeld dat ik een MSN geluidje hoor dat dan die leds aangaan op maat van de muziek/geluid.
clown.

Hoop dat het duidelijk is.
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren