コード例 #1
0
ファイル: Program.cs プロジェクト: sverrirs/CorsairK95
        /// <summary>
        /// Runs a simple connection experiment and sending led control messages
        /// </summary>
        public static void Experiment()
        {
            K95Device usb = new K95Device();

            try
            {
                usb.Connect();

                LedBrightness[] ledbrightness = { LedBrightness.Off,
                                                  LedBrightness.Low,   LedBrightness.Medium,  LedBrightness.High,
                                                  LedBrightness.Medium,LedBrightness.Low };

                // Now cycle through the brightness intensities for the keyboard
                for (int i = 0; i < 10000; i++)
                {
                    usb.SetLedBrightness(ledbrightness[i % ledbrightness.Length]);

                    // Short wait to let the hardware get ready again and the user to notice the change
                    Thread.Sleep(150);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                Console.WriteLine(ex.ToString());

                usb.Disconnect();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: sverrirs/CorsairK95
        /// <summary>
        /// Runs a simple connection experiment and sending led control messages
        /// </summary>
        public static void Experiment()
        {
            K95Device usb = new K95Device();
            try
            {
                usb.Connect();

                LedBrightness[] ledbrightness = {LedBrightness.Off,
                                                 LedBrightness.Low, LedBrightness.Medium, LedBrightness.High,
                                                 LedBrightness.Medium, LedBrightness.Low };

                // Now cycle through the brightness intensities for the keyboard
                for ( int i = 0; i < 10000; i++)
                {
                    usb.SetLedBrightness(ledbrightness[i % ledbrightness.Length]);

                    // Short wait to let the hardware get ready again and the user to notice the change
                    Thread.Sleep(150);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: "+ex.Message);
                Console.WriteLine(ex.ToString());

                usb.Disconnect();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: sverrirs/CorsairK95
        /// <summary>
        /// Brute-force sends bytes to the keyboard in an attempt to figure out what control sequences are supported
        /// NOTE: This has the potential to actually brick your entire keyboard! 
        /// </summary>
        public static void StartDiscovery()
        {
            using (var output = new StreamWriter("output-0x21.txt"))
            {
                output.WriteLine("Start"); output.Flush();

                K95Device usb = new K95Device();
                usb.Connect();

                for (int request = 0; request < 256; request++)
                {
                    for (int value = 0; value < 3840; value++)
                    {
                        //for (int key = 0; key < 256; key++)
                        {
                            /*if (usb == null)
                        {
                            usb = new K95Device();
                            usb.Connect();
                        }*/

                            try
                            {
                                //usb.Send(0x21, Convert.ToByte(request), value, 0, new[] { (byte)key });
                                //Console.WriteLine("0x{0:X}, 0x{1:X}, 0x{2:X}", request, value, key);
                                // request == 20
                                usb.Send(0x21, Convert.ToByte(request), value, 0);
                                output.WriteLine("0x21, 0x{0:X}, 0x{1:X}", request, value); output.Flush();
                                Thread.Sleep(250);
                            }
                            catch (Exception)
                            {
                                /*try { usb?.Disconnect(); } catch (Exception) {}
                            usb = null;*/
                            }
                        }
                    }
                }

                output.WriteLine("Finished"); output.Flush();
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: sverrirs/CorsairK95
        /// <summary>
        /// Brute-force sends bytes to the keyboard in an attempt to figure out what control sequences are supported
        /// NOTE: This has the potential to actually brick your entire keyboard!
        /// </summary>
        public static void StartDiscovery()
        {
            using (var output = new StreamWriter("output-0x21.txt"))
            {
                output.WriteLine("Start"); output.Flush();

                K95Device usb = new K95Device();
                usb.Connect();

                for (int request = 0; request < 256; request++)
                {
                    for (int value = 0; value < 3840; value++)
                    {
                        //for (int key = 0; key < 256; key++)
                        {
                            /*if (usb == null)
                             * {
                             * usb = new K95Device();
                             * usb.Connect();
                             * }*/

                            try
                            {
                                //usb.Send(0x21, Convert.ToByte(request), value, 0, new[] { (byte)key });
                                //Console.WriteLine("0x{0:X}, 0x{1:X}, 0x{2:X}", request, value, key);
                                // request == 20
                                usb.Send(0x21, Convert.ToByte(request), value, 0);
                                output.WriteLine("0x21, 0x{0:X}, 0x{1:X}", request, value); output.Flush();
                                Thread.Sleep(250);
                            }
                            catch (Exception)
                            {
                                /*try { usb?.Disconnect(); } catch (Exception) {}
                                 * usb = null;*/
                            }
                        }
                    }
                }

                output.WriteLine("Finished"); output.Flush();
            }
        }