public MainWindowViewModel() { var vGenWrapper = new VGenWrapper(); HidManager = new HidManager(); _gamepadManager = new GamepadManager(vGenWrapper, HidManager); _gamepadManager.ErrorOccuredEvent += (_, message) => { Log(message); }; IsRunning.AsObservable().Where(b => !b).Subscribe(_ => _runningGamepadsDisposable?.Dispose()); }
public Gamepad(GamepadConfiguration config, VGenWrapper vGenWrapper, HidDeviceLoader hidDeviceLoader) { _config = config; _vGenWrapper = vGenWrapper; _hidDeviceLoader = hidDeviceLoader; _virtualMappings = new Dictionary<XInputGamepadButtons, XInputGamepadButtons>(); foreach (var virtualMapping in _config.Mapping.VirtualKeysItems.Where(item => item.DestinationItem != null)) { var virtualPattern = virtualMapping.SourceKeys .Where(sourceKey => sourceKey != null) .Aggregate((XInputGamepadButtons)0, (current, sourceKey) => current | sourceKey.Value); // ReSharper disable once PossibleInvalidOperationException _virtualMappings[virtualPattern] = (XInputGamepadButtons) virtualMapping.DestinationItem; } }
public GamepadManager(VGenWrapper vGenWrapper, HidManager hidManager) { _vGenWrapper = vGenWrapper; _hidManager = hidManager; }