Exemplo n.º 1
0
        static Task DoWorkAsyncInfiniteLoop()
        {
            while (true)
            {
                //System.Diagnostics.Process.
                if (System.Diagnostics.Debugger.IsAttached)
                {
                    // Initialize the LED SDK

                    if (!_ledInitialized)
                    {
                        _ledInitialized = LogitechGSDK.LogiLedInit();
                        if (!_ledInitialized)
                        {
                            Console.WriteLine("LogitechGSDK.LogiLedInit() failed.");
                        }
                        // Set all devices to Black
                        LogitechGSDK.LogiLedSetLighting(0, 0, 0);
                    }

                    LogitechGSDK.LogiLedSetTargetDevice(LogitechGSDK.LOGI_DEVICETYPE_ALL);

                    // Set some keys on keyboard
                    LogitechGSDK.LogiLedFlashSingleKey(keyboardNames.L, 0, 100, 100, 500, 1000);
                    LogitechGSDK.LogiLedFlashLighting(0, 100, 100, 100, 1000);
                    LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.O, 0, 100, 100);
                    //LogitechGSDK.LogiLedFlashSingleKey(keyboardNames.G, 0, 100, 100);
                    //LogitechGSDK.LogiLedSetLightingForKeyWithKeyName(keyboardNames.I, 0, 100, 100);
                    //LogitechGSDK.LogiLedPulseLighting(0, 100, 100, 100, 500);
                }
                else
                {
                    //if not running debugger, if sdk is up, shut it down
                    if (_ledInitialized)
                    {
                        LogitechGSDK.LogiLedShutdown();
                    }
                }
                System.Threading.Thread.Sleep(500);
            }
        }
Exemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKey(KeyCode.Mouse0))
        {
            //On mouse click set random color backlighting. In the monochrome backlighting devices it will change the brightness.
            System.Random random = new System.Random();
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            LogitechGSDK.LogiLedSetLighting(red, blue, green);
        }
        if (Input.GetKey(KeyCode.Mouse1))
        {
            byte[]        bitmap = new byte[LogitechGSDK.LOGI_LED_BITMAP_SIZE];
            System.Random random = new System.Random();
            for (int i = 0; i < LogitechGSDK.LOGI_LED_BITMAP_SIZE; i++)
            {
                bitmap[i] = (byte)random.Next(0, 255);
            }
            LogitechGSDK.LogiLedSetLightingFromBitmap(bitmap);
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            LogitechGSDK.LogiLedSetLightingForTargetZone(LogitechGSDK.DeviceType.Speaker, 0, red, blue, green);
        }
        if (Input.GetKey(KeyCode.F))
        {
            //Flashing preset effect
            System.Random random = new System.Random();
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            LogitechGSDK.LogiLedFlashLighting(red, blue, green, LogitechGSDK.LOGI_LED_DURATION_INFINITE, 200);
        }
        if (Input.GetKey(KeyCode.P))
        {
            //Pulsing preset effect
            System.Random random = new System.Random();
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            LogitechGSDK.LogiLedPulseLighting(red, blue, green, LogitechGSDK.LOGI_LED_DURATION_INFINITE, 100);
        }

        if (Input.GetKey(KeyCode.E))
        {
            //Pulsing preset effect
            System.Random random = new System.Random();
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            int finishRed   = random.Next(0, 100);
            int finishBlue  = random.Next(0, 100);
            int finishGreen = random.Next(0, 100);

            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F1, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);
            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F2, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);
            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F3, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);
            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F4, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);

            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            int duration = random.Next(50, 200);

            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F5, red, green, blue, 0, duration);
            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F6, red, green, blue, 0, duration);
            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F7, red, green, blue, 0, duration);
            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F8, red, green, blue, 0, duration);
        }
        if (Input.GetKey(KeyCode.S))
        {
            LogitechGSDK.LogiLedStopEffects();
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        print("Update before");
        LogitechGSDK.LogiLedSetLighting(red, green, blue);
        print("Update after");
        if (Input.GetKey(KeyCode.R))
        {
            curr_color = colors.R;
        }
        else if (Input.GetKey(KeyCode.G))
        {
            curr_color = colors.G;
        }
        else if (Input.GetKey(KeyCode.B))
        {
            curr_color = colors.B;
        }
        else if (Input.GetKey(KeyCode.KeypadPlus))
        {
            switch (curr_color)
            {
            case colors.R:
                goal_r = Mathf.Min((float)(goal_r + 0.02f), 1.0f);
                red    = (int)Mathf.Min((float)(red + 2), 100.0f);
                break;

            case colors.G:
                goal_g = Mathf.Min((float)(goal_g + 0.02f), 1.0f);
                green  = (int)Mathf.Min((float)(green + 2), 100.0f);
                break;

            case colors.B:
                goal_b = Mathf.Min((float)(goal_b + 0.02f), 1.0f);
                blue   = (int)Mathf.Min((float)(blue + 2), 100.0f);
                break;
            }
        }
        else if (Input.GetKey(KeyCode.KeypadMinus))
        {
            switch (curr_color)
            {
            case colors.R:
                goal_r = Mathf.Max((float)(goal_r - 0.02f), 0.0f);
                red    = (int)Mathf.Max((float)(red - 2), 0.0f);
                break;

            case colors.G:
                goal_g = Mathf.Max((float)(goal_g - 0.02f), 0.0f);
                green  = (int)Mathf.Max((float)(green - 2), 0.0f);
                break;

            case colors.B:
                goal_b = Mathf.Max((float)(goal_b - 0.02f), 0.0f);
                blue   = (int)Mathf.Max((float)(blue - 2), 0.0f);
                break;
            }
        }
        else if (Input.GetKey(KeyCode.E))
        {
            //Pulsing preset effect
            System.Random random = new System.Random();
            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            int finishRed   = random.Next(0, 100);
            int finishBlue  = random.Next(0, 100);
            int finishGreen = random.Next(0, 100);

            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F1, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);
            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F2, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);
            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F3, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);
            LogitechGSDK.LogiLedPulseSingleKey(LogitechGSDK.keyboardNames.F4, finishRed, finishGreen, finishBlue, red, green, blue, 100, true);

            red   = random.Next(0, 100);
            blue  = random.Next(0, 100);
            green = random.Next(0, 100);
            int duration = random.Next(50, 200);

            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F5, red, green, blue, 0, duration);
            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F6, red, green, blue, 0, duration);
            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F7, red, green, blue, 0, duration);
            LogitechGSDK.LogiLedFlashSingleKey(LogitechGSDK.keyboardNames.F8, red, green, blue, 0, duration);
        }
        else if (Input.GetKey(KeyCode.S))
        {
            red = 0; blue = 0; green = 0;
            LogitechGSDK.LogiLedStopEffects();
        }

        //    interpolate_color(ref curr_r, ref curr_g, ref curr_b, ref goal_r, ref goal_g, ref goal_b);

        Color        whateverColor      = new Color(curr_r, curr_g, curr_b, 1);
        MeshRenderer gameObjectRenderer = test.GetComponent <MeshRenderer>();
        Material     newMaterial        = new Material(Shader.Find("Standard"));

        newMaterial.color           = whateverColor;
        gameObjectRenderer.material = newMaterial;
    }