示例#1
0
        public MappingViewModel(MappingModel model, GameController controller, XInputTypes inputType) : base(model)
        {
            this.controller = controller;
            var mapperData = controller.Mapper.GetMapping(inputType);

            Model.XInputType = inputType;
            var device = controller.InputDevice;

            Model.Inputs.Add(MappingTypes.Disabled);
            foreach (var directInput in device.Buttons)
            {
                Model.Inputs.Add(directInput);
            }
            foreach (var directInput in device.Axes)
            {
                Model.Inputs.Add(directInput);
            }
            foreach (var directInput in device.Sliders)
            {
                Model.Inputs.Add(directInput);
            }
            if (mapperData != null && mapperData.InputType == null)
            {
                mapperData.InputType = device.Buttons.FirstOrDefault();
            }
            Model.MapperData = mapperData;
            SetSelected(mapperData);
        }
 public AutoConfigureViewModel(GameController controller, XInputTypes valueToRead)
 {
     this.controller = controller;
     xInputType      = valueToRead;
     model           = new AutoConfigureModel();
     inputTypes      = controller.InputDevice.GetButtons().Concat(controller.InputDevice.GetAxes()).ToArray();
 }
示例#3
0
        public MappingViewModel(MappingModel model, GameController controller, XInputTypes inputType) : base(model)
        {
            this.controller = controller;
            var mapperData = controller.Mapper.GetMapping(inputType);

            Model.XInputType = inputType;
            var device = controller.InputDevice;

            Model.Inputs.Add(DisabledInputSource.Instance);
            foreach (var directInput in device.Sources.Where(s => s.Type == InputSourceTypes.Button))
            {
                Model.Inputs.Add(directInput);
            }
            foreach (var directInput in device.Sources.Where(s => s.Type == InputSourceTypes.Axis))
            {
                Model.Inputs.Add(directInput);
            }
            foreach (var directInput in device.Sources.Where(s => s.Type == InputSourceTypes.Slider))
            {
                Model.Inputs.Add(directInput);
            }
            if (mapperData != null && mapperData.InputType == null)
            {
                mapperData.Source = device.Sources.Where(s => s.Type == InputSourceTypes.Button).FirstOrDefault();
            }
            Model.MapperData = mapperData;
            SetSelected(mapperData);
        }
示例#4
0
 public double Get(XInputTypes type)
 {
     if (inputDevice != null)
     {
         return(Value);
     }
     return(type.GetDisableValue());
 }
示例#5
0
 /// <summary>
 /// Gets the current state of the inputTpye.
 /// </summary>
 /// <param name="inputType">Type of input</param>
 /// <returns>Value</returns>
 public double Get(XInputTypes inputType)
 {
     if (values.ContainsKey(inputType))
     {
         return(values[inputType]);
     }
     return(0);
 }
示例#6
0
        public MappingViewModel(MappingModel model, GameController controller, XInputTypes inputType) : base(model)
        {
            this.controller  = controller;
            Model.XInputType = inputType;
            var mapperData = GetMapperData();

            Model.MapperData = mapperData;
            SetSelected(mapperData);
        }
示例#7
0
        /// <summary>
        /// Gets if the value is slider type.
        /// <para>Implements <see cref="IInputHelper{T}.IsAxis(T)"/> enum value</para>
        /// </summary>
        /// <param name="type"><see cref="XInputTypes"/> enum value</param>
        /// <returns></returns>
        public bool IsSlider(XInputTypes input)
        {
            switch (input)
            {
            case XInputTypes.L2:
            case XInputTypes.R2:
                return(true);

            default:
                return(false);
            }
        }
示例#8
0
 public static InputSourceTypes GetInputSourceType(this XInputTypes input)
 {
     if (input.IsAxis())
     {
         return(InputSourceTypes.Axis);
     }
     else if (input.IsButton())
     {
         return(InputSourceTypes.Button);
     }
     throw new NotImplementedException("ERROR");
 }
示例#9
0
        protected bool Next()
        {
            Model.MaxType = null;
            int index = Array.IndexOf(valuesToRead, xInputType);

            SetTime(false);
            if (index + 1 < valuesToRead.Length)
            {
                xInputType   = valuesToRead[index + 1];
                Model.XInput = xInputType;
                return(true);
            }
            return(false);
        }
