public void InputMapping_ShouldSetDefinedAxisStatesToZero_WhenSetWithAxisMappingGroups()
        {
            // Arrange
            var inputComponent = new InputComponent();

            var inputMapping = new InputMapping();

            var axisMapping1 = new AxisMapping {
                AxisName = "Axis 1"
            };
            var axisMapping2 = new AxisMapping {
                AxisName = "Axis 2"
            };

            inputMapping.AxisMappings.Add(axisMapping1);
            inputMapping.AxisMappings.Add(axisMapping2);

            // Act
            inputComponent.InputMapping = inputMapping;

            // Assert
            Assert.That(inputComponent.AxisStates.Count, Is.EqualTo(2));
            Assert.That(inputComponent.AxisStates[axisMapping1.AxisName], Is.Zero);
            Assert.That(inputComponent.AxisStates[axisMapping2.AxisName], Is.Zero);
        }
        public void InputMapping_ShouldSetDefinedActionStatesToFalse_WhenSetWithActionMappingGroups()
        {
            // Arrange
            var inputComponent = new InputComponent();

            var inputMapping = new InputMapping();

            var actionMapping1 = new ActionMapping {
                ActionName = "Action 1"
            };
            var actionMapping2 = new ActionMapping {
                ActionName = "Action 2"
            };

            inputMapping.ActionMappings.Add(actionMapping1);
            inputMapping.ActionMappings.Add(actionMapping2);

            // Act
            inputComponent.InputMapping = inputMapping;

            // Assert
            Assert.That(inputComponent.ActionStates.Count, Is.EqualTo(2));
            Assert.That(inputComponent.ActionStates[actionMapping1.ActionName], Is.False);
            Assert.That(inputComponent.ActionStates[actionMapping2.ActionName], Is.False);
        }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        foregroundSpriteJD.ResetAnchors();
        foregroundSpritePolimi.ResetAnchors();
        foregroundSpriteJD.UpdateAnchors();
        foregroundSpritePolimi.UpdateAnchors();

        if (Time.timeSinceLevelLoad > 6.0f && !started)
        {
            backgrounSprite.color        = Color.white;
            foregroundSpritePolimi.alpha = 0f;
            foregroundSpriteJD.alpha     = 1f;
            uiCamera.audio.Play();
            started = true;
        }

        if (InputMapping.GetAction(Actions.Skip) > 0)
        {
            Application.LoadLevel("LevelSelectionMenu");
        }

        if (Input.GetMouseButtonDown(0))
        {
            Application.LoadLevel("LevelSelectionMenu");
        }

        if (!uiCamera.audio.isPlaying && started)
        {
            Application.LoadLevel("LevelSelectionMenu");
        }
    }
Esempio n. 4
0
        //////////////////////////////////////////////////////////////////////////////

        #region Field state

        private void ReadFieldState(Peer peer, NetIncomingMessage message)
        {
            game = new Game(MultiplayerMode.Client);

            SetupField(settings.scheme);
            ReadFieldState(message);

            m_localPlayer = null;

            List <Player> players = game.GetPlayers().list;

            for (int i = 0; i < players.Count; ++i)
            {
                if (players[i].input == null)
                {
                    m_localPlayer = players[i];
                    m_localPlayer.SetPlayerInput(InputMapping.CreatePlayerInput(InputType.Keyboard1));
                    m_localPlayer.input.IsActive = true; // TODO: handle console
                    break;
                }
            }

            Debug.Assert(m_localPlayer != null);
            m_localPlayer.connection      = peer.RemoteConnection;
            m_localPlayer.IsReady         = true;
            m_localPlayer.needsFieldState = false;
        }
        public void SerializeAndDeserialize_WhenInputMappingIsNotNull()
        {
            // Arrange
            var inputMapping        = new InputMapping();
            var inputMappingAssetId = AssetId.CreateUnique();

            var component = new InputComponent
            {
                InputMapping = inputMapping
            };

            AssetStore.GetAssetId(inputMapping).Returns(inputMappingAssetId);
            AssetStore.GetAsset <InputMapping>(inputMappingAssetId).Returns(inputMapping);

            // Act
            var actual = SerializeAndDeserialize(component);

            // Assert
            Assert.That(actual.InputMapping, Is.EqualTo(inputMapping));
            Assert.That(actual.HardwareInput, Is.EqualTo(HardwareInput.Empty));
            Assert.That(actual.ActionBindings, Is.Empty);
            Assert.That(actual.AxisBindings, Is.Empty);
            Assert.That(actual.ActionStates, Is.Empty);
            Assert.That(actual.AxisStates, Is.Empty);
        }
