コード例 #1
0
        public MacroActions(HueRequests hueReq)
        {
            // Initialize the LED SDK
            bool LedInitialized = LogitechLEDGSDK.LogiLedInitWithName("logitech_rgb");

            Thread.Sleep(initDelay);
            if (!LedInitialized)
            {
                Console.WriteLine("LogitechGSDK.LogiLedInit() failed.");
            }
            Console.WriteLine("LED SDK Initialized");
            LogitechLEDGSDK.LogiLedSetTargetDevice(LogitechLEDGSDK.LOGI_DEVICETYPE_ALL);

            // Set all devices to Black
            LogitechLEDGSDK.LogiLedSetLighting(0, 0, 0);
            // Initialize requests class
            requests = hueReq;

            // Initialize the Macro SDK with callback implementation
            LogitechMacroGSDK.logiGkeyCB cbInstance = new LogitechMacroGSDK.logiGkeyCB((this.GkeySDKCallback));
            LogitechMacroGSDK.LogiGkeyInitWithoutContext(cbInstance);

            // Get the curr state of the lights
            LightState state1 = requests.GetStateAsync(ID1).Result;
            LightState state2 = requests.GetStateAsync(ID2).Result;

            // Mimic the lights with the RGB keyboard buttons
            GKeyMimicLightState(gKeyList.ElementAt(0).Value, state1);
            GKeyMimicLightState(gKeyList.ElementAt(1).Value, state2);
        }
コード例 #2
0
        public void GKeyMimicLightState(keyboardNames key, LightState state)
        {
            if (state != null && state.on)
            {
                // Scale hue, sat, brightness
                double H = state.hue * (360.0 / 65535);
                double S = state.sat * (1.0 / 254);
                double L = state.bri * (1.0 / 254);

                LogitechLEDGSDK.LogiLedSetLightingForKeyWithKeyName(key,
                                                                    HueHSLtoRGBPercent(H, S, L, (int)RBGnVal.R),
                                                                    HueHSLtoRGBPercent(H, S, L, (int)RBGnVal.G),
                                                                    HueHSLtoRGBPercent(H, S, L, (int)RBGnVal.B));
            }
            else
            {
                LogitechLEDGSDK.LogiLedSetLightingForKeyWithKeyName(key, 0, 0, 0);
            }
        }