示例#10
0
        /// <summary>
        /// Gets the value for disabled mapping.
        /// </summary>
        /// <param name="input"><see cref="XInputTypes"/> enum value</param>
        /// <returns></returns>
        public double GetDisableValue(XInputTypes input)
        {
            switch (input)
            {
            case XInputTypes.LX:
            case XInputTypes.LY:
            case XInputTypes.RX:
            case XInputTypes.RY:
                return(0.5);

            default:
                return(0);
            }
        }
示例#11
0
        /// <summary>
        /// Gets if the value is axis type.
        /// <para>Implements <see cref="IInputHelper{T}.IsAxis(T)"/> enum value</para>
        /// </summary>
        /// <param name="type"><see cref="XInputTypes"/> enum value</param>
        /// <returns></returns>
        public bool IsAxis(XInputTypes input)
        {
            switch (input)
            {
            case XInputTypes.LX:
            case XInputTypes.LY:
            case XInputTypes.RX:
            case XInputTypes.RY:
                return(true);

            default:
                return(false);
            }
        }
示例#12
0
        /// <summary>
        /// Gets if the value is DPad type.
        /// <para>Implements <see cref="IInputHelper{T}.IsDPad(T)"/> enum value</para>
        /// </summary>
        /// <param name="type"><see cref="XInputTypes"/> enum value</param>
        /// <returns></returns>
        public bool IsDPad(XInputTypes input)
        {
            switch (input)
            {
            case XInputTypes.LEFT:
            case XInputTypes.RIGHT:
            case XInputTypes.UP:
            case XInputTypes.DOWN:
                return(true);

            default:
                return(false);
            }
        }
示例#13
0
 public AutoConfigureViewModel(AutoConfigureModel model, GameController controller, XInputTypes[] valuesToRead) : base(model)
 {
     this.controller   = controller;
     this.valuesToRead = valuesToRead;
     xInputType        = valuesToRead.First();
     if (valuesToRead.Length > 1)
     {
         Model.ButtonsVisibility = System.Windows.Visibility.Collapsed;
         Model.TimerVisibility   = System.Windows.Visibility.Visible;
     }
     else
     {
         Model.ButtonsVisibility = System.Windows.Visibility.Visible;
         Model.TimerVisibility   = System.Windows.Visibility.Collapsed;
     }
     inputTypes     = controller.InputDevice.Sources.ToArray();
     timer.Interval = TimeSpan.FromMilliseconds(BlinkTime);
     timer.Tick    += TimerTick;
     timer.Start();
 }
示例#14
0
        /// <summary>
        /// Gets if the value is button type.
        /// <para>Implements <see cref="IInputHelper{T}.IsButton(T)"/> enum value</para>
        /// </summary>
        /// <param name="type"><see cref="XInputTypes"/> enum value</param>
        /// <returns></returns>
        public bool IsButton(XInputTypes input)
        {
            switch (input)
            {
            case XInputTypes.A:
            case XInputTypes.B:
            case XInputTypes.X:
            case XInputTypes.Y:
            case XInputTypes.L1:
            case XInputTypes.R1:
            case XInputTypes.L3:
            case XInputTypes.R3:
            case XInputTypes.Start:
            case XInputTypes.Back:
            case XInputTypes.Home:
                return(true);

            default:
                return(false);
            }
        }
示例#15
0
 public AutoConfigureViewModel(AutoConfigureModel model, IEnumerable <IInputDevice> inputDevices, InputMapper mapper, XInputTypes[] valuesToRead) : base(model)
 {
     this.mapper       = mapper;
     this.inputDevices = inputDevices;
     this.valuesToRead = valuesToRead;
     xInputType        = valuesToRead.First();
     if (valuesToRead.Length > 1)
     {
         Model.ButtonsVisibility = System.Windows.Visibility.Collapsed;
         Model.TimerVisibility   = System.Windows.Visibility.Visible;
     }
     else
     {
         Model.ButtonsVisibility = System.Windows.Visibility.Visible;
         Model.TimerVisibility   = System.Windows.Visibility.Collapsed;
     }
     inputTypes     = inputDevices.SelectMany(i => i.Sources).ToArray();
     timer.Interval = TimeSpan.FromMilliseconds(BlinkTime);
     timer.Tick    += TimerTick;
     timer.Start();
 }
示例#16
0
 /// <summary>
 /// Sets the mapping for a given XInput.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="to"></param>
 /// <returns></returns>
 public void SetMapping(XInputTypes type, MapperDataCollection to)
 {
     Mappings[type] = to;
 }
