Ejemplo n.º 1
0
        internal static void ResetInternal()
        {
            if (OnReset != null)
            {
                OnReset.Invoke();
            }

            OnSetup  = null;
            OnUpdate = null;
            OnReset  = null;
            OnActiveDeviceChanged = null;
            OnDeviceAttached      = null;
            OnDeviceDetached      = null;
            OnUpdateDevices       = null;
            OnCommitDevices       = null;

            DestroyDeviceManagers();
            DestroyDevices();

            playerActionSets.Clear();

            MouseProvider.Reset();
            KeyboardProvider.Reset();

            IsSetup = false;
        }
Ejemplo n.º 2
0
        public RenderFrame(KeyboardProvider keyboard)
        {
            KeyboardBitmap = keyboard.KeyboardBitmap(4);
            KeyboardBitmap.SetResolution(96, 96);

            MouseBitmap = new Bitmap(40, 40);
            MouseBitmap.SetResolution(96, 96);

            HeadsetBitmap = new Bitmap(40, 40);
            HeadsetBitmap.SetResolution(96, 96);

            GenericBitmap = new Bitmap(40, 40);
            GenericBitmap.SetResolution(96, 96);

            MousematBitmap = new Bitmap(40, 40);
            MousematBitmap.SetResolution(96, 96);

            using (var g = Graphics.FromImage(KeyboardBitmap))
                g.Clear(Color.Black);
            using (var g = Graphics.FromImage(MouseBitmap))
                g.Clear(Color.Black);
            using (var g = Graphics.FromImage(HeadsetBitmap))
                g.Clear(Color.Black);
            using (var g = Graphics.FromImage(GenericBitmap))
                g.Clear(Color.Black);
            using (var g = Graphics.FromImage(MousematBitmap))
                g.Clear(Color.Black);
        }
Ejemplo n.º 3
0
        public LuaKeyboardModule(LuaManager luaManager) : base(luaManager)
        {
            _keyboardProvider = luaManager.KeyboardProvider;

            // Register the KeyMatch type for usage in GetKeyPosition
            UserData.RegisterType(typeof(KeyMatch));
        }
Ejemplo n.º 4
0
        public DeviceVisualModel(KeyboardProvider keyboard, int x)
        {
            _x        = x;
            _keyboard = keyboard;

            DrawType = DrawType.Keyboard;
            VisualBitmapScalingMode = BitmapScalingMode.LowQuality;
        }
Ejemplo n.º 5
0
 public static ProfileModel GetProfile(KeyboardProvider keyboard, ModuleModel module, string name)
 {
     if (keyboard == null || module == null)
     {
         return(null);
     }
     return(ReadProfiles(keyboard.Slug + "/" + module.Name).FirstOrDefault(p => p.Name == name));
 }
Ejemplo n.º 6
0
 public static List <string> GetProfileNames(KeyboardProvider keyboard, ModuleModel module)
 {
     if (keyboard == null || module == null)
     {
         return(null);
     }
     return(ReadProfiles(keyboard.Slug + "/" + module.Name).Select(p => p.Name).ToList());
 }
