Beispiel #1
0
        public async Task <IChroma> CreateAsync()
        {
            var chromaApi = ChromaApi ?? new NativeApi();
            var res       = await ColoreProvider.CreateAsync(ChromaAppInfo, chromaApi).ConfigureAwait(false);

            return(res);
        }
Beispiel #2
0
        private async void StartLogic(TraySettings settings)
        {
            //Initializing Chroma SDK
            IChroma chromaInstance = await ColoreProvider.CreateNativeAsync();

            AppInfo appInfo = new AppInfo(
                "Ambilight for Razer devices",
                "Shows an ambilight effect on your Razer Chroma devices",
                "Nico Jeske",
                "*****@*****.**",
                new[]
            {
                ApiDeviceType.Headset,
                ApiDeviceType.Keyboard,
                ApiDeviceType.Keypad,
                ApiDeviceType.Mouse,
                ApiDeviceType.Mousepad,
                ApiDeviceType.ChromaLink
            },
                Category.Application);
            await chromaInstance.InitializeAsync(appInfo);

            _keyboardLogic = new KeyboardLogic(settings, chromaInstance);
            _mousePadLogic = new MousePadLogic(settings, chromaInstance);
            _mouseLogic    = new MouseLogic(settings, chromaInstance);
            _linkLogic     = new LinkLogic(settings, chromaInstance);
            _headsetLogic  = new HeadsetLogic(settings, chromaInstance);
            _keypadLogic   = new KeypadLogic(settings, chromaInstance);

            DesktopDuplicatorReader reader = new DesktopDuplicatorReader(this, settings);
        }
Beispiel #3
0
        private async void typingmode_button_Click(object sender, EventArgs e)
        {
            var chroma = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(ColoreColor.Black);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.White, ColoreKey.A, ColoreKey.S, ColoreKey.D, ColoreKey.F, ColoreKey.J, ColoreKey.K, ColoreKey.L, ColoreKey.OemSemicolon);
        }
Beispiel #4
0
        private async void gamingmode_button_Click(object sender, EventArgs e)
        {
            var chroma = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(ColoreColor.Black);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.Red, ColoreKey.W, ColoreKey.A, ColoreKey.S, ColoreKey.D);
        }
Beispiel #5
0
        private async void laptopmode_button_Click(object sender, EventArgs e)
        {
            var chroma = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(ColoreColor.Black);

            await chroma.SetAllAsync(ColoreColor.White);
        }
Beispiel #6
0
        private async void csgo_gamemode_Click(object sender, EventArgs e)
        {
            var chroma = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(ColoreColor.Black);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.Green, ColoreKey.W, ColoreKey.A, ColoreKey.S, ColoreKey.D);
        }
Beispiel #7
0
        // Main Window Elements

        private async void blue_color_Click(object sender, EventArgs e)
        {
            var chroma = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(ColoreColor.Black);

            await chroma.SetAllAsync(ColoreColor.Blue);
        }
Beispiel #8
0
        private async void reset_button_Click(object sender, EventArgs e)
        {
            var chroma = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(ColoreColor.Black);

            await chroma.UninitializeAsync();
        }
Beispiel #9
0
        private async void pink_button_Click(object sender, EventArgs e)
        {
            var chroma = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(ColoreColor.Black);

            await chroma.SetAllAsync(ColoreColor.HotPink);
        }
Beispiel #10
0
        static async Task <IChroma> GetInstance()
        {
            Console.WriteLine("Creating a new chroma instance...");
            var chroma = await ColoreProvider.CreateNativeAsync();

            await Task.Delay(1000); // Used to be 500, but apparently the razer API got slower or something.

            return(chroma);
        }
        private static async void StartRestApp()
        {
            // When creating a Chroma instance using the REST API backend, you need to supply the SDK with information about your app.
            var appInfo = new AppInfo("Another App", "Another awesome Chroma app!", "Test Test", "*****@*****.**", Category.Application);

            IChroma chroma = await ColoreProvider.CreateRestAsync(appInfo);

            Console.WriteLine(chroma.Initialized);
        }
        public async Task ShouldCallUninitializeOnClear()
        {
            var apiMock = new Mock <IChromaApi>();
            await ColoreProvider.CreateAsync(TestAppInfo, apiMock.Object);

            await ColoreProvider.CreateAsync(TestAppInfo, apiMock.Object);

            apiMock.Verify(a => a.UninitializeAsync(), Times.Once);
        }