示例#17
0
 public WebXOutputSource(string name, XInputTypes type) : base(null, name, type.GetInputSourceType(), 0)
 {
     inputType = type;
     newValue  = type.GetDisableValue();
 }
示例#18
0
 public static double GetDisableValue(this XInputTypes input)
 {
     return(XInputHelper.Instance.GetDisableValue(input));
 }
示例#19
0
 public static bool IsButton(this XInputTypes input)
 {
     return(XInputHelper.Instance.IsButton(input));
 }
示例#20
0
 /// <summary>
 /// Sets the mapping for a given XInput.
 /// </summary>
 /// <param name="type"></param>
 /// <param name="to"></param>
 /// <returns></returns>
 public void SetMapping(XInputTypes type, MapperData to)
 {
     mappings[type] = to;
 }
示例#21
0
 public XOutputSource(string name, XInputTypes type) : base(null, name, type.GetInputSourceType(), 0)
 {
     inputType = type;
 }
 public AutoConfigureWindow(GameController controller, XInputTypes valueToRead)
 {
     viewModel   = new AutoConfigureViewModel(controller, valueToRead);
     DataContext = viewModel;
     InitializeComponent();
 }
示例#23
0
        private XboxInputMessage GetMessage(DeviceInputChangedEventArgs e)
        {
            XboxInputMessage message = new XboxInputMessage();

            if (e.ChangedDPads.Any())
            {
                message.UP    = XInput.GetBool(XInputTypes.UP);
                message.DOWN  = XInput.GetBool(XInputTypes.DOWN);
                message.LEFT  = XInput.GetBool(XInputTypes.LEFT);
                message.RIGHT = XInput.GetBool(XInputTypes.RIGHT);
            }
            foreach (var value in e.ChangedValues)
            {
                if (value.IsButton)
                {
                    XInputTypes type = (XInputTypes)Enum.Parse(typeof(XInputTypes), value.DisplayName);
                    switch (type)
                    {
                    case XInputTypes.A:
                        message.A = value.Value > 0.5;
                        break;

                    case XInputTypes.B:
                        message.B = value.Value > 0.5;
                        break;

                    case XInputTypes.X:
                        message.X = value.Value > 0.5;
                        break;

                    case XInputTypes.Y:
                        message.Y = value.Value > 0.5;
                        break;

                    case XInputTypes.L1:
                        message.L1 = value.Value > 0.5;
                        break;

                    case XInputTypes.R1:
                        message.R1 = value.Value > 0.5;
                        break;

                    case XInputTypes.L3:
                        message.L3 = value.Value > 0.5;
                        break;

                    case XInputTypes.R3:
                        message.R3 = value.Value > 0.5;
                        break;

                    case XInputTypes.Start:
                        message.Start = value.Value > 0.5;
                        break;

                    case XInputTypes.Back:
                        message.Back = value.Value > 0.5;
                        break;

                    case XInputTypes.Home:
                        message.Home = value.Value > 0.5;
                        break;
                    }
                }
                else
                {
                    XInputTypes type = (XInputTypes)Enum.Parse(typeof(XInputTypes), value.DisplayName);
                    switch (type)
                    {
                    case XInputTypes.L2:
                        message.L2 = value.Value;
                        break;

                    case XInputTypes.R2:
                        message.R2 = value.Value;
                        break;

                    case XInputTypes.LX:
                        message.LX = value.Value;
                        break;

                    case XInputTypes.LY:
                        message.LY = value.Value;
                        break;

                    case XInputTypes.RX:
                        message.RX = value.Value;
                        break;

                    case XInputTypes.RY:
                        message.RY = value.Value;
                        break;
                    }
                }
            }
            return(message);
        }
示例#24
0
 public MappingView(GameController controller, XInputTypes type)
 {
     viewModel   = new MappingViewModel(controller, type);
     DataContext = viewModel;
     InitializeComponent();
 }
示例#25
0
 /// <summary>
 /// Gets boolean output.
 /// </summary>
 /// <param name="inputType">Type of input</param>
 /// <returns>boolean value</returns>
 public bool GetBool(XInputTypes inputType)
 {
     return(Get(inputType) > 0.5);
 }
示例#26
0
 public static bool IsSlider(this XInputTypes input)
 {
     return(XInputHelper.Instance.IsSlider(input));
 }