Ejemplo n.º 7
0
        internal static void UpdateInternal()
        {
            AssertIsSetup();
            if (OnSetup != null)
            {
                OnSetup.Invoke();
                OnSetup = null;
            }

            if (!enabled)
            {
                return;
            }

            if (SuspendInBackground && !applicationIsFocused)
            {
                return;
            }

            currentTick++;
            UpdateCurrentTime();
            var deltaTime = currentTime - lastUpdateTime;

            MouseProvider.Update();
            KeyboardProvider.Update();

            UpdateDeviceManagers(deltaTime);

            CommandWasPressed = false;
            UpdateDevices(deltaTime);
            CommitDevices(deltaTime);

            var lastActiveDevice = ActiveDevice;

            UpdateActiveDevice();

            UpdatePlayerActionSets(deltaTime);

            // We wait to trigger OnActiveDeviceChanged until after UpdatePlayerActionSets
            // so binding name changes will have updated, which is more intuitive.
            if (lastActiveDevice != ActiveDevice && OnActiveDeviceChanged != null)
            {
                OnActiveDeviceChanged.Invoke(ActiveDevice);
            }

            if (OnUpdate != null)
            {
                OnUpdate.Invoke(currentTick, deltaTime);
            }

            lastUpdateTime = currentTime;
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Get all profiles matching the provided game
        /// </summary>
        /// <param name="game">The game to match</param>
        /// <param name="keyboard">The keyboard to match</param>
        /// <returns>All profiles matching the provided game</returns>
        public static List <ProfileModel> GetAll(EffectModel game, KeyboardProvider keyboard)
        {
            if (game == null)
            {
                throw new ArgumentNullException(nameof(game));
            }
            if (keyboard == null)
            {
                throw new ArgumentNullException(nameof(keyboard));
            }

            return(GetAll().Where(g => g.GameName.Equals(game.Name) && g.KeyboardSlug.Equals(keyboard.Slug)).ToList());
        }
Ejemplo n.º 9
0
        /// <summary>
        ///     Resizes layers that are shown in the editor and match exactly the full keyboard widht and height
        /// </summary>
        /// <param name="target">The new keyboard to adjust the layers for</param>
        public void ResizeLayers(KeyboardProvider target)
        {
            foreach (var layer in GetLayers())
            {
                if (!layer.LayerType.ShowInEdtor ||
                    !(Math.Abs(layer.Properties.Width - Width) < 0.01) ||
                    !(Math.Abs(layer.Properties.Height - Height) < 0.01))
                {
                    continue;
                }

                layer.Properties.Width  = target.Width;
                layer.Properties.Height = target.Height;
            }
        }
Ejemplo n.º 10
0
        public FrameModel(KeyboardProvider keyboard, bool renderMice, bool renderHeadsets, bool renderGenerics,
                          bool renderMousemats)
        {
            if (keyboard == null)
            {
                return;
            }

            // Setup bitmaps
            var x = 0;

            if (renderMice)
            {
                MouseModel = new DeviceVisualModel(DrawType.Mouse, x);
                x         += 20;
            }
            if (renderHeadsets)
            {
                HeadsetModel = new DeviceVisualModel(DrawType.Headset, x);
                x           += 20;
            }
            if (renderGenerics)
            {
                GenericModel = new DeviceVisualModel(DrawType.Generic, x);
                x           += 20;
            }
            if (renderMousemats)
            {
                MousematModel = new DeviceVisualModel(DrawType.Mousemat, x);
                x            += 20;
            }

            KeyboardModel = new DeviceVisualModel(keyboard, x);

            // If not rendering anything but keyboard, use keyboard height, else default to 40
            var height = 20;

            if (keyboard.Height * 4 > height)
            {
                height = keyboard.Height * 4;
            }
            _rect = new Rect(0, 0, x + keyboard.Width * 4, height);
        }
Ejemplo n.º 11
0
        /// <summary>
        ///     Represents a Rectangle on the keyboard which can be drawn to a Bitmap.
        ///     By default, a rectangle is the entire keyboard's size.
        /// </summary>
        /// <param name="keyboard">The keyboard this rectangle will be used for</param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="colors">An array of colors the ColorBlend will use</param>
        /// <param name="gradientMode"></param>
        public KeyboardRectangle(KeyboardProvider keyboard, int x, int y, List <Color> colors,
                                 LinearGradientMode gradientMode)
        {
            _keyboard            = keyboard;
            _rotationProgress    = 0;
            _blinkWorker.DoWork += BlinkWorker_DoWork;

            Scale   = 4;
            X       = x;
            Y       = y;
            Width   = keyboard.Width * Scale;
            Height  = keyboard.Height * Scale;
            Visible = true;
            Opacity = 255;

            ContainedBrush = true;
            GradientMode   = gradientMode;
            Rotate         = false;
            LoopSpeed      = 1;
            Colors         = colors;
        }
Ejemplo n.º 12
0
 public KeyboardChangedEventArgs(KeyboardProvider oldKeyboard, KeyboardProvider newKeyboard)
 {
     OldKeyboard = oldKeyboard;
     NewKeyboard = newKeyboard;
 }
Ejemplo n.º 13
0
        /// <summary>
        ///     Enables the given keyboard
        /// </summary>
        /// <param name="keyboardProvider"></param>
        public async void EnableKeyboard(KeyboardProvider keyboardProvider)
        {
            if (keyboardProvider == null)
            {
                throw new ArgumentNullException(nameof(keyboardProvider));
            }

            if (ChangingKeyboard || (ActiveKeyboard?.Name == keyboardProvider.Name))
            {
                return;
            }

            _logger.Debug("Trying to enable keyboard: {0}", keyboardProvider.Name);
            ChangingKeyboard = true;

            // Store the old keyboard so it can be used in the event we're raising later
            var oldKeyboard = ActiveKeyboard;

            // Release the current keyboard
            ReleaseActiveKeyboard();

            // Create a dialog to let the user know Artemis hasn't frozen
            ProgressDialogController dialog = null;

            if (DialogService.GetActiveWindow() != null)
            {
                dialog = await DialogService.ShowProgressDialog("Enabling keyboard",
                                                                $"Checking if keyboard '{keyboardProvider.Name}' can be enabled...", true);

                // May seem a bit cheesy, but it's tidier to have the animation finish
                await Task.Delay(500);
            }
            dialog?.SetIndeterminate();

            var canEnable = await keyboardProvider.CanEnableAsync(dialog);

            if (!canEnable)
            {
                if (dialog != null)
                {
                    await dialog.CloseAsync();
                }

                DialogService.ShowErrorMessageBox(keyboardProvider.CantEnableText);
                ActiveKeyboard = null;
                _generalSettings.LastKeyboard = null;
                _generalSettings.Save();
                _logger.Warn("Failed enabling keyboard: {0}", keyboardProvider.Name);
                ChangingKeyboard = false;
                return;
            }

            dialog?.SetMessage($"Enabling keyboard: {keyboardProvider.Name}...");

            // Setup the new keyboard
            ActiveKeyboard = keyboardProvider;
            await ActiveKeyboard.EnableAsync(dialog);

            EnableUsableDevices();

            _generalSettings.LastKeyboard = ActiveKeyboard.Name;
            _generalSettings.Save();

            RaiseKeyboardChangedEvent(new KeyboardChangedEventArgs(oldKeyboard, ActiveKeyboard));
            _logger.Debug("Enabled keyboard: {0}", keyboardProvider.Name);

            if (dialog != null)
            {
                await dialog.CloseAsync();
            }

            ChangingKeyboard = false;
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Casts an item at/towards the position of the mouse, or self casts.
        /// </summary>
        /// <param name="iID"></param>
        public static void CastItem(ItemID iID)
        {
            var playerSpellbook = UnitManager.MyChampion.GetSpellBook();
            var playerInventory = UnitManager.MyChampion.Inventory;

            if (playerInventory.HasItem(iID))
            {
                switch (playerInventory.GetItemByID(iID).Slot)
                {
                case ItemSlot.One:
                    if (playerSpellbook.GetSpellClass(SpellSlot.Item1).IsSpellReady)
                    {
                        KeyboardProvider.PressKey(KeyboardProvider.KeyBoardScanCodes.KEY_1);
                    }

                    break;

                case ItemSlot.Two:
                    if (playerSpellbook.GetSpellClass(SpellSlot.Item2).IsSpellReady)
                    {
                        KeyboardProvider.PressKey(KeyboardProvider.KeyBoardScanCodes.KEY_2);
                    }

                    break;

                case ItemSlot.Three:
                    if (playerSpellbook.GetSpellClass(SpellSlot.Item3).IsSpellReady)
                    {
                        KeyboardProvider.PressKey(KeyboardProvider.KeyBoardScanCodes.KEY_3);
                    }

                    break;

                case ItemSlot.Trinket:
                    if (playerSpellbook.GetSpellClass(SpellSlot.Trinket).IsSpellReady)
                    {
                        KeyboardProvider.PressKey(KeyboardProvider.KeyBoardScanCodes.KEY_4);
                    }

                    break;

                case ItemSlot.Five:
                    if (playerSpellbook.GetSpellClass(SpellSlot.Item4).IsSpellReady)
                    {
                        KeyboardProvider.PressKey(KeyboardProvider.KeyBoardScanCodes.KEY_5);
                    }

                    break;

                case ItemSlot.Six:
                    if (playerSpellbook.GetSpellClass(SpellSlot.Item5).IsSpellReady)
                    {
                        KeyboardProvider.PressKey(KeyboardProvider.KeyBoardScanCodes.KEY_6);
                    }

                    break;

                case ItemSlot.Seven:
                    if (playerSpellbook.GetSpellClass(SpellSlot.Item6).IsSpellReady)
                    {
                        KeyboardProvider.PressKey(KeyboardProvider.KeyBoardScanCodes.KEY_7);
                    }

                    break;
                }
            }
        }
Ejemplo n.º 15
0
 public ActiveKeyboardChanged(KeyboardProvider oldKeyboard, KeyboardProvider newKeyboard)
 {
     OldKeyboard = oldKeyboard;
     NewKeyboard = newKeyboard;
 }