예제 #1
0
 public void MapControls(Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick warthog)
 {
     // Add in the mappings
     Disposables = new List <IDisposable> {
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottle75Command.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleButtonStateHandler.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleCameraCommand.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleClearMessages.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleCycleCommand.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleHardpointsCommand.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Subscribe(x => TmThrottleHat.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleLandedStateHandler.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleLandingGearCommand.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleLightsCommand.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleHeatSinkCommand.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleShieldCellCommand.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleSecondaryFireCommand.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         //warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleSilentCommand.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Subscribe(x => TmThrottleSliderJoystick.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleStateModifier.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         //warthog.Where(x => Reactive.ButtonsChanged(x)).Subscribe(x => TmThrottleVoiceCommandHandler.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Subscribe(x => TmThrottleXYJoystick.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
         warthog.Subscribe(x => TmThrottleZJoystick.Process(x, this), ex => Logger.LogError($"Exception : {ex}")),
     };
 }
예제 #2
0
        public void Initialize(string devicePath)
        {
            var joystick = new Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick(devicePath, Logger);

            MapControls(joystick);
            MapLights(joystick);
            joystick.Initialize();
        }
예제 #3
0
 public void MapLights(Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick warthog)
 {
     // Turn lights on and off
     SharedState.ModeChanged.Subscribe(x =>
     {
         warthog.Lights         = (byte)Light.LEDBacklight;
         warthog.LightIntensity = (byte)GetIntensity(x);
     });
 }
예제 #4
0
        /// <summary>
        /// Just testing things...
        /// </summary>
        /// <param name="args"></param>
        private static void Main(string[] args)
        {
            try
            {
                const ushort TTC_VENDORID           = 0xF00F;
                const ushort TTC_PRODUCTID_KEYBOARD = 0x00000003;
                // \\?\hid#hidclass#1&1731f3ea&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
                var test = Usb.Hid.Connection.Devices.RetrieveAllDevicePath(TTC_VENDORID, TTC_PRODUCTID_KEYBOARD).FirstOrDefault();

                var list = Usb.Hid.Connection.Devices.RetrieveAllDevicePath().ToList();

                var controller0 = new Controller(@"\\?\hid#hidclass#1&1731f3ea&1&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd", new NullLogger <LogTest>());



                // A lot of commented out calls to different part of the code to determine that the libraries are doing what I want them to do.

                //var paths = Devices.RetrieveAllDevicePath(
                //    Usb.GameControllers.LeoBodnar.BBI32.Joystick.VendorId,
                //    Usb.GameControllers.LeoBodnar.BBI32.Joystick.ProductId);

                //var paths = Devices.RetrieveAllDevicePath(
                //   Usb.GameControllers.Microsoft.Sidewinder.StrategicCommander.Joystick.VendorId,
                //    Usb.GameControllers.Microsoft.Sidewinder.StrategicCommander.Joystick.ProductId);

                var paths = Devices.RetrieveAllDevicePath(
                    Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick.VendorId,
                    Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick.ProductId);

                //var paths = Devices.RetrieveAllDevicePath(
                //    Usb.GameControllers.CHProducts.ProPedals.Joystick.VendorId,
                //    Usb.GameControllers.CHProducts.ProPedals.Joystick.ProductId);

                //var paths = Devices.RetrieveAllDevicePath(
                //   Usb.GameControllers.Pioneer.DDJSB2.Joystick.VendorId,
                //   Usb.GameControllers.Pioneer.DDJSB2.Joystick.ProductId);

                //                int idVendor = 0x0C45;
                //              int ipProduct = 0x760A;

                //int idVendor = 0x2B73;
                //int ipProduct = 0x0001;

                // \\?\hid#vid_0c45&pid_760a&mi_01&col06#b&146a75ad&0&0005#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
                // \\?\hid#vid_0c45&pid_760a&mi_00#b&279a91eb&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
                // \\?\hid#vid_0c45&pid_760a&mi_01&col04#b&146a75ad&0&0003#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd
                // \\?\hid#vid_0c45&pid_760a&mi_01&col01#b&146a75ad&0&0000#{4d1e55b2-f16f-11cf-88cb-001111000030}       //mute vol+ vol-
                // \\?\hid#vid_0c45&pid_760a&mi_01&col02#b&146a75ad&0&0001#{4d1e55b2-f16f-11cf-88cb-001111000030}
                // \\?\hid#vid_0c45&pid_760a&mi_01&col03#b&146a75ad&0&0002#{4d1e55b2-f16f-11cf-88cb-001111000030}
                // \\?\hid#vid_0c45&pid_760a&mi_01&col05#b&146a75ad&0&0004#{4d1e55b2-f16f-11cf-88cb-001111000030}\kbd

                //idVendor: 0x0C45(Sonix Technology Co., Ltd.)
                //idProduct: 0x760A

                //var paths = Devices.RetrieveAllDevicePath(idVendor, ipProduct).ToList();
                //Usb.GameControllers.Microsoft.Sidewinder.ForceFeedback2.Joystick.VendorId,
                //Usb.GameControllers.Microsoft.Sidewinder.ForceFeedback2.Joystick.ProductId);

                //var usb = new Usb.Hid.Connection.Controller(paths[6]);

                //usb.ContinuousUsb = true;
                //usb.ContinuousUsbReportSize = 15;
                //usb.ContinuousUsbDebounce = true;
                //usb.ContinuousUsbDebounceButtonsIndex = 1;
                if (false)
                {
                    var bbi32Paths = Devices.RetrieveAllDevicePath(
                        Usb.GameControllers.LeoBodnar.BBI32.Joystick.VendorId,
                        Usb.GameControllers.LeoBodnar.BBI32.Joystick.ProductId);

                    var usb = new Usb.Hid.Connection.Controller(bbi32Paths.First(), null);
                    usb.Subscribe(x => Console.WriteLine($"bbi32: {DateTime.Now}"));
                    usb.Initialize();
                    usb.ProcessInputReport().Wait();
                }
                if (false)
                {
                    using (ILoggerFactory loggerFactory =
                               LoggerFactory.Create(builder => builder.AddSimpleConsole(options =>
                                                                                        { options.SingleLine = true; options.TimestampFormat = "hh:mm:ss "; }).SetMinimumLevel(LogLevel.Debug)))
                    {
                        ILogger <Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick> logger
                            = loggerFactory.CreateLogger <Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick>();

                        var warthog = Devices.RetrieveAllDevicePath(
                            Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick.VendorId,
                            Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick.ProductId);

                        var usb = new Usb.Hid.Connection.Controller(warthog.First(), logger)
                        {
                            ContinuousUsb = true,
                            // Warthog returns raw vales starting at 16.  Only look for changes before that.
                            ContinuousUsbReportSize = 15,

                            // Debounce the buttons
                            ContinuousUsbDebounce = true,
                            // Button data is bytes 1-4
                            ContinuousUsbDebounceButtonsIndex = 1,
                        };

                        usb.Subscribe(x => Console.WriteLine($"warthog: {DateTime.Now}"));
                        usb.Initialize();
                        //usb.ProcessInputReport().Wait();

                        Console.ReadKey();

                        usb.Stop();
                    }
                }
                if (true)
                {
                    using (ILoggerFactory loggerFactory =
                               LoggerFactory.Create(builder => builder.AddSimpleConsole(options =>
                                                                                        { options.SingleLine = true; options.TimestampFormat = "hh:mm:ss "; }).SetMinimumLevel(LogLevel.Debug)))
                    {
                        ILogger <Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick> logger
                            = loggerFactory.CreateLogger <Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick>();

                        var controller = new Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick(paths.First(), logger);

                        controller.Subscribe(x => Console.WriteLine($"warthog: {DateTime.Now}"));

                        controller.Initialize();

                        //var test = controller.Controller.GetInputReport();

                        controller.Lights = (byte)Usb.GameControllers.Thrustmaster.Warthog.Throttle.Models.Light.LED1;
                        System.Threading.Thread.Sleep(500);

                        controller.Lights = (byte)Usb.GameControllers.Thrustmaster.Warthog.Throttle.Models.Light.LED2;
                        System.Threading.Thread.Sleep(500);

                        controller.Lights = (byte)Usb.GameControllers.Thrustmaster.Warthog.Throttle.Models.Light.LED3;
                        System.Threading.Thread.Sleep(500);
                        //usb.ProcessSerialMessage(test.Length, test, test.Length, 0).Wait();

                        Console.ReadKey();
                    }
                }
                if (false)
                {
                    var controller = new Usb.GameControllers.CHProducts.ProPedals.Joystick(paths.First(), null);

                    controller.Initialize();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            while (true)
            {
                ;
            }
            Console.ReadKey();
        }