SHARE
TWEET

Untitled

a guest Feb 20th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Decompiled with JetBrains decompiler
  2. // Type: Aurora.Devices.Asus.AuraDevice
  3. // Assembly: Aurora, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
  4. // MVID: 10E8C401-02CD-4F83-843C-67D1260C7788
  5. // Assembly location: C:\Users\Diogo\Desktop\Debug v0.0.7\Debug\Aurora.exe
  6.  
  7. using AuraServiceLib;
  8. using Aurora.Settings;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Diagnostics;
  13. using System.Drawing;
  14. using System.Runtime.InteropServices;
  15. using System.Threading;
  16.  
  17. namespace Aurora.Devices.Asus
  18. {
  19.   internal class AuraDevice : Device
  20.   {
  21.     private static readonly bool DEBUG = true;
  22.     private static readonly bool DEBUG_SPAM = false;
  23.     private static readonly bool DEBUG_EFFECTS = false;
  24.     private static readonly bool DEBUG_GROUPS = true;
  25.     private static readonly bool DEBUG_LIGHTS = true;
  26.     private readonly object _lock = new object();
  27.     private Stopwatch watch = new Stopwatch();
  28.     private long lastUpdateTime = 0;
  29.     private bool initialized = false;
  30.     private bool keyboardConnected = false;
  31.     private bool peripheralConnected = false;
  32.     private System.Windows.Controls.Image imgBitmap = new System.Windows.Controls.Image();
  33.     private const string deviceName = "ASUS Aura";
  34.     private static IAuraDeviceCollection auraDeviceCollection;
  35.     private const int DEVICE_MODE_SW = 0;
  36.     private const int DEVICE_MODE_EC = 1;
  37.     private const uint DEVICE_TYPE_MAINBOARD_MASTER = 65536;
  38.     private const uint DEVICE_TYPE_VGA = 131072;
  39.     private const uint DEVICE_TYPE_DRAM = 458752;
  40.     private const uint DEVICE_TYPE_KEYBOARD = 524288;
  41.     private const uint DEVICE_TYPE_MOUSE = 589824;
  42.     private const uint DEVICE_TYPE_ADDRESSABLE_STRIP = 69632;
  43.     private VariableRegistry variableRegistry;
  44.     private const string RegistryKeyboard = "ASUS Aura_enable_keyboard";
  45.     private const string RegistryMouse = "ASUS Aura_enable_mouse";
  46.     private const string RegistryVga = "ASUS Aura_enable_gpu";
  47.     private const string RegistryOther = "ASUS Aura_enable_other";
  48.     private const string RegistryKeyboardTitle = "Enable keyboard support";
  49.     private const string RegistryMouseTitle = "Enable mouse support";
  50.     private const string RegistryGpuTitle = "Enable GPU support";
  51.     private const string RegistryOtherTitle = "Enable other peripheral support";
  52.     private bool _registryEnableKeyboard;
  53.     private bool _registryEnableMouse;
  54.     private bool _registryEnableGpu;
  55.     private bool _registryEnableOther;
  56.  
  57.     public string GetDeviceDetails()
  58.     {
  59.       if (!this.initialized)
  60.         return "ASUS Aura: Not initialized";
  61.       string str1 = "ASUS Aura:";
  62.       for (int index = 0; index < AuraDevice.auraDeviceCollection.Count; ++index)
  63.       {
  64.         // ISSUE: variable of a compiler-generated type
  65.         IAuraDevice auraDevice = AuraDevice.auraDeviceCollection[index];
  66.         string str2 = str1;
  67.         string str3;
  68.         if (!string.IsNullOrEmpty(auraDevice.Manufacture + auraDevice.Model))
  69.           str3 = " (" + (object) (index + 1) + ")" + auraDevice.Manufacture + " " + auraDevice.Model;
  70.         else
  71.           str3 = " (" + (object) (index + 1) + ")" + auraDevice.Name;
  72.         str1 = str2 + str3;
  73.       }
  74.       return str1 + ": Connected";
  75.     }
  76.  
  77.     public string GetDeviceName()
  78.     {
  79.       return "ASUS Aura";
  80.     }
  81.  
  82.     public string GetDeviceUpdatePerformance()
  83.     {
  84.       return this.initialized ? this.lastUpdateTime.ToString() + " ms" : "";
  85.     }
  86.  
  87.     public VariableRegistry GetRegisteredVariables()
  88.     {
  89.       if (this.variableRegistry == null)
  90.       {
  91.         this.variableRegistry = new VariableRegistry();
  92.         // ISSUE: variable of a compiler-generated type
  93.         AuraDevelopement instance = (AuraDevelopement) Activator.CreateInstance(Marshal.GetTypeFromCLSID(new Guid("34B707DC-1133-4EBC-B380-21387A50A89D")));
  94.         // ISSUE: reference to a compiler-generated method
  95.         instance.AURARequireToken();
  96.         // ISSUE: reference to a compiler-generated method
  97.         AuraDevice.auraDeviceCollection = instance.GetAllDevices();
  98.         int num1 = 0;
  99.         int num2 = 0;
  100.         int num3 = 0;
  101.         int num4 = 0;
  102.         int num5 = 0;
  103.         int num6 = 0;
  104.         int num7 = 0;
  105.         for (int index = 0; index < AuraDevice.auraDeviceCollection.Count; ++index)
  106.         {
  107.           // ISSUE: variable of a compiler-generated type
  108.           IAuraDevice auraDevice = AuraDevice.auraDeviceCollection[index];
  109.           string str = string.IsNullOrEmpty(auraDevice.Manufacture + auraDevice.Model) ? auraDevice.Name : auraDevice.Manufacture + " " + auraDevice.Model;
  110.           string title1 = str + "\r\nLight count: " + (object) auraDevice.LightCount;
  111.           string title2 = "WARNING UNKNOWN TYPE! Enable " + str + "\r\nLight count: " + (object) auraDevice.LightCount + "\r\nDevice type: " + string.Format("{0:X}", (object) auraDevice.Type);
  112.           switch (auraDevice.Type)
  113.           {
  114.             case 65536:
  115.               this.variableRegistry.Register("enable_mobo_" + (object) num1, (object) true, title1, (object) null, (object) null, "", VariableFlags.None);
  116.               ++num1;
  117.               break;
  118.             case 69632:
  119.               this.variableRegistry.Register("enable_adressable_" + (object) num4, (object) true, title1, (object) null, (object) null, "", VariableFlags.None);
  120.               ++num4;
  121.               break;
  122.             case 131072:
  123.               this.variableRegistry.Register("enable_vga_" + (object) num5, (object) true, title1, (object) null, (object) null, "", VariableFlags.None);
  124.               ++num5;
  125.               break;
  126.             case 458752:
  127.               this.variableRegistry.Register("enable_dram_" + (object) num3, (object) true, title1, (object) null, (object) null, "", VariableFlags.None);
  128.               ++num3;
  129.               break;
  130.             case 524288:
  131.               this.variableRegistry.Register("enable_keyboard_" + (object) num2, (object) true, title1, (object) null, (object) null, "", VariableFlags.None);
  132.               ++num2;
  133.               break;
  134.             case 589824:
  135.               this.variableRegistry.Register("enable_mouse_" + (object) num6, (object) true, title1, (object) null, (object) null, "", VariableFlags.None);
  136.               ++num6;
  137.               break;
  138.             default:
  139.               this.variableRegistry.Register("enable_unknown_" + (object) num7, (object) true, title2, (object) null, (object) null, "", VariableFlags.None);
  140.               ++num7;
  141.               break;
  142.           }
  143.         }
  144.       }
  145.       return this.variableRegistry;
  146.     }
  147.  
  148.     public bool Initialize()
  149.     {
  150.       if (!this.initialized)
  151.       {
  152.         lock (this._lock)
  153.         {
  154.           Global.logger.Info("Initializing Device");
  155.           try
  156.           {
  157.             if (AuraDevice.DEBUG_SPAM)
  158.               this.Dump(AuraDevice.auraDeviceCollection);
  159.             for (int index = 0; index < AuraDevice.auraDeviceCollection.Count; ++index)
  160.             {
  161.               // ISSUE: reference to a compiler-generated method
  162.               AuraDevice.auraDeviceCollection[index].SetMode(0);
  163.               // ISSUE: reference to a compiler-generated method
  164.               AuraDevice.auraDeviceCollection[index].Apply();
  165.               switch (AuraDevice.auraDeviceCollection[index].Type)
  166.               {
  167.                 case 524288:
  168.                   this.keyboardConnected = true;
  169.                   break;
  170.                 default:
  171.                   this.peripheralConnected = true;
  172.                   break;
  173.               }
  174.             }
  175.             this.initialized = true;
  176.           }
  177.           catch (Exception ex)
  178.           {
  179.             Global.logger.Error("There was an error initializing Asus Aura SDK.\r\n" + ex.Message);
  180.             return false;
  181.           }
  182.           if (!this.initialized)
  183.             Global.logger.Error("No Asus Aura devices successfully Initialized.");
  184.         }
  185.       }
  186.       return this.initialized;
  187.     }
  188.  
  189.     public bool IsConnected()
  190.     {
  191.       if (AuraDevice.DEBUG_SPAM)
  192.         Global.logger.Info("IsConnected()");
  193.       return this.initialized && AuraDevice.auraDeviceCollection != null;
  194.     }
  195.  
  196.     public bool IsInitialized()
  197.     {
  198.       return this.initialized;
  199.     }
  200.  
  201.     public bool IsKeyboardConnected()
  202.     {
  203.       if (AuraDevice.DEBUG_SPAM)
  204.         Global.logger.Info("IsKeyboardConnected()");
  205.       return this.keyboardConnected;
  206.     }
  207.  
  208.     public bool IsPeripheralConnected()
  209.     {
  210.       if (AuraDevice.DEBUG_SPAM)
  211.         Global.logger.Info("IsPeripheralConnected()");
  212.       return this.peripheralConnected;
  213.     }
  214.  
  215.     public bool Reconnect()
  216.     {
  217.       if (AuraDevice.DEBUG)
  218.         Global.logger.Info("Reconnect()");
  219.       this.OnDeviceStop();
  220.       return this.Initialize();
  221.     }
  222.  
  223.     public void Reset()
  224.     {
  225.       if (AuraDevice.DEBUG)
  226.         Global.logger.Info("Reset()");
  227.       this.OnDeviceStop();
  228.       this.Initialize();
  229.     }
  230.  
  231.     public void Shutdown()
  232.     {
  233.       if (AuraDevice.DEBUG)
  234.         Global.logger.Info("Shutdown()");
  235.       lock (this._lock)
  236.       {
  237.         if (!this.initialized)
  238.           return;
  239.         this.OnDeviceStop();
  240.       }
  241.     }
  242.  
  243.     public bool UpdateDevice(
  244.       Dictionary<DeviceKeys, Color> keyColors,
  245.       DoWorkEventArgs e,
  246.       bool forced = false)
  247.     {
  248.       if (!this.initialized)
  249.         return false;
  250.       if (e.Cancel)
  251.         return false;
  252.       try
  253.       {
  254.         foreach (KeyValuePair<DeviceKeys, Color> keyColor in keyColors)
  255.         {
  256.           if (e.Cancel)
  257.             return false;
  258.           if (this.peripheralConnected)
  259.             this.ProcessPeriphalDevices(keyColor);
  260.           if (this.keyboardConnected)
  261.             this.ProcessKeyboardDevices(keyColor);
  262.         }
  263.         if (e.Cancel)
  264.           return false;
  265.       }
  266.       catch (Exception ex)
  267.       {
  268.         Global.logger.Error("UpdateDevice() Failed: " + ex.ToString());
  269.         return false;
  270.       }
  271.       return true;
  272.     }
  273.  
  274.     public bool UpdateDevice(
  275.       DeviceColorComposition colorComposition,
  276.       DoWorkEventArgs e,
  277.       bool forced = false)
  278.     {
  279.       this.watch.Restart();
  280.       bool flag = this.UpdateDevice(colorComposition.keyColors, e, forced);
  281.       this.watch.Stop();
  282.       this.lastUpdateTime = this.watch.ElapsedMilliseconds;
  283.       return flag;
  284.     }
  285.  
  286.     private void OnDeviceStop()
  287.     {
  288.       this.keyboardConnected = false;
  289.       this.peripheralConnected = false;
  290.       this.initialized = false;
  291.     }
  292.  
  293.     private void ProcessPeriphalDevices(KeyValuePair<DeviceKeys, Color> keyValuePair)
  294.     {
  295.       int lightId = AuraDevice.DeviceKeyToAuraPeripheralKeyId(keyValuePair.Key);
  296.       if (lightId == int.MaxValue)
  297.         return;
  298.       new Thread((ThreadStart) (() =>
  299.       {
  300.         for (int index = 0; index < AuraDevice.auraDeviceCollection.Count; ++index)
  301.         {
  302.           switch (AuraDevice.auraDeviceCollection[index].Type)
  303.           {
  304.             case 65536:
  305.             case 69632:
  306.             case 131072:
  307.             case 458752:
  308.               if (keyValuePair.Key == DeviceKeys.Peripheral_Logo)
  309.               {
  310.                 this.SetDeviceLightsColor(AuraDevice.auraDeviceCollection[index], keyValuePair.Value);
  311.                 break;
  312.               }
  313.               break;
  314.             case 589824:
  315.               this.SetRgbLightColor(AuraDevice.auraDeviceCollection[index], lightId, keyValuePair.Value);
  316.               break;
  317.           }
  318.         }
  319.       })).Start();
  320.     }
  321.  
  322.     private void ProcessKeyboardDevices(KeyValuePair<DeviceKeys, Color> keyValuePair)
  323.     {
  324.       new Thread((ThreadStart) (() =>
  325.       {
  326.         int auraKeyboardKeyId = AuraDevice.DeviceKeysToAuraKeyboardKeyId(keyValuePair.Key);
  327.         if (auraKeyboardKeyId == int.MaxValue)
  328.           return;
  329.         for (int index = 0; index < AuraDevice.auraDeviceCollection.Count; ++index)
  330.         {
  331.           if (AuraDevice.auraDeviceCollection[index].Type == 524288U)
  332.             this.SetRgbLightColor(AuraDevice.auraDeviceCollection[index], auraKeyboardKeyId, keyValuePair.Value);
  333.         }
  334.       })).Start();
  335.     }
  336.  
  337.     /// <summary>
  338.     /// Method for setting all RGB Lights for a device one color.
  339.     /// </summary>
  340.     /// <param name="device">IAuraDevice that controls the RGB lights</param>
  341.     /// <param name="color">Color to set RGB key to</param>
  342.     private void SetDeviceLightsColor(IAuraDevice device, Color color)
  343.     {
  344.       new Thread((ThreadStart) (() =>
  345.       {
  346.         bool flag = false;
  347.         foreach (IAuraRgbLight light in device.Lights)
  348.         {
  349.           if (device.Type == 458752U || !this.ColorMatchesLight(color, light.Red, light.Green, light.Blue))
  350.           {
  351.             light.Red = color.R;
  352.             light.Green = color.G;
  353.             light.Blue = color.B;
  354.             flag = true;
  355.           }
  356.           else if (AuraDevice.DEBUG_SPAM)
  357.             Global.logger.Info("SetDeviceLightsColor() Color match dont update: " + light.Name);
  358.         }
  359.         if (!flag)
  360.           return;
  361.         // ISSUE: reference to a compiler-generated method
  362.         device.Apply();
  363.       })).Start();
  364.     }
  365.  
  366.     /// <summary>Method for setting Aura Keyboard RGB keys.</summary>
  367.     /// <param name="device">IAuraKeyboard that controls the RGB light</param>
  368.     /// <param name="index">Index of RGB key. Keys are enumerated by the device controller</param>
  369.     /// <param name="color">Color to set RGB key to</param>
  370.     private void SetKeyboardRgbKeyColor(IAuraKeyboard device, int index, Color color)
  371.     {
  372.       new Thread((ThreadStart) (() =>
  373.       {
  374.         // ISSUE: variable of a compiler-generated type
  375.         IAuraRgbKey key = device.Keys[index];
  376.         bool flag = false;
  377.         if (!this.ColorMatchesLight(color, key.Red, key.Green, key.Blue))
  378.         {
  379.           key.Red = color.R;
  380.           key.Green = color.G;
  381.           key.Blue = color.B;
  382.           flag = true;
  383.         }
  384.         else if (AuraDevice.DEBUG_SPAM)
  385.           Global.logger.Info("SetKeyboardRgbKeyColor() Color match dont update: " + key.Name);
  386.         if (!flag)
  387.           return;
  388.         // ISSUE: reference to a compiler-generated method
  389.         device.Apply();
  390.       })).Start();
  391.     }
  392.  
  393.     /// <summary>Method for setting general Aura RGB lights.</summary>
  394.     /// <param name="device">IAuraDevice that controls the RGB light</param>
  395.     /// <param name="index">Index of RGB Light. Lights are enumerated by the device controller</param>
  396.     /// <param name="color">Color to set RGB light to</param>
  397.     private void SetRgbLightColor(IAuraDevice device, int index, Color color)
  398.     {
  399.       new Thread((ThreadStart) (() =>
  400.       {
  401.         // ISSUE: variable of a compiler-generated type
  402.         IAuraRgbLight light = device.Lights[index];
  403.         bool flag = false;
  404.         if (!this.ColorMatchesLight(color, light.Red, light.Green, light.Blue))
  405.         {
  406.           light.Red = color.R;
  407.           light.Green = color.G;
  408.           light.Blue = color.B;
  409.           flag = true;
  410.         }
  411.         else if (AuraDevice.DEBUG_SPAM)
  412.           Global.logger.Info("SetRgbLightColor() Color match dont update: " + light.Name);
  413.         if (!flag)
  414.           return;
  415.         // ISSUE: reference to a compiler-generated method
  416.         device.Apply();
  417.       })).Start();
  418.     }
  419.  
  420.     private bool ColorMatchesLight(Color color, byte r, byte g, byte b)
  421.     {
  422.       return (int) color.R == (int) r && (int) color.G == (int) g && (int) color.B == (int) b;
  423.     }
  424.  
  425.     /// <summary>Determines the int ID from a DeviceKeys</summary>
  426.     /// <param name="key">The key to translate</param>
  427.     /// <returns>the ushort id, or ushort.MaxValue if invalid</returns>
  428.     private static int DeviceKeysToAuraKeyboardKeyId(DeviceKeys key)
  429.     {
  430.       switch (key)
  431.       {
  432.         case DeviceKeys.ESC:
  433.           return 1;
  434.         case DeviceKeys.F1:
  435.           return 59;
  436.         case DeviceKeys.F2:
  437.           return 60;
  438.         case DeviceKeys.F3:
  439.           return 61;
  440.         case DeviceKeys.F4:
  441.           return 62;
  442.         case DeviceKeys.F5:
  443.           return 63;
  444.         case DeviceKeys.F6:
  445.           return 64;
  446.         case DeviceKeys.F7:
  447.           return 65;
  448.         case DeviceKeys.F8:
  449.           return 66;
  450.         case DeviceKeys.F9:
  451.           return 67;
  452.         case DeviceKeys.F10:
  453.           return 68;
  454.         case DeviceKeys.F11:
  455.           return 87;
  456.         case DeviceKeys.F12:
  457.           return 88;
  458.         case DeviceKeys.PRINT_SCREEN:
  459.           return 183;
  460.         case DeviceKeys.SCROLL_LOCK:
  461.           return 70;
  462.         case DeviceKeys.PAUSE_BREAK:
  463.           return 197;
  464.         case DeviceKeys.TILDE:
  465.           return 41;
  466.         case DeviceKeys.ONE:
  467.           return 2;
  468.         case DeviceKeys.TWO:
  469.           return 3;
  470.         case DeviceKeys.THREE:
  471.           return 4;
  472.         case DeviceKeys.FOUR:
  473.           return 5;
  474.         case DeviceKeys.FIVE:
  475.           return 6;
  476.         case DeviceKeys.SIX:
  477.           return 7;
  478.         case DeviceKeys.SEVEN:
  479.           return 8;
  480.         case DeviceKeys.EIGHT:
  481.           return 9;
  482.         case DeviceKeys.NINE:
  483.           return 10;
  484.         case DeviceKeys.ZERO:
  485.           return 11;
  486.         case DeviceKeys.MINUS:
  487.           return 12;
  488.         case DeviceKeys.EQUALS:
  489.           return 13;
  490.         case DeviceKeys.BACKSPACE:
  491.           return 14;
  492.         case DeviceKeys.INSERT:
  493.           return 210;
  494.         case DeviceKeys.HOME:
  495.           return 199;
  496.         case DeviceKeys.PAGE_UP:
  497.           return 201;
  498.         case DeviceKeys.NUM_LOCK:
  499.           return 69;
  500.         case DeviceKeys.NUM_SLASH:
  501.           return 181;
  502.         case DeviceKeys.NUM_ASTERISK:
  503.           return 55;
  504.         case DeviceKeys.NUM_MINUS:
  505.           return 74;
  506.         case DeviceKeys.TAB:
  507.           return 15;
  508.         case DeviceKeys.Q:
  509.           return 16;
  510.         case DeviceKeys.W:
  511.           return 17;
  512.         case DeviceKeys.E:
  513.           return 18;
  514.         case DeviceKeys.R:
  515.           return 19;
  516.         case DeviceKeys.T:
  517.           return 20;
  518.         case DeviceKeys.Y:
  519.           return 21;
  520.         case DeviceKeys.U:
  521.           return 22;
  522.         case DeviceKeys.I:
  523.           return 23;
  524.         case DeviceKeys.O:
  525.           return 24;
  526.         case DeviceKeys.P:
  527.           return 25;
  528.         case DeviceKeys.OPEN_BRACKET:
  529.           return 26;
  530.         case DeviceKeys.CLOSE_BRACKET:
  531.           return 27;
  532.         case DeviceKeys.BACKSLASH:
  533.           return 43;
  534.         case DeviceKeys.DELETE:
  535.           return 211;
  536.         case DeviceKeys.END:
  537.           return 207;
  538.         case DeviceKeys.PAGE_DOWN:
  539.           return 209;
  540.         case DeviceKeys.NUM_SEVEN:
  541.           return 71;
  542.         case DeviceKeys.NUM_EIGHT:
  543.           return 72;
  544.         case DeviceKeys.NUM_NINE:
  545.           return 73;
  546.         case DeviceKeys.NUM_PLUS:
  547.           return 78;
  548.         case DeviceKeys.CAPS_LOCK:
  549.           return 58;
  550.         case DeviceKeys.A:
  551.           return 30;
  552.         case DeviceKeys.S:
  553.           return 31;
  554.         case DeviceKeys.D:
  555.           return 32;
  556.         case DeviceKeys.F:
  557.           return 33;
  558.         case DeviceKeys.G:
  559.           return 34;
  560.         case DeviceKeys.H:
  561.           return 35;
  562.         case DeviceKeys.J:
  563.           return 36;
  564.         case DeviceKeys.K:
  565.           return 37;
  566.         case DeviceKeys.L:
  567.           return 38;
  568.         case DeviceKeys.SEMICOLON:
  569.           return 39;
  570.         case DeviceKeys.APOSTROPHE:
  571.           return 40;
  572.         case DeviceKeys.HASHTAG:
  573.           return 3;
  574.         case DeviceKeys.ENTER:
  575.           return 28;
  576.         case DeviceKeys.NUM_FOUR:
  577.           return 75;
  578.         case DeviceKeys.NUM_FIVE:
  579.           return 76;
  580.         case DeviceKeys.NUM_SIX:
  581.           return 77;
  582.         case DeviceKeys.LEFT_SHIFT:
  583.           return 42;
  584.         case DeviceKeys.BACKSLASH_UK:
  585.           return 43;
  586.         case DeviceKeys.Z:
  587.           return 44;
  588.         case DeviceKeys.X:
  589.           return 45;
  590.         case DeviceKeys.C:
  591.           return 46;
  592.         case DeviceKeys.V:
  593.           return 47;
  594.         case DeviceKeys.B:
  595.           return 48;
  596.         case DeviceKeys.N:
  597.           return 49;
  598.         case DeviceKeys.M:
  599.           return 50;
  600.         case DeviceKeys.COMMA:
  601.           return 51;
  602.         case DeviceKeys.PERIOD:
  603.           return 52;
  604.         case DeviceKeys.FORWARD_SLASH:
  605.           return 53;
  606.         case DeviceKeys.RIGHT_SHIFT:
  607.           return 54;
  608.         case DeviceKeys.ARROW_UP:
  609.           return 200;
  610.         case DeviceKeys.NUM_ONE:
  611.           return 79;
  612.         case DeviceKeys.NUM_TWO:
  613.           return 80;
  614.         case DeviceKeys.NUM_THREE:
  615.           return 81;
  616.         case DeviceKeys.NUM_ENTER:
  617.           return 156;
  618.         case DeviceKeys.LEFT_CONTROL:
  619.           return 29;
  620.         case DeviceKeys.LEFT_WINDOWS:
  621.           return 219;
  622.         case DeviceKeys.LEFT_ALT:
  623.           return 56;
  624.         case DeviceKeys.SPACE:
  625.           return 57;
  626.         case DeviceKeys.RIGHT_ALT:
  627.           return 184;
  628.         case DeviceKeys.APPLICATION_SELECT:
  629.           return 221;
  630.         case DeviceKeys.RIGHT_CONTROL:
  631.           return 157;
  632.         case DeviceKeys.ARROW_LEFT:
  633.           return 203;
  634.         case DeviceKeys.ARROW_DOWN:
  635.           return 208;
  636.         case DeviceKeys.ARROW_RIGHT:
  637.           return 205;
  638.         case DeviceKeys.NUM_ZERO:
  639.           return 82;
  640.         case DeviceKeys.NUM_PERIOD:
  641.           return 83;
  642.         case DeviceKeys.FN_Key:
  643.           return 256;
  644.         case DeviceKeys.LOGO:
  645.           return 257;
  646.         case DeviceKeys.ADDITIONALLIGHT1:
  647.           return 258;
  648.         case DeviceKeys.ADDITIONALLIGHT2:
  649.           return 259;
  650.         case DeviceKeys.OEM5:
  651.           return 6;
  652.         case DeviceKeys.OEMTilde:
  653.           return 41;
  654.         case DeviceKeys.OEM8:
  655.           return 9;
  656.         case DeviceKeys.OEM6:
  657.           return 7;
  658.         case DeviceKeys.OEM1:
  659.           return 2;
  660.         case DeviceKeys.OEMPlus:
  661.           return 13;
  662.         default:
  663.           return int.MaxValue;
  664.       }
  665.     }
  666.  
  667.     /// <summary>Determines the ushort ID from a DeviceKeys</summary>
  668.     /// <param name="key">The key to translate</param>
  669.     /// <returns>the index of that mouse LED</returns>
  670.     private static int DeviceKeyToAuraPeripheralKeyId(DeviceKeys key)
  671.     {
  672.       switch (key)
  673.       {
  674.         case DeviceKeys.Peripheral_Logo:
  675.           return 0;
  676.         case DeviceKeys.Peripheral_ScrollWheel:
  677.           return 1;
  678.         case DeviceKeys.Peripheral_FrontLight:
  679.           return 2;
  680.         default:
  681.           return int.MaxValue;
  682.       }
  683.     }
  684.  
  685.     private void LedTest(IAuraDevice device, int time)
  686.     {
  687.       this.SetDeviceLightsColor(device, Color.Black);
  688.       this.SetDeviceLightsColor(device, Color.Red);
  689.       Thread.Sleep(time);
  690.       this.SetDeviceLightsColor(device, Color.Green);
  691.       Thread.Sleep(time);
  692.       this.SetDeviceLightsColor(device, Color.Blue);
  693.       Thread.Sleep(time);
  694.       this.SetDeviceLightsColor(device, Color.Black);
  695.     }
  696.  
  697.     /// <summary>Can be called anywhere after int()</summary>
  698.     /// <param name="deviceCollection"></param>
  699.     private void Dump(IAuraDeviceCollection deviceCollection)
  700.     {
  701.       Global.logger.Info("------------ Dump Aura Device Info Start -------------");
  702.       foreach (IAuraDevice device in deviceCollection)
  703.       {
  704.         Global.logger.Info("Name:" + device.Name);
  705.         Global.logger.Info("Manufacture:" + device.Manufacture);
  706.         Global.logger.Info("Model:" + device.Model);
  707.         Global.logger.Info("Groups:" + device.Groups.Count.ToString());
  708.         Global.logger.Info("Lights:" + (object) device.Lights.Count);
  709.         Global.logger.Info("Type:" + string.Format("{0:X}", (object) device.Type));
  710.         if (AuraDevice.DEBUG_EFFECTS)
  711.         {
  712.           foreach (IAuraEffect effect in device.Effects)
  713.           {
  714.             Global.logger.Info("-------- Supported Lighting Effects -------");
  715.             Global.logger.Info("- Effect Name:" + effect.Name);
  716.             Global.logger.Info("- Effect ID:" + (object) effect.Id);
  717.             Global.logger.Info("- Effect Synchronized:" + (object) effect.Synchronized);
  718.           }
  719.         }
  720.         if (AuraDevice.DEBUG_GROUPS)
  721.         {
  722.           int num = 0;
  723.           foreach (IAuraRgbLightGroup group in device.Groups)
  724.           {
  725.             Global.logger.Info("-------- Device Group Info -------");
  726.             Global.logger.Info("- Group Name:" + group.Name);
  727.             Global.logger.Info("- Group ID:" + string.Format("{0:X}", (object) group.Id));
  728.             Global.logger.Info("- Group LED count:" + group.Count.ToString());
  729.             foreach (IAuraRgbLight auraRgbLight in group)
  730.             {
  731.               Global.logger.Info("-------- Device Group Light Info -------");
  732.               Global.logger.Info("-- Light name:" + auraRgbLight.Name);
  733.               Global.logger.Info("- Light Index Id: " + (object) num);
  734.               ++num;
  735.             }
  736.           }
  737.         }
  738.         if (AuraDevice.DEBUG_LIGHTS)
  739.         {
  740.           int num = 0;
  741.           foreach (IAuraRgbLight light in device.Lights)
  742.           {
  743.             Global.logger.Info("-------- Device Light Info -------");
  744.             Global.logger.Info("- Light Name:" + light.Name);
  745.             Global.logger.Info("- Light Index Id: " + (object) num);
  746.             ++num;
  747.           }
  748.         }
  749.       }
  750.       Global.logger.Info("------------Dump Aura Device Info Finished-------------");
  751.     }
  752.   }
  753. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top