Esempio n. 6
0
 void Start()
 {
     Cursor.lockState = CursorLockMode.Locked;
     Cursor.visible   = false;
     rigid            = GetComponent <Rigidbody>();
     inputMapping     = GameObject.Find("Input").GetComponent <InputMapping>();
 }
Esempio n. 7
0
		public void RemoveMap(InputMapping relMap)
		{

			Undo.DestroyObjectImmediate(relMap);
			Undo.SetCurrentGroupName("Removed Input Map");
			Undo.RecordObject(manager, "Removed Input Map");
			manager.RefreshInputMappings();
			return;

			////var tempList = manager.inputMappings.ToList();
			////tempList.Remove(relMap);
			////manager.inputMappings = tempList.ToArray();
			//InputMapping[] tempMappings = new InputMapping[manager.inputMappings.Length - 1];

			//int removeIndex = 0;

			//for (int i = 0, o = 0; i < manager.inputMappings.Length; i++)
			//{
			//	if (manager.inputMappings[i] == relMap)
			//	{
			//		o = 1;
			//		removeIndex = i;
			//	}
			//	else
			//	{
			//		tempMappings[i - o] = manager.inputMappings[i];
			//	}
			//}
			//if (manager.inputMappings[removeIndex])
			//	DestroyImmediate(manager.inputMappings[removeIndex].gameObject);
			//manager.inputMappings = new InputMapping[tempMappings.Length];
			//manager.inputMappings = tempMappings;
		}
Esempio n. 8
0
    void Start()
    {
        Debug.Log(InputMapping.getValidControllersCount());

        foreach (var ID in InputMapping.getValidControllersID())
        {
            Debug.Log(ID);
        }

        InputMapping.useController(1);

        selectedIsland          = 0;
        this.transform.position = new Vector3(islands[0].transform.position.x, this.transform.position.y, islands[0].transform.position.z);
        selectors[0].SetActive(true);
        tweenPos = camera.GetComponent <TweenPosition>();
        tweenPos.ignoreTimeScale = true;
        tweenPos.duration        = tweenDuration;
        tweenPos.style           = UITweener.Style.Once;
        tweenPos.method          = UITweener.Method.EaseInOut;
        numberOfIsles            = positions.Count;
        staticPositions          = islands;
        currentIsland            = islands[selectedIsland].GetComponent <IslandDescriptor>();
        previousIsland           = null;

        if (islandTransitionEnd != null)
        {
            islandTransitionEnd(previousIsland, currentIsland, LevelCorner.Left);
        }
    }
Esempio n. 9
0
    public static InputMapping AddMap(ref InputManager _manager, string newName)
    {
        var parent = _manager.transform.Find("InputMappings");

        if (!parent)
        {
            new GameObject("InputMappings").transform.parent = _manager.transform;
            return(AddMap(ref _manager, newName));
        }
        InputMapping tempMapping = (InputMapping)Undo.AddComponent(parent.gameObject, typeof(InputMapping));

        Undo.SetCurrentGroupName("Added Input Map" + newName);
        tempMapping.mapName = newName;
        Undo.RecordObject(_manager, "Added Input Map" + newName);
        _manager.RefreshInputMappings();
        Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
        // = parent.gameObject.AddComponent<>();
        //var tempMapping = new GameObject(newName, typeof(InputMapping)).GetComponent<InputMapping>();
        //tempMapping.transform.parent = parent;
        //, "Added Input Map"



        //var tempList = _manager.inputMappings.ToList();
        //tempList.Add(tempMapping);
        //_manager.inputMappings = tempList.ToArray();
        //Undo.RegisterCreatedObjectUndo(tempMapping, "Added Input Map");


        return(tempMapping);
    }
