protected override void RunScan()
        {
            BpLogger.Info("XInputGamepadManager start scanning");
            try
            {
                // TODO this should scan in a loop on a timer until told to stop
                var controllers = new[]
                {
                    new Controller(UserIndex.One),
                    new Controller(UserIndex.Two),
                    new Controller(UserIndex.Three),
                    new Controller(UserIndex.Four),
                };
                foreach (var c in controllers)
                {
                    if (!c.IsConnected)
                    {
                        continue;
                    }

                    BpLogger.Debug($"Found connected XInput Gamepad for Index {c.UserIndex}");
                    var deviceImpl = new XInputGamepadDevice(LogManager, c);
                    var device     = new ButtplugDevice(LogManager, new XInputProtocol(LogManager, deviceImpl), deviceImpl);
                    InvokeDeviceAdded(new DeviceAddedEventArgs(device));
                    InvokeScanningFinished();
                }
            }
            catch (DllNotFoundException e)
            {
                // TODO Should we maybe try testing for this in construction instead of during scanning?
                BpLogger.Error($"Required DirectX DLL not found: {e.Message}\nThis probably means you need to install the DirectX Runtime from June 2010: https://www.microsoft.com/en-us/download/details.aspx?id=8109");
                InvokeScanningFinished();
            }
        }
        public async Task <IButtplugDevice> CreateDevice(IButtplugLogManager aLogManager, IButtplugDeviceImpl aDevice)
        {
            var device = new ButtplugDevice(aLogManager, _protocolType, aDevice);
            // Run initialization now, just to make sure we're ready to go when we hand the device back.
            // TODO should probably find a better cancellation token for this. Or like, any at all.
            await device.InitializeAsync(CancellationToken.None).ConfigureAwait(false);

            return(device);
        }
        public async Task TestBaseDevice()
        {
            var logMgr  = new ButtplugLogManager();
            var devImpl = new TestDeviceImpl(logMgr, "Device");
            var dev     = new ButtplugDevice(logMgr, new TestProtocol(logMgr, devImpl), devImpl)
            {
                Index = 2,
            };

            await dev.InitializeAsync(default(CancellationToken));

            (await dev.ParseMessageAsync(new StopDeviceCmd(2), default(CancellationToken))).Should().BeOfType <Ok>();

            dev.Awaiting(async aDevice => await dev.ParseMessageAsync(new RotateCmd(2, new List <RotateCmd.RotateSubcommand>()), default(CancellationToken))).Should().Throw <ButtplugDeviceException>();

            dev.Disconnect();
            dev.Awaiting(async aDevice => await aDevice.ParseMessageAsync(new StopDeviceCmd(2), default(CancellationToken))).Should().Throw <ButtplugDeviceException>();
        }
Пример #4
0
 public void AddDevice(ButtplugDevice dev)
 {
     InvokeDeviceAdded(new DeviceAddedEventArgs(dev));
 }
Пример #5
0
 public TestDeviceSubtypeManager([NotNull] ButtplugDevice aDevice)
     : base(new ButtplugLogManager())
 {
     Device = aDevice;
 }