示例#1
0
 public LedUpdater()
 {
     sdk = new AuraSdk() as IAuraSdk2;
     // Aquire control
     sdk.SwitchMode();
     // enumerate all devices
     devices = sdk.Enumerate(0);
 }
示例#2
0
        public AsusSdkAdapter()
        {
            var sdk = (IAuraSdk2) new AuraSdk();

            sdk.SwitchMode();
            var devices = sdk.Enumerate(528384);

            this._sdk = sdk;
            this._notebookKeyboard = devices.Count > 0 ? devices[0] : null;
        }
示例#3
0
        /// <inheritdoc />
        public void Dispose()
        {
            try { UpdateTrigger?.Dispose(); }
            catch { /* at least we tried */ }

            try { _sdk?.ReleaseControl(0); }
            catch { /* at least we tried */ }

            _sdk = null;
        }
示例#4
0
        public void Configure(DriverDetails driverDetails)
        {
            _sdk = (IAuraSdk2) new AuraSdk();
            _sdk.SwitchMode();
            _collection = _sdk.Enumerate(0);

            var drivers = GetDevices();

            foreach (ControlDevice controlDevice in drivers)
            {
                DeviceAdded?.Invoke(this, new Events.DeviceChangeEventArgs(controlDevice));
            }
        }
 /// <summary>
 /// Constructor for ASUS Rog Strix G15 (2021) laptop adapter.
 /// </summary>
 public AsusRogStrix_G15_2021_Adapter()
 {
     try
     {
         var sdk = (IAuraSdk2) new AuraSdk();
         sdk.SwitchMode();
         var devices = sdk.Enumerate(528384);
         this._sdk = sdk;
         this._notebookKeyboard = devices.Count > 0 ? devices[0] : throw new Exception("No Asus device attached.");
         this.Initialized       = true;
     }
     catch (Exception)
     {
         this.Initialized = false;
     }
 }
示例#6
0
        public AsusHandler(bool enableUnsupportedVersion = false)
        {
            try
            {
                if (CheckVersion(enableUnsupportedVersion, out string message))
                {
                    AuraSdk = new AuraSdk() as IAuraSdk2;
                }
                else
                {
                    AuraSdk = null;
                }

                Log(message);
            }
            catch
            {
                Log("AuraSDK not installed!");
                AuraSdk = null;
            }
        }
示例#7
0
        public AsusHandler(bool enableUnsupportedVersion = false, bool forceInitialize = false)
        {
            string message = "";

            try
            {
                if (CheckVersion(enableUnsupportedVersion, forceInitialize, out message))
                {
                    AuraSdk = new AuraSdk() as IAuraSdk2;
                }
                else
                {
                    AuraSdk = null;
                }

                Log(message);
            }
            catch (Exception e)
            {
                Log(message);
                Log("There was an error initializing the AuraSDK: " + e);
                AuraSdk = null;
            }
        }
示例#8
0
 public void Dispose()
 {
     _sdk?.ReleaseControl(0);
     _sdk = null;
 }
示例#9
0
 public void Configure(DriverDetails driverDetails)
 {
     _sdk = (IAuraSdk2) new AuraSdk();
     _sdk.SwitchMode();
     _collection = _sdk.Enumerate(0);
 }
示例#10
0
        /// <inheritdoc />
        public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
        {
            IsInitialized = false;

            try
            {
                UpdateTrigger?.Stop();

                // ReSharper disable once SuspiciousTypeConversion.Global
                _sdk = (IAuraSdk2) new AuraSdk();
                _sdk.SwitchMode();

                IList <IRGBDevice> devices = new List <IRGBDevice>();
                foreach (IAuraSyncDevice device in _sdk.Enumerate(0))
                {
                    try
                    {
                        IAsusRGBDevice rgbDevice;
                        switch ((AsusDeviceType)device.Type)
                        {
                        case AsusDeviceType.MB_RGB:
                            rgbDevice = new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, WMIHelper.GetMainboardInfo()?.model ?? device.Name));
                            break;

                        case AsusDeviceType.MB_ADDRESABLE:
                            rgbDevice = new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedStripe, device), LedId.LedStripe1);
                            break;

                        case AsusDeviceType.VGA_RGB:
                            rgbDevice = new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device));
                            break;

                        case AsusDeviceType.HEADSET_RGB:
                            rgbDevice = new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device));
                            break;

                        case AsusDeviceType.DRAM_RGB:
                            rgbDevice = new AsusDramRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.DRAM, device));
                            break;

                        case AsusDeviceType.KEYBOARD_RGB:
                        case AsusDeviceType.NB_KB_RGB:
                        case AsusDeviceType.NB_KB_4ZONE_RGB:
                            rgbDevice = new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device, CultureInfo.CurrentCulture));
                            break;

                        case AsusDeviceType.MOUSE_RGB:
                            rgbDevice = new AsusMouseRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mouse, device));
                            break;

                        default:
                            rgbDevice = new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Unknown, device), LedId.Custom1);
                            break;
                        }

                        if (loadFilter.HasFlag(rgbDevice.DeviceInfo.DeviceType))
                        {
                            rgbDevice.Initialize(UpdateTrigger);
                            devices.Add(rgbDevice);
                        }
                    }
                    catch
                    {
                        if (throwExceptions)
                        {
                            throw;
                        }
                    }
                }

                UpdateTrigger?.Start();

                Devices       = new ReadOnlyCollection <IRGBDevice>(devices);
                IsInitialized = true;
            }
            catch
            {
                if (throwExceptions)
                {
                    throw;
                }
                return(false);
            }
            return(true);
        }