Beispiel #13
0
        static async void ambiantColor()
        {
            KeyboardController keyboard       = new KeyboardController();
            IChroma            ChromaInstance = await ColoreProvider.CreateNativeAsync();

            while (true)
            {
                ScreenShotController screen = new ScreenShotController();
                keyboard.changeKeyboardColor(screen.GetScreenAverageColor());
                keyboard.applyKeyboardColor(ChromaInstance);
            }
        }
Beispiel #14
0
        private async void phasmo_gamemode_Click(object sender, EventArgs e)
        {
            var chroma = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(ColoreColor.Black);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.Green, ColoreKey.W, ColoreKey.A, ColoreKey.S, ColoreKey.D, ColoreKey.LeftShift, ColoreKey.C);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.White, ColoreKey.V, ColoreKey.B);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.Red, ColoreKey.Q, ColoreKey.J, ColoreKey.E, ColoreKey.G, ColoreKey.F, ColoreKey.T);
        }
Beispiel #15
0
        private static async void ChromaUpdateAsync()
        {
            AllKeys.Remove(Key.Invalid); // no idea why this key is inside the enum?
            var opacity      = 0.5;
            var keyboardGrid = KeyboardCustom.Create();
            var mouseGrid    = MouseCustom.Create();
            var chroma       = await ColoreProvider.CreateNativeAsync();

            var bg_playing      = new ColoreColor((byte)Properties.Settings.Default.Background_Playing.R, (byte)Properties.Settings.Default.Background_Playing.G, (byte)Properties.Settings.Default.Background_Playing.B);
            var bg_pause        = new ColoreColor((byte)Properties.Settings.Default.Background_Pause.R, (byte)Properties.Settings.Default.Background_Pause.G, (byte)Properties.Settings.Default.Background_Pause.B);
            var pos_fore        = new ColoreColor((byte)Properties.Settings.Default.Position_Foreground.R, (byte)Properties.Settings.Default.Position_Foreground.G, (byte)Properties.Settings.Default.Position_Foreground.B);
            var pos_back        = new ColoreColor((byte)Properties.Settings.Default.Position_Background.R, (byte)Properties.Settings.Default.Position_Background.G, (byte)Properties.Settings.Default.Position_Background.B);
            var vol             = new ColoreColor((byte)Properties.Settings.Default.Volume.R, (byte)Properties.Settings.Default.Volume.G, (byte)Properties.Settings.Default.Volume.B);
            var backgroundColor = ColoreColor.Black;

            while (true)
            {
                var backgroundDetermine = player.PlayerEngine.PlayerState == ITPlayerState.ITPlayerStatePlaying ? bg_playing : bg_pause;
                backgroundColor = BackgroundColorDecision(ref opacity, Properties.Settings.Default.AdaptiveDensity ? ActiveDevice.AudioMeterInformation.MasterPeakValue : 1, backgroundDetermine);// (10 - Properties.Settings.Default.RefreshRate) + 1, backgroundDetermine);
                ColorsVariableDecision(ref bg_playing, ref bg_pause, ref pos_fore, ref pos_back, ref vol);
                try
                {
                    var currentTime = TimeSpan.FromSeconds(player.PlayerEngine.PlayerPosition);
                    var position    = player.CalculatedPosition;
                    keyboardGrid.Set(backgroundColor);
                    mouseGrid.Set(backgroundColor);
                    SetIndividualKeys(ref keyboardGrid);
                    SetPlayingTime(ref keyboardGrid, currentTime, ColoreColor.Red, ThisIsWhatCalledOrange, ColoreColor.Yellow);
                    SetPlayingPosition(ref keyboardGrid, position, FunctionKeys, pos_fore, pos_back);
                    SetPlayingPosition(ref mouseGrid, position, Properties.Settings.Default.ReverseLEDRender ? RightStrip : LeftStrip, pos_fore, pos_back);
                    SetVolumeScale(ref mouseGrid, Properties.Settings.Default.ReverseLEDRender ? LeftStrip : RightStrip, vol);
                    SetVolumeScale(ref keyboardGrid, DPadKeys, vol);
                }
                catch
                {
                    continue; //in case the music is not playing yet, the position is unobtainable.
                }
                finally
                {
                    await chroma.Keyboard.SetCustomAsync(keyboardGrid);

                    await chroma.Mouse.SetGridAsync(mouseGrid);

                    await chroma.Headset.SetAllAsync(backgroundColor);

                    await chroma.Mousepad.SetAllAsync(backgroundColor);

                    Thread.Sleep(500 * (Properties.Settings.Default.AdaptiveDensity ? Properties.Settings.Default.RefreshRate / 10 : 1));
                }
            }
        }
