/// <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); }
public double Get() { if (inputDevice != null) { return(inputDevice.Get(this)); } return(0); }
public double Get(XInputTypes type) { if (inputDevice != null) { return(inputDevice.Get(this)); } return(type.GetDisableValue()); }
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); }
/// <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); }
public IByte[] Input() { var input = _inputDevice.Get(); return(input.Select(c => _byteToAsciiConverter.ToByte(c.ToString())).ToArray()); }