示例#11
0
 public AuraSyncHub()
 {
     sdk          = (IAuraSdk2)(new AuraSdk());
     rgbLedsCache = new Dictionary <Tuple <int, int>, AuraSyncRgbLed>();
 }
示例#12
0
        /// <inheritdoc />
        public bool Initialize(RGBDeviceType loadFilter = RGBDeviceType.All, bool exclusiveAccessIfPossible = false, bool throwExceptions = false)
        {
            IsInitialized = false;

            try
            {
                UpdateTrigger?.Stop();

                // ReSharper disable once SuspiciousTypeConversion.Global
                _sdk = (IAuraSdk2) new AuraSdk();
                _sdk.SwitchMode();

                IList <IRGBDevice> devices = new List <IRGBDevice>();
                foreach (IAuraSyncDevice device in _sdk.Enumerate(0))
                {
                    try
                    {
                        IAsusRGBDevice rgbDevice = null;
                        switch (device.Type)
                        {
                        case 0x00010000:     //Motherboard
                            rgbDevice = new AsusMainboardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mainboard, device, WMIHelper.GetMainboardInfo()?.model ?? device.Name));
                            break;

                        case 0x00011000:     //Motherboard LED Strip
                            rgbDevice = new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.LedStripe, device), LedId.LedStripe1);
                            break;

                        case 0x00020000:     //VGA
                            rgbDevice = new AsusGraphicsCardRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.GraphicsCard, device));
                            break;

                        case 0x00040000:     //Headset
                            rgbDevice = new AsusHeadsetRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Headset, device));
                            break;

                        case 0x00070000:     //DRAM
                            rgbDevice = new AsusDramRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.DRAM, device));
                            break;

                        case 0x00080000:     //Keyboard
                        case 0x00081000:     //Notebook Keyboard
                        case 0x00081001:     //Notebook Keyboard(4 - zone type)
                            rgbDevice = new AsusKeyboardRGBDevice(new AsusKeyboardRGBDeviceInfo(device, CultureInfo.CurrentCulture));
                            break;

                        case 0x00090000:     //Mouse
                            rgbDevice = new AsusMouseRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Mouse, device));
                            break;

                        case 0x00000000:     //All
                        case 0x00012000:     //All - In - One PC
                        case 0x00030000:     //Display
                        case 0x00050000:     //Microphone
                        case 0x00060000:     //External HDD
                        case 0x00061000:     //External BD Drive
                        case 0x000B0000:     //Chassis
                        case 0x000C0000:     //Projector
                            rgbDevice = new AsusUnspecifiedRGBDevice(new AsusRGBDeviceInfo(RGBDeviceType.Unknown, device), LedId.Custom1);
                            break;
                        }

                        if ((rgbDevice != null) && loadFilter.HasFlag(rgbDevice.DeviceInfo.DeviceType))
                        {
                            rgbDevice.Initialize(UpdateTrigger);
                            devices.Add(rgbDevice);
                        }
                    }
                    catch
                    {
                        if (throwExceptions)
                        {
                            throw;
                        }
                    }
                }

                UpdateTrigger?.Start();

                Devices       = new ReadOnlyCollection <IRGBDevice>(devices);
                IsInitialized = true;
            }
            catch
            {
                if (throwExceptions)
                {
                    throw;
                }
                return(false);
            }
            return(true);
        }