Beispiel #16
0
        private void initChromaSkd()
        {
            var t = ColoreProvider.CreateNativeAsync();

            t.Wait();
            this.chroma = t.Result;

            this.muted = KeyboardCustom.Create();
            this.muted.Set(Colore.Data.Color.Red);
            this.muted[Key.Macro4] = Colore.Data.Color.Green;

            this.unmuted = KeyboardCustom.Create();
            this.unmuted.Set(Colore.Data.Color.Green);
            this.unmuted[Key.Macro4] = Colore.Data.Color.Red;
        }
Beispiel #17
0
        private async void amogus_gamemode_Click(object sender, EventArgs e) // LOL
        {
            var chroma = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(ColoreColor.Black);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.Green, ColoreKey.W, ColoreKey.A, ColoreKey.S, ColoreKey.D);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.Red, ColoreKey.R, ColoreKey.Q);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.White, ColoreKey.Escape);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.Pink, ColoreKey.E);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.FromRgb(0x964B00), ColoreKey.Tab);
        }
Beispiel #18
0
        private async void minecraft_gamemode_Click(object sender, EventArgs e)
        {
            var chroma = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(ColoreColor.Black);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.Green, ColoreKey.D1, ColoreKey.D2, ColoreKey.D3, ColoreKey.D4, ColoreKey.D5, ColoreKey.D6, ColoreKey.D7, ColoreKey.D8, ColoreKey.D9, ColoreKey.D0);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.Green, ColoreKey.W, ColoreKey.A, ColoreKey.S, ColoreKey.D);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.FromRgb(0x964B00), ColoreKey.Q);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.FromRgb(0x964B00), ColoreKey.E);

            await chroma.Keyboard.SetKeysAsync(ColoreColor.Green, ColoreKey.LeftShift);
        }
Beispiel #19
0
        void init()
        {
            // User Settings

            XmlDocument xmlConfig = new XmlDocument();

            xmlConfig.Load(AppDomain.CurrentDomain.BaseDirectory + "config.xml");
            var mqttConfig = xmlConfig["RazerChromaMqtt"]["MQTT"];
            var v          = mqttConfig["MqttUser"].InnerText.Trim();

            mqttHost     = mqttConfig["MqttHost"].InnerText.Trim();
            mqttPort     = mqttConfig["MqttPort"].InnerText.Trim();
            mqttUser     = mqttConfig["MqttUser"].InnerText.Trim();
            mqttPw       = mqttConfig["MqttPw"].InnerText.Trim();
            mqttPreTopic = mqttConfig["MqttPreTopic"].InnerText.Trim();

            if (mqttUser == "" || mqttPw == "")
            {
                mqttUser = mqttPw = null;
            }


            // MQTT
            mqttClient                 = MqttClientFactory.CreateClient($"tcp://{mqttHost}:{mqttPort}", "chroma", mqttUser, mqttPw);
            mqttClient.Connected      += MqttC_Connected;
            mqttClient.ConnectionLost += MqttC_ConnectionLost;
            mqttClient.PublishArrived += MqttC_PublishArrived;

            MqttAppender.mqttClient   = mqttClient;
            MqttAppender.mqttPreTopic = mqttPreTopic;

            try
            {
                mqttClient.Connect(mqttPreTopic + "state", QoS.BestEfforts, new MqttPayload("offline"), false);
            }
            catch (Exception e)
            {
                log.Error("Mqtt connect eror : " + e.Message);
                base.Stop();
            }


            Task <IChroma> connectChroma = ColoreProvider.CreateNativeAsync();

            connectChroma.Wait();
            chroma = connectChroma.Result;
        }