Esempio n. 10
0
            public void AddInputWithSampleMouseAxisMappings(out InputComponent inputComponent, out AxisMapping lookRight, out AxisMapping lookUp)
            {
                lookRight = new AxisMapping {
                    AxisName = nameof(lookRight)
                };
                lookRight.HardwareAxes.Add(new HardwareAxis
                {
                    HardwareInputVariant = HardwareInputVariant.CreateMouseVariant(HardwareInputVariant.MouseVariant.AxisX),
                    Scale = 1.0
                });

                lookUp = new AxisMapping {
                    AxisName = nameof(lookUp)
                };
                lookUp.HardwareAxes.Add(new HardwareAxis
                {
                    HardwareInputVariant = HardwareInputVariant.CreateMouseVariant(HardwareInputVariant.MouseVariant.AxisY),
                    Scale = 1.0
                });

                var inputMapping = new InputMapping();

                inputMapping.AxisMappings.Add(lookUp);
                inputMapping.AxisMappings.Add(lookRight);

                inputComponent = new InputComponent {
                    InputMapping = inputMapping
                };

                var entity = new Entity();

                entity.AddComponent(inputComponent);

                _scene.AddEntity(entity);
            }
Esempio n. 11
0
        private void UpdateMapping(InputMapping mapping, String inputField, String inputValue)
        {
            String currentValue = GetInputMappingValue(mapping, inputField);

            if (!selectedControlModified)
            {
                Console.WriteLine("--> " + inputField + ": No changes");

                SetControlText(GetControlByControlName(selectedControl), currentValue);
            }
            else if (currentValue != inputValue)
            {
                Console.WriteLine("--> " + inputField + ": Setting value to '" + inputValue + "'");

                mapping.SetControlProperty(inputField, inputValue);

                SetControlText(GetControlByControlName(selectedControl), inputValue);
            }
            else if (SelectedInputConfigState.DisabledOnInput)
            {
                Console.WriteLine("--> " + inputField + ": Setting value to ''");

                mapping.SetControlProperty(inputField, "");

                SetControlText(GetControlByControlName(selectedControl), "");
            }
        }
Esempio n. 12
0
 public void OnToggleAllDevices()
 {
     PlayerPrefs.SetInt("alldevices", (!this._allDevicesCheckbox.value) ? 0 : 1);
     PlayerPrefs.Save();
     InputMapping.InitControllers();
     this.ResetUI();
 }
Esempio n. 13
0
 void Update()
 {
     if (InputMapping.GetAction(Actions.Quit) > 0)
     {
         Application.LoadLevel("Abouts");
     }
 }
Esempio n. 14
0
 // Initialization
 void Awake()
 {
     _animator         = GetComponent <Animator>();
     inputMap          = GameObject.Find("Input Manager").GetComponent <InputMapping>();
     rb                = GetComponent <Rigidbody2D>();
     rb.freezeRotation = true;
 }
 // Update is called once per frame
 void Update()
 {
     if (InputMapping.GetAction(Actions.Quit) > 0 || InputMapping.GetAction(Actions.Skip) > 0)
     {
         Application.Quit();
     }
 }
Esempio n. 16
0
    // Update is called once per frame
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }
        if (!WindowFocus.hasFocus)
        {
            Debug.Log("WindowFocus.HasFocus()" + WindowFocus.hasFocus);
            return;
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            moving = !moving;
        }


        AlertPercentRotation(InputMapping.HorizontalAxis(controller));
        RotatePitch(InputMapping.VerticalAxis(controller));
        Turn();
        LockZTurnAxis();
        MoveForward();


        RotateBody();
    }
