KeyMapping is a named handler for 3 CustomInput.
        public override void Visit(KeyMapping mapping)
        {
            var writer = serviceLocator.GetWriter<KeyMapping>();
            var keyXml = writer.Write(mapping);

            document.ImportAndAppendChild(keyXml);
        }
        private CommandHandler[] handlers = new CommandHandler[256];    // 指令包处理器

        public override void before()
        {
            // 加载配置文件
            Configs.init(System.IO.Directory.GetCurrentDirectory() + "\\" + "config.ini");

            // 键盘映射初始化
            KeyMapping.init();

            // RLE压缩处理器初始化
            RLEncoding.init();

            // TODO: 单个可处理包大小不能超过400k
            this.byteBuffer = new ByteWriter(4096 * 100);

            // 包指令处理器
            handlers[Command.HEARTBEAT]       = heartbeat;
            handlers[Command.CONTROL_REQUEST] = requestControl;
            handlers[Command.CLOSE_REQUEST]   = closeControl;
            handlers[Command.GET_CLIPBOARD]   = readClipboard;
            handlers[Command.SET_CLIPBOARD]   = writeClipboard;
            handlers[Command.HID_COMMAND]     = hidCommandExec;
            handlers[Command.LIST_FILES]      = listFiles;
            handlers[Command.DOWNLOAD_FILE]   = transferFile;
            handlers[Command.UPLOAD_FILE]     = writeFile;
        }
Example #3
0
 // Writes a KeyMapping directly to file.
 public static void WriteMapping(KeyMapping keyMap)
 {
     using (StreamWriter outputFile = new StreamWriter(Path.Combine(DefaultSavePath, DefaultFileName)))
     {
         outputFile.Write(MapToString(keyMap));
     }
 }
Example #4
0
 public JoinedSubClassPart(AttributeStore underlyingStore)
 {
     attributes = new AttributeStore <SubclassMapping>(underlyingStore);
     keyMapping = new KeyMapping {
         ContainingEntityType = typeof(TSubclass)
     };
 }
Example #5
0
    private KeyCode ResolveKeyCode(int playerId, KeyMapping keyMap, ActionControl action)
    {
        KeyCode keyCode = KeyCode.None;

        switch (keyMap)
        {
        case KeyMapping.KeyBoard:
            keyCode = ResolveKeyBoardKeyCode(action);
            break;

        case KeyMapping.LogitechDualAction:
            keyCode = ResolveLogitechDualActionKeyCode(playerId, action);
            break;

        case KeyMapping.LogitechF310:
            keyCode = ResolveLogitechF310KeyCode(playerId, action);
            break;

        case KeyMapping.XBox360:
            keyCode = ResolveXBox360KeyCode(playerId, action);
            break;

        case KeyMapping.PS3:
            keyCode = ResolvePS3KeyCode(playerId, action);
            break;
        }
        return(keyCode);
    }
Example #6
0
        public static IHardwareKeyMappingTarget ConvertPressedKey(KeyEventArgs keyEventArgs, KeyboardDevice keyboardDevice)
        {
            var pressedKey       = keyEventArgs.Key; // To be more precise, that's the key that has been pressed and is now released
            var otherKeysPressed = EnumExtensions.GetValues <Key>()
                                   .Where(key => key != Key.None)
                                   .Where(key => (keyboardDevice.GetKeyStates(key) & KeyStates.Down) != 0)
                                   .ToList();

            var modifierKeys = otherKeysPressed.Where(ModifierKeys.ContainsKey).ToList();

            // Only valid if key is known!
            var valid = KeyMapping.ContainsKey(pressedKey);

            if (!valid)
            {
                return(null);
            }

            // Ignore other regular keys, but take into account modifiers
            var modifiers = modifierKeys
                            .Select(key => ModifierKeys[key])
                            .Aggregate(Modifier.None, (mod, acc) => mod | acc);
            var pressedConvertedKey = new HardwareKeyMappingTarget(KeyMapping[pressedKey], modifiers);

            return(pressedConvertedKey);
        }