Beispiel #20
0
        public static async void StartListener(ChannelReader <SpotifySongDTO> reader)
        {
            _ = Task.Run(async delegate
            {
                var chroma = await ColoreProvider.CreateNativeAsync();

                while (true)
                {
                    var x = await reader.ReadAsync();

                    var hex = ExtractColor(fetchImage(x.ImageUrl));

                    uint.TryParse(hex, System.Globalization.NumberStyles.HexNumber, null, out uint color);

                    await chroma.SetAllAsync(ColoreColor.FromRgb(color));
                }
            });
Beispiel #21
0
        public void Initialize()
        {
            if (Initialized)
            {
                return;
            }

            ColoreProvider.CreateNativeAsync().ContinueWith(task =>
            {
                if (task.IsCompleted)
                {
                    _chroma     = task.Result;
                    Initialized = _chroma.Initialized;
                }

                SdkInit?.Invoke(this, new SdkInitEvent {
                    Initialized = Initialized
                });
            });
        }
Beispiel #22
0
        private async Task Initialize()
        {
            // get chroma instance
            chroma = await ColoreProvider.CreateNativeAsync();

            // Create the custom Grid
            keyboardGrid = KeyboardCustom.Create();

            // show bounds
            CreateGridBorder(ColoreColor.Yellow);

            // show controls
            keyboardGrid[ColoreKey.Left]  = ColoreColor.Blue;
            keyboardGrid[ColoreKey.Right] = ColoreColor.Blue;
            keyboardGrid[ColoreKey.Up]    = ColoreColor.Blue;
            keyboardGrid[ColoreKey.Down]  = ColoreColor.Blue;

            // set player start position
            currentDirection = lastDirection = Position2D.Right;
            playerPosition   = (leftBottomBounds + rightTopBounds) / 2;
            playerBody.Clear();

            // Create a Grid containing all used positions
            freeCells.Clear();
            TraverseGrid((row, col) =>
            {
                var pos = new Position2D(row, col);
                if (pos != playerPosition && pos != targetPosition && !playerBody.Contains(pos))
                {
                    freeCells.Add(pos);
                }
            });

            // Create Target Position
            CreateNextRandomTarget(ColoreColor.Red);

            await chroma.Keyboard.SetCustomAsync(keyboardGrid);
        }
Beispiel #23
0
 public async Task InitChromaAsync()
 {
     chroma = await ColoreProvider.CreateNativeAsync();
 }
        public Module Setup()
        {
            IChroma chroma = ColoreProvider.CreateNativeAsync().Result;

            chroma.SetAllAsync(Colore.Data.Color.Red);
            chroma.Keyboard[Key.A] = Colore.Data.Color.Red;

            Module module = new Module()
            {
                Name = "Razer"
            };

            module.Devices.Add(new Device()
            {
                Id    = "RAZER_BLACKWIDOW_V1",
                Title = "BlackWidow",
                Map   = new DeviceMap()
                {
                    BackgroundImage = ImageToByteArray(Resource.keyboard),
                    Size            = new Size(100, 30),
                    Leds            = new Point[1, 2]
                    {
                        { new Point(10, 10), new Point(10, 40) }
                    }
                }

                /*Map = new int[7, 23]
                 *  {
                 *      {0,1,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0},
                 *      {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                 *      {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                 *      {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,0},
                 *      {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,1,1,1},
                 *      {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                 *      {0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0}
                 *  }*/
            });

            module.Devices.Add(new Device()
            {
                Id    = "LED_STRIP",
                Title = "LedStrip",
                Map   = new DeviceMap()
                {
                    BackgroundImage = null,
                    Size            = new Size(300, 5),
                    Leds            = new Point[1, 21]
                    {
                        {
                            new Point(0, 0),
                            new Point(15, 0),
                            new Point(30, 0),
                            new Point(45, 0),
                            new Point(60, 0),
                            new Point(75, 0),
                            new Point(90, 0),
                            new Point(105, 0),
                            new Point(120, 0),
                            new Point(135, 0),
                            new Point(150, 0),
                            new Point(165, 0),
                            new Point(180, 0),
                            new Point(195, 0),
                            new Point(210, 0),
                            new Point(225, 0),
                            new Point(240, 0),
                            new Point(255, 0),
                            new Point(270, 0),
                            new Point(285, 0),
                            new Point(300, 0)
                        }
                    }
                }
            });

            module.Devices.Add(new Device()
            {
                Id    = "RAZER_DEATHADDER_V2",
                Title = "Death Adder",
                Map   = new DeviceMap()
                {
                    BackgroundImage = ImageToByteArray(Resource.mouse),
                    Size            = new Size(50, 50),
                    Leds            = new Point[1, 2]
                    {
                        { new Point(25, 15), new Point(25, 40) }
                    }
                }
            });

            module.Devices.Add(new Device()
            {
                Id    = "RAZER_CHROMA_7.1",
                Title = "Chroma 7.1",
                Map   = new DeviceMap()
                {
                    BackgroundImage = ImageToByteArray(Resource.headphones),
                    Size            = new Size(50, 50),
                    Leds            = new Point[2, 1]
                    {
                        { new Point(5, 36) }, { new Point(45, 36) }
                    }
                }
            });

            return(module);
        }
Beispiel #25
0
        static async Task MainAsync(string[] args)
        {
            string char1Name, char2Name, char3Name;
            int    char1CurrentHP, char1MaxHP, char1CurrentMP, char1MaxMP, char2CurrentHP, char2MaxHP, char2CurrentMP, char2MaxMP, char3CurrentHP, char3MaxHP, char3CurrentMP, char3MaxMP;
            int    familyLevel = 0;
            uint   bufferSize  = 255;
            var    keyboard    = KeyboardCustom.Create();
            var    chroma      = await ColoreProvider.CreateNativeAsync();

            await chroma.SetAllAsync(fadeRed);

WaitGame:
            try
            {
                Process  GameProcess = Process.GetProcessesByName("rGE").FirstOrDefault();
                VAMemory vam         = new VAMemory("rGE");
                vam.ReadInt32(GameProcess.MainModule.BaseAddress);
                while (true)
                {
                    Console.Clear();
                    //HP
                    char1CurrentHP = vam.ReadInt32((IntPtr)(vam.getBaseAddress + CurrentHP[0]));
                    char1MaxHP     = vam.ReadInt32((IntPtr)(vam.getBaseAddress + MaxHP[0]));
                    char2CurrentHP = vam.ReadInt32((IntPtr)(vam.getBaseAddress + CurrentHP[1]));
                    char2MaxHP     = vam.ReadInt32((IntPtr)(vam.getBaseAddress + MaxHP[1]));
                    char3CurrentHP = vam.ReadInt32((IntPtr)(vam.getBaseAddress + CurrentHP[2]));
                    char3MaxHP     = vam.ReadInt32((IntPtr)(vam.getBaseAddress + MaxHP[2]));
                    //MP
                    char1CurrentMP = vam.ReadInt16((IntPtr)(vam.getBaseAddress + CurrentMP[0]));
                    char1MaxMP     = vam.ReadInt16((IntPtr)(vam.getBaseAddress + MaxMP[0]));
                    char2CurrentMP = vam.ReadInt16((IntPtr)(vam.getBaseAddress + CurrentMP[1]));
                    char2MaxMP     = vam.ReadInt16((IntPtr)(vam.getBaseAddress + MaxMP[1]));
                    char3CurrentMP = vam.ReadInt16((IntPtr)(vam.getBaseAddress + CurrentMP[2]));
                    char3MaxMP     = vam.ReadInt16((IntPtr)(vam.getBaseAddress + MaxMP[2]));

                    var HP1Point = Math.Round((double)char1CurrentHP / char1MaxHP, 2);
                    var HP2Point = Math.Round((double)char2CurrentHP / char2MaxHP, 2);
                    var HP3Point = Math.Round((double)char3CurrentHP / char3MaxHP, 2);
                    var MP1Point = Math.Round((double)char1CurrentMP / char1MaxMP, 2);
                    var MP2Point = Math.Round((double)char2CurrentMP / char2MaxMP, 2);
                    var MP3Point = Math.Round((double)char3CurrentMP / char3MaxMP, 2);
                    RenderKeyboard(ref keyboard, new[] { (int)(HP1Point * 10), (int)(HP2Point * 10), (int)(HP3Point * 10) }, new[] { (int)(MP1Point * 10), (int)(MP2Point * 10), (int)(MP3Point * 10) });
                    await chroma.Keyboard.SetCustomAsync(keyboard);

                    //char1Name = vam.ReadStringASCII((IntPtr)(vam.getBaseAddress + Name[0]), bufferSize);
                    //char2Name = vam.ReadStringASCII((IntPtr)(vam.getBaseAddress + Name[1]), bufferSize);
                    //char3Name = vam.ReadStringASCII((IntPtr)(vam.getBaseAddress + Name[2]), bufferSize);
                    //char1Name = char1Name.Substring(0, char1Name.IndexOf("\0"));
                    //char2Name = char2Name.Substring(0, char2Name.IndexOf("\0"));
                    //char3Name = char3Name.Substring(0, char3Name.IndexOf("\0"));
                    //Console.WriteLine($"\rName : {char1Name} {char1CurrentMP}/{char1MaxMP}[{HP1Point * 100}]% ");
                    //Console.WriteLine($"\rName : {char2Name} {char2CurrentMP}/{char2MaxMP}[{HP2Point * 100}]% ");
                    //Console.WriteLine($"\rName : {char3Name} {char3CurrentMP}/{char3MaxMP}[{HP3Point * 100}]% ");
                    Thread.Sleep(500);
                }
            }

            catch
            {
                keyboard.Set(fadeRed);
                await chroma.Keyboard.SetCustomAsync(keyboard);

                Console.Write("\rWaiting for character info to allocate into memory...");
                Thread.Sleep(500);
                goto WaitGame;
            }
        }
Beispiel #26
0
 public RazerSdkAdapter()
 {
     this._chromaInterface = ColoreProvider.CreateNativeAsync().Result;
 }