Esempio n. 17
0
 private async Task <Validation <Error, InputMapping> > InputMappingMustExist(InputMapping inputMapping)
 => await _inputMappingRepository
 .AnyAsync(e => e.Key == inputMapping.Key && e.InputType == inputMapping.InputType)
 .Map(exist => !exist
             ? Fail <Error, InputMapping>(
          $"Input mapping key {inputMapping.Key} and type {inputMapping.InputType} does not exist")
             : Success <Error, InputMapping>(inputMapping));
        public UnityUnknownDeviceProfile(string joystickName)
        {
            Name = "Unknown Device";
            if (joystickName != "")
            {
                Name += " (" + joystickName + ")";
            }

            Meta          = "";
            Sensitivity   = 1.0f;
            LowerDeadZone = 0.2f;

            SupportedPlatforms = null;
            JoystickNames      = new[] { joystickName };

            AnalogMappings = new InputMapping[UnityInputDevice.MaxAnalogs];
            for (var i = 0; i < UnityInputDevice.MaxAnalogs; i++)
            {
                AnalogMappings[i] = new InputMapping {
                    Handle = "Analog " + i,
                    Source = Analog(i),
                    Target = InputTarget.Analog0 + i
                };
            }

            ButtonMappings = new InputMapping[UnityInputDevice.MaxButtons];
            for (var i = 0; i < UnityInputDevice.MaxButtons; i++)
            {
                ButtonMappings[i] = new InputMapping {
                    Handle = "Button " + i,
                    Source = Button(i),
                    Target = InputTarget.Button0 + i
                };
            }
        }
Esempio n. 19
0
    public void AddGrab()
    {
        InputMapping grabMapping = AddMap("Grab");

        grabMapping.axisType = InputMapping.AxisType.Axis1D;
        grabMapping.type1D   = InputMapping.InputTypeAxis1D.Hand;
    }
Esempio n. 20
0
        public static bool ProcessInput(Key key, ModifierKeys modifiers)
        {
            string shortcut = GetShortcut(key, modifiers);

            InputMapping mapping = CommandMappings.FirstOrDefault(c => c.KeyboardShortcut == shortcut);

            if (mapping == null)
            {
                return(false);
            }

            if (!Commands.ContainsKey(mapping.CommandId))
            {
                return(false);
            }

            ScriptplayerCommand command = Commands[mapping.CommandId];

            if (!command.CanExecute(null))
            {
                return(false);
            }

            command.Execute(null);
            return(true);
        }
Esempio n. 21
0
        private static void ProcessInputMapping(RawInputHidData data, InputMapping mapping)
        {
            var allValues = data.ValueSetStates.SelectMany(x => x).ToArray();

            // TODO: This relies on a complex process of encountering errors, encoding those errors into exceptions, and throwing exceptions
            //  On the whole, this is probably very slow.
            // We can speed up the whole thing by forgoing RawInput.Sharp and implementing it ourselves, caching device data and checking
            //  what reports each axis is under.

            foreach (var axis in mapping.Axes)
            {
                var maybeValue = TryGetNormalizedValue(allValues, axis.AxisUsage);
                if (!maybeValue.HasValue)
                {
                    continue;
                }

                var value = maybeValue.Value;
                if (axis.Invert)
                {
                    value = -value;
                }

                var inputId = new InputIdentifier(data.Device.VendorId, data.Device.ProductId, axis.GameAxis);
                sInputs[inputId] = value;

                SixAxisPlugin.Instance.ReceivedControllerInput();
            }
        }
    void Start()
    {
        inputMapping     = new InputMapping();
        levelsAttributes = new LevelsAttributes();

        sceneID = LevelsAttributes.currentLevelId;

                #if UNITY_ANDROID
        inputMapping.idController = "Android";

        instantiatePlayer(sceneID, PlayerCharacter.GHOST, levelsAttributes.getInitialPositionFromID(sceneID),
                          inputMapping.idController, getKeysBasedOnController(inputMapping.idController));

        CustomGUI gui = GameObject.Find("CustomGUI").GetComponent <CustomGUI>();
        gui.initializeButtonsAndroid();
                #endif

                #if UNITY_STANDALONE_WIN || UNITY_WEBPLAYER
        string idController = inputMapping.idController;
        instantiatePlayer(sceneID, PlayerCharacter.GHOST, levelsAttributes.getInitialPositionFromID(sceneID),
                          idController, getKeysBasedOnController(idController));
                #endif

        SizeFixer sizeFixer = new SizeFixer();
        namePlayer = sizeFixer.getRectFixResolution(1900, 20, 300, 200);
        coinsRect  = sizeFixer.getRectFixResolution(1600, 20, 100, 50);

        nameStyle          = new GUIStyle();
        nameStyle.fontSize = 17;
    }
