コード例 #1
0
        /// <summary>
        /// Refreshes the current state. Triggers <see cref="InputChanged"/> event.
        /// </summary>
        /// <returns>if the input was available</returns>
        public bool RefreshInput()
        {
            foreach (var type in XInputHelper.Instance.Values)
            {
                var mapping = mapper.GetMapping(type);
                if (mapping != null)
                {
                    double value = 0;
                    if (mapping.InputType != null)
                    {
                        value = source.Get(mapping.InputType);
                    }
                    values[type] = mapping.GetValue(value);
                }
            }
            if (mapper.SelectedDPad != -1)
            {
                dPads[0] = source.DPads.ElementAt(mapper.SelectedDPad);
            }
            else
            {
                dPads[0] = DPadHelper.GetDirection(GetBool(XInputTypes.UP), GetBool(XInputTypes.DOWN), GetBool(XInputTypes.LEFT), GetBool(XInputTypes.RIGHT));
            }
            var changedDPads  = state.SetDPads(dPads);
            var changedValues = state.SetValues(values.Where(t => !t.Key.IsDPad()).ToDictionary(x => (Enum)x.Key, x => x.Value));

            if (changedDPads.Any() || changedValues.Any())
            {
                InputChanged?.Invoke(this, new DeviceInputChangedEventArgs(changedValues, changedDPads));
            }
            return(true);
        }
コード例 #2
0
ファイル: InputSource.cs プロジェクト: Pasinozavr/XOutput
 public double Get()
 {
     if (inputDevice != null)
     {
         return(inputDevice.Get(this));
     }
     return(0);
 }
コード例 #3
0
 public double Get(XInputTypes type)
 {
     if (inputDevice != null)
     {
         return(inputDevice.Get(this));
     }
     return(type.GetDisableValue());
 }
コード例 #4
0
ファイル: XOutputSource.cs プロジェクト: DuckerMan/XOutput
        internal bool Refresh(IInputDevice source, InputMapper mapper)
        {
            var mapping = mapper.GetMapping(inputType);

            if (mapping != null)
            {
                double value = 0;
                if (mapping.InputType != null)
                {
                    value = source.Get(mapping.Source);
                }
                double newValue = mapping.GetValue(value);
                return(RefreshValue(newValue));
            }
            return(false);
        }
コード例 #5
0
 /// <summary>
 /// Refreshes the current state.
 /// </summary>
 /// <returns></returns>
 public bool RefreshInput()
 {
     foreach (var type in (XInputTypes[])Enum.GetValues(typeof(XInputTypes)))
     {
         var mapping = mapper.GetMapping(type);
         if (mapping != null)
         {
             double value = 0;
             if (mapping.InputType != null)
             {
                 value = source.Get(mapping.InputType);
             }
             values[type] = mapping.GetValue(value);
         }
         else
         {
         }
     }
     dPad = source.DPad;
     InputChanged?.Invoke();
     return(true);
 }
コード例 #6
0
        public IByte[] Input()
        {
            var input = _inputDevice.Get();

            return(input.Select(c => _byteToAsciiConverter.ToByte(c.ToString())).ToArray());
        }