private static DeviceViewModel CreateDeviceViewMode(out IHOTASQueue hotasQueue, out IHOTASDevice hotasDevice, out IJoystick subJoystick) { var subFileSystem = Substitute.For <IFileSystem>(); var subDispatchFactory = Substitute.For <DispatcherFactory>(); var subDirectInputFactory = Substitute.For <DirectInputFactory>(); var subMediaPlayerFactory = Substitute.For <MediaPlayerFactory>(); var subJoystickFactory = Substitute.For <JoystickFactory>(); var hotasQueueFactory = new HOTASQueueFactory(Substitute.For <IKeyboard>()); var hotasDeviceFactory = new HOTASDeviceFactory(); var deviceId = Guid.NewGuid(); var productId = Guid.NewGuid(); var directInput = subDirectInputFactory.CreateDirectInput(); subJoystick = subJoystickFactory.CreateJoystick(directInput, deviceId); subJoystick.Capabilities.Returns(new Capabilities()); hotasQueue = hotasQueueFactory.CreateHOTASQueue(); hotasDevice = hotasDeviceFactory.CreateHOTASDevice(directInput, subJoystickFactory, productId, deviceId, "test", hotasQueue); hotasDevice.Capabilities = new Capabilities() { AxeCount = 0, ButtonCount = 2 }; var deviceVm = new DeviceViewModel(subDispatchFactory.CreateDispatcher(), subFileSystem, subMediaPlayerFactory, hotasDevice); return(deviceVm); }
private static DeviceViewModel CreateDeviceViewMode_AxesChanged(out IHOTASQueue hotasQueue, out IHOTASDevice subHotasDevice) { var subFileSystem = Substitute.For <IFileSystem>(); var subDispatcherFactory = Substitute.For <DispatcherFactory>(); var subMediaPlayerFactory = Substitute.For <MediaPlayerFactory>(); var subJoystickFactory = Substitute.For <JoystickFactory>(); var hotasQueueFactory = new HOTASQueueFactory(Substitute.For <IKeyboard>()); var testJoystick = new TestJoystick_AxisChanged(); subJoystickFactory.CreateJoystick(Arg.Any <IDirectInput>(), Arg.Any <Guid>()).Returns(j => testJoystick); IDispatcher testDispatcher = new TestDispatcher_AxisChanged(); subDispatcherFactory.CreateDispatcher().Returns(d => testDispatcher); hotasQueue = hotasQueueFactory.CreateHOTASQueue(); subHotasDevice = Substitute.For <IHOTASDevice>(); var axisMap = Substitute.For <HOTASAxis>(); axisMap.MapId = (int)JoystickOffset.Slider1; axisMap.Type = HOTASButton.ButtonType.AxisLinear; subHotasDevice.ButtonMap.Returns(new ObservableCollection <IHotasBaseMap>() { axisMap }); var deviceVm = new DeviceViewModel(subDispatcherFactory.CreateDispatcher(), subFileSystem, subMediaPlayerFactory, subHotasDevice); return(deviceVm); }
public HOTASDevice(IDirectInput directInput, Guid productGuid, Guid deviceId, string name, IHOTASQueue hotasQueue) { _directInput = directInput ?? throw new ArgumentNullException(nameof(directInput)); _hotasQueue = hotasQueue ?? throw new ArgumentNullException(nameof(hotasQueue)); if (deviceId == Guid.Empty) { return; //can occur when loading an unsupported json format and the device id isn't deserialized correctly or a non-connected device that was previously saved } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } DeviceId = deviceId; ProductId = productGuid; Name = name; InitializeModeProfile(); }
public HOTASDevice(IDirectInput directInput, JoystickFactory joystickFactory, Guid productGuid, Guid deviceId, string name, IHOTASQueue hotasQueue) : this(directInput, productGuid, deviceId, name, hotasQueue) { _directInput = directInput ?? throw new ArgumentNullException(nameof(directInput)); _joystickFactory = joystickFactory ?? throw new ArgumentNullException(nameof(joystickFactory)); _hotasQueue = hotasQueue ?? throw new ArgumentNullException(nameof(hotasQueue)); if (deviceId == Guid.Empty) { throw new ArgumentNullException(nameof(deviceId)); } if (string.IsNullOrWhiteSpace(name)) { throw new ArgumentNullException(nameof(name)); } if (App.IsDebug) { return; } AcquireJoystick(); LoadCapabilitiesMapping(); }
private static DeviceViewModel CreateDeviceViewMode_LostConnection(out IHOTASQueue hotasQueue, out IHOTASDevice subHotasDevice) { var subFileSystem = Substitute.For <IFileSystem>(); var subDispatcherFactory = Substitute.For <DispatcherFactory>(); var subMediaPlayerFactory = Substitute.For <MediaPlayerFactory>(); var subJoystickFactory = Substitute.For <JoystickFactory>(); var hotasQueueFactory = new HOTASQueueFactory(Substitute.For <IKeyboard>()); var testJoystick = new TestJoystick_LostConnection(); subJoystickFactory.CreateJoystick(Arg.Any <IDirectInput>(), Arg.Any <Guid>()).Returns(j => testJoystick); hotasQueue = hotasQueueFactory.CreateHOTASQueue(); subHotasDevice = Substitute.For <IHOTASDevice>(); subHotasDevice.ButtonMap.Returns(new ObservableCollection <IHotasBaseMap>()); subHotasDevice.Capabilities.Returns(new Capabilities() { AxeCount = 0, ButtonCount = 2 }); var deviceVm = new DeviceViewModel(subDispatcherFactory.CreateDispatcher(), subFileSystem, subMediaPlayerFactory, subHotasDevice); return(deviceVm); }
private static HOTASCollection CreateHotasCollection(out IDirectInput directInput, out JoystickFactory joystickFactory, out IHOTASQueue hotasQueue) { directInput = Substitute.For <IDirectInput>(); hotasQueue = Substitute.For <IHOTASQueue>(); var productId = Guid.NewGuid(); var deviceId = Guid.NewGuid(); const string name = "test device name"; var subJoystick = Substitute.For <IJoystick>(); subJoystick.Capabilities.Returns(new Capabilities() { PovCount = 1, AxeCount = 4, ButtonCount = 20 }); subJoystick.IsAxisPresent(Arg.Any <string>()).Returns(true); joystickFactory = Substitute.For <JoystickFactory>(); joystickFactory.CreateJoystick(default, default).ReturnsForAnyArgs(subJoystick);
public virtual IHOTASDevice CreateHOTASDevice(IDirectInput directInput, Guid productGuid, Guid deviceId, string name, IHOTASQueue hotasQueue) { return(new HOTASDevice(directInput, productGuid, deviceId, name, hotasQueue)); }