Esempio n. 23
0
        // ReSharper disable once CyclomaticComplexity
        public Option <ICommand> HandleKeyInput(int key)
        {
            Player player = Game.Player;

            switch (InputMapping.GetNormalInput(key))
            {
            case NormalInput.None:
                return(Option.None <ICommand>());

                #region Movement Keys
            case NormalInput.MoveW:
                return(Option.Some <ICommand>(new MoveCommand(player, player.Pos + Direction.W)));

            case NormalInput.MoveS:
                return(Option.Some <ICommand>(new MoveCommand(player, player.Pos + Direction.S)));

            case NormalInput.MoveN:
                return(Option.Some <ICommand>(new MoveCommand(player, player.Pos + Direction.N)));

            case NormalInput.MoveE:
                return(Option.Some <ICommand>(new MoveCommand(player, player.Pos + Direction.E)));

            case NormalInput.MoveNW:
                return(Option.Some <ICommand>(new MoveCommand(player, player.Pos + Direction.NW)));

            case NormalInput.MoveNE:
                return(Option.Some <ICommand>(new MoveCommand(player, player.Pos + Direction.NE)));

            case NormalInput.MoveSW:
                return(Option.Some <ICommand>(new MoveCommand(player, player.Pos + Direction.SW)));

            case NormalInput.MoveSE:
                return(Option.Some <ICommand>(new MoveCommand(player, player.Pos + Direction.SE)));

            case NormalInput.Wait:
                return(Option.Some <ICommand>(new WaitCommand(player)));

                #endregion

            case NormalInput.Cast:
                int spellnum = key - BearLib.Terminal.TK_1;
                if (spellnum >= player.SpellList.Count)
                {
                    return(Option.None <ICommand>());
                }

                Spell.ISpell spell = player.SpellList[spellnum];
                return(CastSpell(player, spellnum, spell));

            case NormalInput.Get:
                return(Game.MapHandler.GetItem(player.Pos)
                       .FlatMap(item => Option.Some <ICommand>(new PickupCommand(player, item))));

            case NormalInput.OpenMenu:
                Game.Exit();
                return(Option.None <ICommand>());
            }

            return(Option.None <ICommand>());
        }
