public HOTASCollection(DirectInputFactory directInputFactory, JoystickFactory joystickFactory, HOTASQueueFactory hotasQueueFactory, HOTASDeviceFactory hotasDeviceFactory) { _directInputFactory = directInputFactory ?? throw new ArgumentNullException(nameof(directInputFactory)); _joystickFactory = joystickFactory ?? throw new ArgumentNullException(nameof(joystickFactory)); _hotasQueueFactory = hotasQueueFactory ?? throw new ArgumentNullException(nameof(hotasQueueFactory)); _hotasDeviceFactory = hotasDeviceFactory ?? throw new ArgumentNullException(nameof(hotasDeviceFactory)); _directInput = _directInputFactory?.CreateDirectInput(); Initialize(); }
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 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);