Example #7
0
    /// <summary>
    /// Create new <see cref="Axis"/> with specified negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>.
    /// </summary>
    /// <returns>Created Axis.</returns>
    /// <param name="name">Axis name.</param>
    /// <param name="negative">Negative KeyMapping.</param>
    /// <param name="positive">Positive KeyMapping.</param>
    public Axis setAxis(string name, KeyMapping negative, KeyMapping positive, bool isTankDrive = false)
    {
        Axis outAxis = null;

        if (!isTankDrive)
        {
            if (arcadeAxesMap.TryGetValue(name, out outAxis))
            {
                outAxis.set(negative, positive);
            }
            else
            {
                outAxis = new Axis(name, negative, positive);

                arcadeAxesList.Add(outAxis);
                arcadeAxesMap.Add(name, outAxis);
            }
        }
        else
        {
            if (tankAxesMap.TryGetValue(name, out outAxis))
            {
                outAxis.set(negative, positive);
            }
            else
            {
                outAxis = new Axis(name, negative, positive);

                tankAxesList.Add(outAxis);
                tankAxesMap.Add(name, outAxis);
            }
        }

        return(outAxis);
    }
Example #8
0
        private void InitializeKeyMappingsCore(string keyMappingsMatrix)
        {
            keyMappingsByKeyId = new Dictionary <Keys, KeyMapping>();
            var keyMappings = new List <KeyMapping>();
            var rows        = keyMappingsMatrix.Split(new[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

            for (var rowIndex = 0; rowIndex < 11; rowIndex++)
            {
                var rowItems = rows[rowIndex].Split(new[] { "\t", " " }, StringSplitOptions.RemoveEmptyEntries);
                for (var columnIndex = 0; columnIndex <= 7; columnIndex++)
                {
                    var keyNames = rowItems[7 - columnIndex].Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (var keyName in keyNames)
                    {
                        var undefinedKey = keyName == ".";

                        if (!undefinedKey && !Enum.IsDefined(typeof(Keys), keyName))
                        {
                            throw new InvalidOperationException("Unknown key name: " + keyName);
                        }

                        var key     = undefinedKey ? 0 : (Keys)Enum.Parse(typeof(Keys), keyName);
                        var mapping = new KeyMapping(key, rowIndex, columnIndex);
                        keyMappings.Add(mapping);
                        keyMappingsByKeyId[key] = mapping;
                    }
                }
            }
        }
Example #9
0
        private void OnKeyPress(object sender, KeyMapperKeyPressedEventArgs e)
        {
            int scancode = e.Key.Scancode;
            int extended = e.Key.Extended;

            if (capturingFromKey)
            {
                // Have we been sent a dud??
                if (scancode == 0)
                {
                    // Can't use a disabled key as From
                    map = new KeyMapping();
                }
                else
                {
                    SetMapToBlankMapping(scancode, extended);
                }
            }
            else
            {
                // Can't tell from the passed key whether it's mapped or not as
                // if it is, we get the mapped scancode and have no way of telling
                // what the original key was (it's possible 2 keys could be mapped to the
                // same key, meaning can't just do a reverse lookup.)

                // So, mapping to a mapped key is de facto allowed.

                map = new KeyMapping(map.From, new Key(scancode, extended));
            }

            SetupForm();
        }
Example #10
0
        public KeyPictureBox(int scancode, int extended, BlankButton button, float scale, int horizontalStretch, int verticalStretch)
        {
            _scancode          = scancode;
            _extended          = extended;
            _button            = button;
            _scale             = scale;
            _horizontalStretch = horizontalStretch;
            _verticalStretch   = verticalStretch;
            _dragIconScale     = 0.75F;
            _dragbox           = Rectangle.Empty;

            Map = MappingsManager.GetKeyMapping(_scancode, _extended);

            _mapped = (Map.To.Scancode != -1);

            this.AllowDrop = true;

            // Box controls itself.
            this.DragOver          += KeyPictureBoxDragOver;
            this.DragDrop          += KeyPictureBoxDragDrop;
            this.DragLeave         += KeyPictureBoxDragLeave;
            this.GiveFeedback      += KeyPictureBoxGiveFeedback;
            this.MouseDown         += KeyPictureBoxMouseDown;
            this.MouseMove         += KeyPictureBoxMouseMove;
            this.MouseUp           += KeyPictureBoxMouseUp;
            this.QueryContinueDrag += KeyPictureBoxQueryContinueDrag;

            DrawKey();
            this.Width  = this.Image.Width;
            this.Height = this.Image.Height;
        }
Example #11
0
        void KeyPictureBoxDragOver(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent("KeyMapper.KeyMapping") == false)
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            KeyMapping dragged_map = (KeyMapping)e.Data.GetData("KeyMapper.KeyMapping");

            if (dragged_map.To.Scancode >= 0)
            {
                // Can't drop a mapped key onto another key
                e.Effect = DragDropEffects.None;
                return;
            }

            if (dragged_map.From == Map.From)
            {
                return;                 // No need to redraw self
            }
            // Console.WriteLine("Dragover: " + _scancode)

            this.SetImage(ButtonImages.GetButtonImage
                              (dragged_map.From.Scancode, dragged_map.From.Extended,
                              _button, _horizontalStretch, _verticalStretch, _scale, ButtonEffect.MappedPending));

            e.Effect = DragDropEffects.Copy;
        }
Example #12
0
        public List <int> BindKey(int actionCode, KeyCode keyCode, int bindIndex = 0, string actionNameOnNew = "")
        {
            int index = FindActionCode(actionCode);

            if (index >= 0)
            {
                if (FindKeyCode(mapList[index], keyCode) == false)
                {
                    mapList[index] = new KeyMapping {
                        inputName  = mapList[index].inputName,
                        actionCode = actionCode,
                        bind1      = bindIndex == 0 ? keyCode : mapList[index].bind1,
                        bind2      = bindIndex == 1 ? keyCode : mapList[index].bind2,
                    };
                }
            }
            else
            {
                mapList.Add(new KeyMapping {
                    inputName  = actionNameOnNew,
                    actionCode = actionCode,
                    bind1      = bindIndex == 0 ? keyCode : Default.nonAttachedKeyCode,
                    bind2      = bindIndex == 1 ? keyCode : Default.nonAttachedKeyCode,
                });
                index = mapList.Count;
            }

            return(ExistsKeyCodeIndex(keyCode, index));
        }
Example #13
0
        public static bool ReadKey(ILogger logger, KeyAction key)
        {
            if (string.IsNullOrEmpty(key.Key))
            {
                logger.LogError($"You must specify either 'Key' (ConsoleKey value) or 'KeyName' (ConsoleKey enum name) for { key.Name}");
                return(false);
            }

            if (KeyMapping.ContainsKey(key.Key))
            {
                key.ConsoleKey = KeyMapping[key.Key];
            }
            else
            {
                var consoleKey = consoleKeys.FirstOrDefault(k => k.ToString() == key.Key);
                if (consoleKey == 0)
                {
                    logger.LogError($"You must specify a valid 'KeyName' (ConsoleKey enum name) for { key.Name}");
                    return(false);
                }

                key.ConsoleKey = consoleKey;
            }

            if (!string.IsNullOrEmpty(key.Name))
            {
                logger.LogInformation($"[{key.Name}] uses \"{key.Key}\" -> {key.ConsoleKey}");
            }

            return(true);
        }
Example #14
0
        public KeyPictureBox(int scanCode, int extended, BlankButton button, float scale, int horizontalStretch, int verticalStretch)
        {
            this.scanCode          = scanCode;
            this.extended          = extended;
            this.button            = button;
            this.scale             = scale;
            this.horizontalStretch = horizontalStretch;
            this.verticalStretch   = verticalStretch;
            dragIconScale          = 0.75F;
            dragbox = Rectangle.Empty;

            Map = MappingsManager.GetKeyMapping(scanCode, extended);

            mapped = (Map.To.ScanCode != -1);

            AllowDrop = true;

            // Box controls itself.
            DragOver          += KeyPictureBoxDragOver;
            DragDrop          += KeyPictureBoxDragDrop;
            DragLeave         += KeyPictureBoxDragLeave;
            GiveFeedback      += KeyPictureBoxGiveFeedback;
            MouseDown         += KeyPictureBoxMouseDown;
            MouseMove         += KeyPictureBoxMouseMove;
            MouseUp           += KeyPictureBoxMouseUp;
            QueryContinueDrag += KeyPictureBoxQueryContinueDrag;

            DrawKey();
            Width  = Image.Width;
            Height = Image.Height;
        }
Example #15
0
    /// <summary>
    /// Create a new instance of <see cref="Axis"/> with specified negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>.
    /// </summary>
    /// <param name="name">Axis name.</param>
    /// <param name="negativeKeyMapping">Negative KeyMapping.</param>
    /// <param name="positiveKeyMapping">Positive KeyMapping.</param>
    public Axis(string name, KeyMapping negativeKeyMapping, KeyMapping positiveKeyMapping)
    {
        mName     = name;
        mInverted = false;

        Set(negativeKeyMapping, positiveKeyMapping);
    }
Example #16
0
    /// <summary>
    /// Create a new instance of <see cref="Axis"/> with specified negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>.
    /// </summary>
    /// <param name="name">Axis name.</param>
    /// <param name="negativeKeyMapping">Negative KeyMapping.</param>
    /// <param name="positiveKeyMapping">Positive KeyMapping.</param>
    public Axis(string name, KeyMapping negativeKeyMapping, KeyMapping positiveKeyMapping)
    {
        mName     = name;
        mInverted = false;

        set(negativeKeyMapping, positiveKeyMapping);
    }
Example #17
0
        SubclassMapping IIndeterminateSubclassMappingProvider.GetSubclassMapping(SubclassType type)
        {
            var mapping = new SubclassMapping(type);

            GenerateNestedSubclasses(mapping);

            attributes.SetDefault(x => x.Type, typeof(T));
            attributes.SetDefault(x => x.Name, typeof(T).AssemblyQualifiedName);
            attributes.SetDefault(x => x.DiscriminatorValue, typeof(T).Name);

            // TODO: un-hardcode this
            var key = new KeyMapping();

            key.AddDefaultColumn(new ColumnMapping {
                Name = typeof(T).BaseType.Name + "_id"
            });

            attributes.SetDefault(x => x.TableName, GetDefaultTableName());
            attributes.SetDefault(x => x.Key, key);

            // TODO: this is nasty, we should find a better way
            mapping.OverrideAttributes(attributes.CloneInner());

            foreach (var join in joins)
            {
                mapping.AddJoin(join);
            }

            foreach (var property in properties)
            {
                mapping.AddProperty(property.GetPropertyMapping());
            }

            foreach (var component in components)
            {
                mapping.AddComponent(component.GetComponentMapping());
            }

            foreach (var oneToOne in oneToOnes)
            {
                mapping.AddOneToOne(oneToOne.GetOneToOneMapping());
            }

            foreach (var collection in collections)
            {
                mapping.AddCollection(collection.GetCollectionMapping());
            }

            foreach (var reference in references)
            {
                mapping.AddReference(reference.GetManyToOneMapping());
            }

            foreach (var any in anys)
            {
                mapping.AddAny(any.GetAnyMapping());
            }

            return(mapping.DeepClone());
        }
        public override void Visit(KeyMapping keyMapping)
        {
            var writer = serviceLocator.GetWriter <KeyMapping>();
            var keyXml = writer.Write(keyMapping);

            document.ImportAndAppendChild(keyXml);
        }
Example #19
0
        public void ShouldWriteColumns()
        {
            var mapping = new KeyMapping();

            mapping.AddColumn(Layer.Defaults, new ColumnMapping("Column1"));

            writer.VerifyXml(mapping)
            .Element("column").Exists();
        }
Example #20
0
        private void RegisterKey(string identifier, KeyCode keyCode, string name, string description = "")
        {
            KeyMapping key = new KeyMapping(getIdentifier() + "/" + identifier, keyCode, KeyCode.None);

            key.keyGroupIdentifier = getIdentifier();
            key.keyName            = name;
            key.keyDescription     = description;
            InputManager.Instance.registerKeyMapping(key);
        }
Example #21
0
        void Form1_KeyUp(object sender, KeyEventArgs e)
        {
            byte note;

            if (KeyMapping.TryGetValue(e.KeyCode, out note))
            {
                midi.SimulateValue(new MidiValue(false, note));
            }
        }
Example #22
0
    public TouchInformation GetTouch(string _keyMappingName)
    {
        KeyMapping km = GetKeyMapping(_keyMappingName);

        if (km != null)
        {
            return(GetTouch(km.GetTouchId()));
        }
        return(null);
    }
Example #23
0
    public bool GetKey(int playerId, KeyMapping keyMap, ActionControl action)
    {
        KeyCode keyCode = ResolveKeyCode(playerId, keyMap, action);

        if (keyCode != KeyCode.None)
        {
            return(Input.GetKey(keyCode));
        }
        return(false);
    }
Example #24
0
        private KeyMapping RegisterKey(string identifier, KeyCode keyCode, string Name, string Description = "")
        {
            KeyMapping keyMapping = new KeyMapping(getIdentifier() + "/" + identifier, keyCode, KeyCode.None);

            keyMapping.keyGroupIdentifier = getIdentifier();
            keyMapping.keyName            = Name;
            keyMapping.keyDescription     = Description;
            ScriptableSingleton <InputManager> .Instance.registerKeyMapping(keyMapping);

            return(keyMapping);
        }
Example #25
0
        public void Init(string label, KeyMapping key, int index, Action <int, CustomInput> inputHandler, Action <int, Text> textHandler)
        {
            name       = label;
            keyMapping = key;
            keyIndex   = index;

            updateInputHandler = inputHandler;
            updateTextHandler  = textHandler;

            updateTextHandler(keyIndex, mKeyText);
        }
Example #26
0
        void InitialiseDefaults(Member member)
        {
            mapping.Member = member;
            mapping.SetDefaultValue(x => x.Name, member.Name);
            mapping.SetDefaultValue(x => x.TableName, mapping.ContainingEntityType.Name + member.Name);

            mapping.Key = key = new KeyMapping();
            key.AddDefaultColumn(new ColumnMapping {
                Name = mapping.ContainingEntityType.Name + "_id"
            });

            mapping.Index = index = new IndexMapping();
            mapping.Index.As <IndexMapping>(ix =>
                                            ix.SetDefaultValue(x => x.Type, new TypeReference(KeyType)));

            if (ValueType.IsSimpleType())
            {
                // value type value (element)
                mapping.Element = element = new ElementMapping();
                element.AddDefaultColumn(new ColumnMapping {
                    Name = "Value"
                });
                element.SetDefaultValue(x => x.Type, new TypeReference(typeof(TValue)));
            }
            else
            {
                // entity value
                mapping.Relationship = manyToMany = new ManyToManyMapping();
                manyToMany.Class     = new TypeReference(ValueType);
                manyToMany.AddDefaultColumn(new ColumnMapping {
                    Name = ValueType.Name + "_id"
                });
                manyToMany.ParentType = mapping.ContainingEntityType;
                manyToMany.ChildType  = ValueType;
            }

            if (KeyType.IsSimpleType())
            {
                mapping.Index.As <IndexMapping>(ix =>
                                                ix.AddDefaultColumn(new ColumnMapping {
                    Name = "Key"
                }));
            }
            else
            {
                mapping.Index.As <IndexMapping>(ix =>
                {
                    ix.IsManyToMany = true;
                    ix.AddDefaultColumn(new ColumnMapping {
                        Name = KeyType.Name + "_id"
                    });
                });
            }
        }
Example #27
0
        /// <summary>
        /// Record the value of the temporary key in EntityKeyMapping
        /// </summary>
        /// <param name="entityInfo"></param>
        private void AddKeyMapping(EntityInfo entityInfo, Type type, IClassMetadata meta)
        {
            var entity = entityInfo.Entity;
            var id     = GetIdentifier(entity, meta);
            var km     = new KeyMapping()
            {
                EntityTypeName = type.FullName, TempValue = id
            };

            EntityKeyMapping.Add(entityInfo, km);
        }
        public void ShouldWriteColumns()
        {
            var mapping = new KeyMapping();

            mapping.AddColumn(new ColumnMapping {
                Name = "Column1"
            });

            writer.VerifyXml(mapping)
            .Element("column").Exists();
        }
Example #29
0
        public KeyMapping ReadMapping()
        {
            KeyMapping xResult = null;

            while (mBuffer.Count == 0 || !GetKeyMapping(mBuffer.Dequeue(), out xResult))
            {
                //Global.Sleep(10); //ToDo optimize value
                Core.Global.CPU.Halt();
            }
            return(xResult);
        }
Example #30
0
    /// <summary>
    /// Creates new <see cref="KeyMapping"/> with specified name, primary CustomInput, and secondary CustomInput.
    /// </summary>
    /// <returns>Created KeyMapping.</returns>
    /// <param name="name">KeyMapping name.</param>
    /// <param name="primary">Primary input.</param>
    /// <param name="secondary">Secondary input.</param>
    /// <param name="isTankDrive">Boolean to check if TankDrive is active.</param>
    public KeyMapping setKey(string name, CustomInput primary = null, CustomInput secondary = null, bool isTankDrive = false)
    {
        KeyMapping outKey     = null; //Key to return
        KeyMapping defaultKey = null; //Key to store default key preferances (for resetting individual player lists)

        if (!isTankDrive)             //Arcade Drive Enabled
        {
            if (arcadeDriveMap.TryGetValue(name, out outKey) && resetArcadeDriveMap.TryGetValue(name, out outKey))
            {
                outKey.primaryInput   = primary;
                outKey.secondaryInput = secondary;
            }
            else
            {
                //Sets controls to the main key list (outKey) and the default list
                //(defaultKey stores controls (defaults) at initialization)
                outKey     = new KeyMapping(name, primary, secondary);
                defaultKey = new KeyMapping(name, primary, secondary);

                //Assigns each list with correct key
                arcadeDriveList.Add(outKey);
                resetArcadeDriveList.Add(defaultKey);

                //Assigns each key map with the correct name and key (dependent on the list)
                arcadeDriveMap.Add(name, outKey);
                resetArcadeDriveMap.Add(name, defaultKey);
            }
        }
        else //Tank Drive Enabled
        {
            if (tankDriveMap.TryGetValue(name, out outKey) && resetTankDriveMap.TryGetValue(name, out outKey))
            {
                outKey.primaryInput   = primary;
                outKey.secondaryInput = secondary;
            }
            else
            {
                //Sets controls to the main key list (outKey) and the default list
                //(defaultKey stores controls (defaults) at initialization)
                outKey     = new KeyMapping(name, primary, secondary);
                defaultKey = new KeyMapping(name, primary, secondary);

                //Assigns each list with correct key
                tankDriveList.Add(outKey);
                resetTankDriveList.Add(defaultKey);

                //Assigns each key map with the correct name and key (dependent on the list)
                tankDriveMap.Add(name, outKey);
                resetTankDriveMap.Add(name, defaultKey);
            }
        }
        return(outKey);
    }
        public void SetKey(Member property, ClassMappingBase classMap, ICollectionMapping mapping)
        {
            var columnName = property.DeclaringType.Name + "_id";
            var key        = new KeyMapping();

            key.ContainingEntityType = classMap.Type;
            key.AddDefaultColumn(new ColumnMapping {
                Name = columnName
            });

            mapping.SetDefaultValue(x => x.Key, key);
        }
Example #32
0
 public void Init(string label, KeyMapping key, int index)
 {
     Init(label, key, index,
          (int dummy, CustomInput input) =>
     {
         keyMapping.GetInput(keyIndex) = input;
     },
          (int dummy, Text dummy2) =>
     {
         mKeyText.text = keyMapping.GetInput(keyIndex).ToString();
     });
 }
 /// <summary>
 /// Returns true the first frame the user releases the virtual button.
 /// </summary>
 /// <returns><c>true</c>, if user releases the button during the frame, <c>false</c> otherwise.</returns>
 //// <param name="button">KeyMapping instance.</param>
 /// <param name="exactKeyModifiers">If set to <c>true</c> check that only specified key modifiers are active, otherwise check that at least specified key modifiers are active.</param>
 public static bool GetButtonUp(KeyMapping button, bool exactKeyModifiers = false)
 {
     return button.IsPressedUp(exactKeyModifiers, sInputDevice);
 }
    /// <summary>
    /// Create new <see cref="KeyMapping"/> with specified name and inputs.
    /// </summary>
    /// <returns>Created KeyMapping.</returns>
    /// <param name="name">KeyMapping name.</param>
    /// <param name="primary">Primary input.</param>
    /// <param name="secondary">Secondary input.</param>
    /// <param name="third">Third input.</param>
    public static KeyMapping SetKey(string name, CustomInput primary=null, CustomInput secondary=null, CustomInput third=null)
    {
        KeyMapping outKey = null;

        if (sKeysMap.TryGetValue(name, out outKey))
        {
            outKey.primaryInput   = primary;
            outKey.secondaryInput = secondary;
            outKey.thirdInput     = third;
        }
        else
        {
            outKey = new KeyMapping(name, primary, secondary, third);

            sKeysList.Add(outKey);
            sKeysMap.Add(name, outKey);
        }

        return outKey;
    }
    /// <summary>
    /// Create new <see cref="Axis"/> with specified negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>.
    /// </summary>
    /// <returns>Created Axis.</returns>
    /// <param name="name">Axis name.</param>
    /// <param name="negative">Negative KeyMapping.</param>
    /// <param name="positive">Positive KeyMapping.</param>
    public static Axis SetAxis(string name, KeyMapping negative, KeyMapping positive)
    {
        Axis outAxis = null;

        if (sAxesMap.TryGetValue(name, out outAxis))
        {
            outAxis.Set(negative, positive);
        }
        else
        {
            outAxis = new Axis(name, negative, positive);

            sAxesList.Add(outAxis);
            sAxesMap.Add(name, outAxis);
        }

        return outAxis;
    }
    /// <summary>
    /// Removes specified <see cref="KeyMapping"/>.
    /// </summary>
    /// <param name="key">KeyMapping instance.</param>
    public static void RemoveKey(KeyMapping key)
    {
        bool good = true;

        if (!sKeysList.Remove(key))
        {
            good = false;
        }

        if (!sKeysMap.Remove(key.name))
        {
            good = false;
        }

        if (!good)
        {
            Debug.LogError("Failed to remove key \"" + key.name + "\"");
        }
    }
Example #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ControlSetter"/> class.
 /// </summary>
 public ControlSetter() : base()
 {
     mKeyMapping = new KeyMapping();
     mKeyPressed = -1;
 }
Example #38
0
 /// <summary>
 /// Set negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>.
 /// </summary>
 /// <param name="negativeKeyMapping">Negative KeyMapping.</param>
 /// <param name="positiveKeyMapping">Positive KeyMapping.</param>
 public void Set(KeyMapping negativeKeyMapping, KeyMapping positiveKeyMapping)
 {
     negative = negativeKeyMapping;
     positive = positiveKeyMapping;
 }
Example #39
0
 public bool IsKeyDown( KeyMapping mapping )
 {
     Key key = Keys[mapping];
     return Keyboard[key];
 }
Example #40
0
 public Key this[KeyMapping key]
 {
     get { return Keys[(int)key]; }
     set { Keys[(int)key] = value; SaveKeyBindings(); }
 }
Example #41
0
 /// <summary>
 /// Returns true during the frame the user pressed down the virtual button.
 /// </summary>
 /// <returns><c>true</c>, if user pressed down the button during the frame, <c>false</c> otherwise.</returns>
 /// <param name="button">KeyMapping instance.</param>
 /// <param name="exactKeyModifiers">If set to <c>true</c> check that only specified key modifiers are active, otherwise check that at least specified key modifiers are active.</param>
 public static bool GetButtonDown(KeyMapping button, bool exactKeyModifiers = false)
 {
     return button.isPressedDown(exactKeyModifiers, mInputDevice);
 }
Example #42
0
 /// <summary>
 /// Create a new instance of <see cref="Axis"/> with specified negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>.
 /// </summary>
 /// <param name="name">Axis name.</param>
 /// <param name="negative">Negative KeyMapping.</param>
 /// <param name="positive">Positive KeyMapping.</param>
 public Axis(string name, KeyMapping negative, KeyMapping positive)
 {
     mName     = name;
     mInverted = false;
     set(negative, positive);
 }
Example #43
0
 /// <summary>
 /// Set the same negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/> as in another instance.
 /// </summary>
 /// <param name="another">Another Axis instance.</param>
 public void Set(Axis another)
 {
     mNegative = another.mNegative;
     mPositive = another.mPositive;
     mInverted = another.mInverted;
 }
Example #44
0
 /// <summary>
 /// Set the same <see cref="CustomInput"/> as in another instance.
 /// </summary>
 /// <param name="another">Another KeyMapping instance.</param>
 public void set(KeyMapping another)
 {
     mPrimaryInput   = another.mPrimaryInput;
     mSecondaryInput = another.mSecondaryInput;
     mThirdInput     = another.mThirdInput;
 }
Example #45
0
 /// <summary>
 /// Set negative <see cref="KeyMapping"/> and positive <see cref="KeyMapping"/>.
 /// </summary>
 /// <param name="negative">Negative KeyMapping.</param>
 /// <param name="positive">Positive KeyMapping.</param>
 public void set(KeyMapping negative, KeyMapping positive)
 {
     mNegative = negative;
     mPositive = positive;
 }
Example #46
0
    /// <summary>
    /// Initializes a new instance of the <see cref="KeyMapping"/> class based on another instance.
    /// </summary>
    /// <param name="another">Another KeyMapping instance.</param>
    public KeyMapping(KeyMapping another)
    {
        mName = another.mName;

        set(another);
    }
Example #47
0
        public bool GetKeyMapping(uint aScanCode, out KeyMapping aValue) {
            for (int i = 0; i < mKeys.Count; i++) {

                if (mKeys[i].Scancode == aScanCode) {
                    aValue = mKeys[i];
                    return true;
                }
            }

            aValue = null;
            return false;
        }
Example #48
0
        public bool GetMapping(out KeyMapping c) {
            c = null;

            if (mBuffer.Count > 0) {
                GetKeyMapping(mBuffer.Dequeue(), out c);
                return true;
            } else {
                return false;
            }
        }