Esempio n. 24
0
        private void SaveInputMapping(string Path)
        {
            // Create a new XML document
            XmlDocument doc = new XmlDocument();

            // Create an <InputMappings> root tag
            XmlElement inputRoot = doc.CreateElement("InputMappings");

            foreach (ListViewItem inputItem in inputList.Items)
            {
                // Get our InputMapping object
                InputMapping map = (InputMapping)inputItem.Tag;

                // Create the necessary elements
                XmlElement inputElement = doc.CreateElement("InputMapping");

                XmlAttribute inputName = doc.CreateAttribute("Name");

                XmlElement inputKbEnabled         = doc.CreateElement("IsKeyboardBindingEnabled");
                XmlElement inputMouseEnabled      = doc.CreateElement("IsMouseBindingEnabled");
                XmlElement inputControllerEnabled = doc.CreateElement("IsControllerBindingEnabled");

                XmlElement inputKbBinding         = doc.CreateElement("KeyboardBinding");
                XmlElement inputMouseBinding      = doc.CreateElement("MouseBinding");
                XmlElement inputControllerBinding = doc.CreateElement("ControllerBinding");

                // Set the proper values
                inputName.Value = map.Name;
                inputElement.Attributes.Append(inputName); // Add the Name attribute

                inputKbEnabled.InnerText         = map.IsKeyboardBindingEnabled.ToString();
                inputMouseEnabled.InnerText      = map.IsMouseBindingEnabled.ToString();
                inputControllerEnabled.InnerText = map.IsControllerBindingEnabled.ToString();

                inputKbBinding.InnerText         = map.KeyboardMapping.ToString();
                inputMouseBinding.InnerText      = map.MouseMapping.ToString();
                inputControllerBinding.InnerText = map.ControllerMapping.ToString();

                // Add the elements together
                inputElement.AppendChild(inputKbEnabled);
                inputElement.AppendChild(inputMouseEnabled);
                inputElement.AppendChild(inputControllerEnabled);
                inputElement.AppendChild(inputKbBinding);
                inputElement.AppendChild(inputMouseBinding);
                inputElement.AppendChild(inputControllerBinding);

                // Add <InputMapping> tag to the root node
                inputRoot.AppendChild(inputElement);
            }

            // Add the root at the beginning of the document
            doc.AppendChild(inputRoot);

            // Save the document to disk
            doc.Save(Path);

            CurrentFile = Path;
            UpdateTitleBar();
        }
 void Update()
 {
     if (Input.GetButtonDown(InputMapping.GetInputName(playerTag, InputMapping.Input.B)) && trapCount > 0)
     {
         --trapCount;
         PlaceTrap();
     }
 }
Esempio n. 26
0
        public Task <ValueSet> Run(CallStack stack)
        {
            var variables = stack.CurrentVariables.Values;

            var outputs = new ValueSet(InputMapping.ToDictionary(m => m.Key, m => variables[m.Value.Name]));

            return(Task.FromResult <ValueSet>(outputs));
        }
        public void DetermineMapping()
        {
            serializationUtils = new SerializationUtils();

            mapping = GetStandardMapping();
            LoadMapping();

            backupMapping = mapping.Clone();
        }
Esempio n. 28
0
 public void ToggleDevice(UIToggle checkbox, int id, string hardwareId)
 {
     if (checkbox.value != InputDeviceManager.UseDevice(hardwareId))
     {
         PlayerPrefs.SetInt("device_" + hardwareId, (!checkbox.value) ? 0 : 1);
         PlayerPrefs.Save();
         InputMapping.InitControllers();
     }
 }
Esempio n. 29
0
            public void AddInputWithSampleMouseActionMappings(out InputComponent inputComponent, out ActionMapping fire, out ActionMapping zoom,
                                                              out ActionMapping altFire, out ActionMapping melee)
            {
                fire = new ActionMapping {
                    ActionName = nameof(fire)
                };
                fire.HardwareActions.Add(new HardwareAction
                {
                    HardwareInputVariant = HardwareInputVariant.CreateMouseVariant(HardwareInputVariant.MouseVariant.LeftButton)
                });

                zoom = new ActionMapping {
                    ActionName = nameof(zoom)
                };
                zoom.HardwareActions.Add(new HardwareAction
                {
                    HardwareInputVariant = HardwareInputVariant.CreateMouseVariant(HardwareInputVariant.MouseVariant.MiddleButton)
                });

                altFire = new ActionMapping {
                    ActionName = nameof(altFire)
                };
                altFire.HardwareActions.Add(new HardwareAction
                {
                    HardwareInputVariant = HardwareInputVariant.CreateMouseVariant(HardwareInputVariant.MouseVariant.RightButton)
                });

                melee = new ActionMapping {
                    ActionName = nameof(melee)
                };
                melee.HardwareActions.Add(new HardwareAction
                {
                    HardwareInputVariant = HardwareInputVariant.CreateMouseVariant(HardwareInputVariant.MouseVariant.XButton1)
                });
                melee.HardwareActions.Add(new HardwareAction
                {
                    HardwareInputVariant = HardwareInputVariant.CreateMouseVariant(HardwareInputVariant.MouseVariant.XButton2)
                });

                var inputMapping = new InputMapping();

                inputMapping.ActionMappings.Add(fire);
                inputMapping.ActionMappings.Add(zoom);
                inputMapping.ActionMappings.Add(altFire);
                inputMapping.ActionMappings.Add(melee);

                inputComponent = new InputComponent {
                    InputMapping = inputMapping
                };

                var entity = new Entity();

                entity.AddComponent(inputComponent);

                _scene.AddEntity(entity);
            }
Esempio n. 30
0
 public async Task <IActionResult> Put([FromBody] InputMapping data)
 {
     return(await ValidateEditInputMapping(data)
            .MapT(async d =>
     {
         await _inputMappingRepository.UpdateAsync(d);
         return d;
     })
            .ToActionResultAsync());
 }
Esempio n. 31
0
		bool ShowRemoveButton(InputMapping mapping)
		{
			if (GUILayout.Button("-", EditorStyles.miniButtonLeft, miniButtonWidth))
			{
				RemoveMap(mapping);
				return true;
			}

			return false;
		}
 public void SetDefaultMapping()
 {
     mapping = GetStandardMapping();
     backupMapping = mapping.Clone();
 }
 // Initialization
 void Awake () {
     _animator = GetComponent<Animator>();
     inputMap = GameObject.Find("Input Manager").GetComponent<InputMapping>();
     rb = GetComponent<Rigidbody2D>();
     rb.freezeRotation = true;
 }
        private String GetInputMappingValue(InputMapping mapping, String inputField)
        {
            Dictionary<String, String> mappings = mapping.Controls.Mappings;

            if (mappings.ContainsKey(inputField))
                return mappings[inputField];

            throw new Exception("There is no mapping value named '" + inputField + "'");
        }
        private void UpdateMapping(InputMapping mapping, String inputField, String inputValue)
        {
            String currentValue = GetInputMappingValue(mapping, inputField);

            if (!selectedControlModified)
            {
                Console.WriteLine("--> " + inputField + ": No changes");

                SetControlText(GetControlByControlName(selectedControl), currentValue);
            }
            else if (currentValue != inputValue)
            {
                Console.WriteLine("--> " + inputField + ": Setting value to '" + inputValue + "'");

                mapping.SetControlProperty(inputField, inputValue);

                SetControlText(GetControlByControlName(selectedControl), inputValue);
            }
            else if (SelectedInputConfigState.DisabledOnInput)
            {
                Console.WriteLine("--> " + inputField + ": Setting value to ''");

                mapping.SetControlProperty(inputField, "");

                SetControlText(GetControlByControlName(selectedControl), "");
            }
        }
        private void TakeOverMapping(InputMapping mapping)
        {
            Dictionary<String, String> mappings = mapping.Controls.Mappings;
            foreach (KeyValuePair<String, String> entry in mappings)
            {
                System.Windows.Controls.Control control = GetControlByControlName(entry.Key);

                RemoveEventHandlersFromControl(control);
                SetControlText(control, entry.Value);
                AddEventHandlersToControl(control);
            }

            CheckForDoubleInput();
        }
 public void CopyMappingFrom(ConfigurableInput input)
 {
     mapping = input.mapping.Clone();
     backupMapping = input.backupMapping.Clone();
 }
        public void SaveMapping()
        {
            backupMapping = mapping.Clone();

            try
            {
                if (mapping == null)
                {
                    return;
                }

                String mappingFilePath = GetMappingFilePath();

                DictionarySerializer.Serialize(mapping.Controls.Mappings, mappingFilePath);
            }
            catch (Exception e)
            {
                throw new Exception("There was an error while writing the input mapping for device \"" + DeviceName + "\": " + e.Message);
            }
        }
 public void RevertMapping()
 {
     mapping = backupMapping.Clone();
 }
Esempio n. 40
0
 public PlayerInput(InputMapping mapping)
 {
     this.mapping = mapping;
 }