private void StopControllers() { foreach (var controller in Controllers) { controller.Dispose(); } Controllers = new List <Controller>(); try { eliteVirtualJoysticks?.Release(); GameService?.Dispose(); ForceFeedBackController?.Dispose(); voiceMeeterDisposable?.Dispose(); } catch (Exception ex) { Log.LogError(ex.Message); } eliteVirtualJoysticks = null; ForceFeedBackController = null; voiceMeeterDisposable = null; }
public void Initialize(ForceFeedBackController.Controller msffb2) { this.msffb2 = msffb2; Disposables = new List <IDisposable>(); var midiController = DDJSB2.PioneerDDJSB2.CreateInstance(); Disposables.Add(midiController); MapControls(midiController); MapLights(midiController); midiController.Initialize(); }
private void StartControllers( Settings settings, EliteVirtualJoysticks eliteVirtualJoysticks) { Log.LogDebug("Connecting to Elite Game"); GameService.Initialize(); Log.LogDebug("Connected to Elite Game"); Log.LogDebug("Connecting to Controllers"); // Connect to Voicemeeter voiceMeeterDisposable = VoiceMeeter.Remote.Initialize(Voicemeeter.RunVoicemeeterParam.VoicemeeterBanana).Result; // Connect to the Force Feedback Joystick ForceFeedBackController = new ForceFeedBackController.Controller() { Logger = Log }; ForceFeedBackController.Initialize(GameService); try { var ffb2 = new vJoyMapping.Microsoft.Sidewinder.ForceFeedback2.Controller { Arduino = arduino, Name = "Force Feedback 2", SharedState = SharedState, Settings = settings, VirtualJoysticks = eliteVirtualJoysticks, Logger = Log }; ffb2.Initialize(Controller.GetDevicePath( Usb.GameControllers.Microsoft.Sidewinder.ForceFeedback2.Joystick.VendorId, Usb.GameControllers.Microsoft.Sidewinder.ForceFeedback2.Joystick.ProductId)); Controllers.Add(ffb2); Log.LogDebug($"Added {ffb2.Name}"); /* * var swgv = new vJoyMapping.Microsoft.Sidewinder.GameVoice.Controller * { * Arduino = arduino, * Name = "Game Voice", * SharedState = SharedState, * Settings = settings, * VirtualJoysticks = eliteVirtualJoysticks, * Logger = Log * }; * * swgv.Initialize(Controller.GetDevicePath( * Usb.GameControllers.Microsoft.Sidewinder.GameVoice.Joystick.VendorId, * Usb.GameControllers.Microsoft.Sidewinder.GameVoice.Joystick.ProductId)); * * Controllers.Add(swgv); */ var swsc = new vJoyMapping.Microsoft.Sidewinder.StrategicCommander.Controller { Arduino = arduino, Name = "Strategic Commander", SharedState = SharedState, Settings = settings, VirtualJoysticks = eliteVirtualJoysticks, Logger = Log }; swsc.Initialize(Controller.GetDevicePath( Usb.GameControllers.Microsoft.Sidewinder.StrategicCommander.Joystick.VendorId, Usb.GameControllers.Microsoft.Sidewinder.StrategicCommander.Joystick.ProductId)); Controllers.Add(swsc); Log.LogDebug($"Added {swsc.Name}"); var warthog = new vJoyMapping.Thrustmaster.Warthog.Throttle.Controller { Arduino = arduino, Name = "Warthog Throttle", SharedState = SharedState, Settings = settings, VirtualJoysticks = eliteVirtualJoysticks, Logger = Log }; warthog.Initialize(Controller.GetDevicePath( Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick.VendorId, Usb.GameControllers.Thrustmaster.Warthog.Throttle.Joystick.ProductId)); Controllers.Add(warthog); Log.LogDebug($"Added {warthog.Name}"); var altProductId = false; retry: try { var pedals = new vJoyMapping.CHProducts.ProPedals.Controller { Arduino = arduino, Name = "Pro Pedals", SharedState = SharedState, Settings = settings, VirtualJoysticks = eliteVirtualJoysticks, Logger = Log }; var productId = altProductId ? Usb.GameControllers.CHProducts.ProPedals.JoystickMSDriver.ProductId : Usb.GameControllers.CHProducts.ProPedals.Joystick.ProductId; pedals.Initialize(Controller.GetDevicePath( Usb.GameControllers.CHProducts.ProPedals.Joystick.VendorId, productId), altProductId); Controllers.Add(pedals); Log.LogDebug($"Added {pedals.Name}"); } catch (Exception _) { if (altProductId == false) { altProductId = true; goto retry; } throw; } var bbi32 = new vJoyMapping.LeoBodnar.BBI32.Controller { Arduino = arduino, Name = "BBI32", SharedState = SharedState, Settings = settings, VirtualJoysticks = eliteVirtualJoysticks, Logger = Log }; bbi32.Initialize(Controller.GetDevicePath( Usb.GameControllers.LeoBodnar.BBI32.Joystick.VendorId, Usb.GameControllers.LeoBodnar.BBI32.Joystick.ProductId)); Controllers.Add(bbi32); Log.LogDebug($"Added {bbi32.Name}"); var ddjsb2 = new vJoyMapping.Pioneer.ddjsb2.Controller { Arduino = arduino, Name = "DDJSB2", SharedState = SharedState, Settings = settings, VirtualJoysticks = eliteVirtualJoysticks, GameService = GameService, Logger = Log }; ddjsb2.Initialize(ForceFeedBackController); Controllers.Add(ddjsb2); Log.LogDebug($"Added {ddjsb2.Name}"); /* * var keyboard = new KeyboardMapping.Controller * { * Arduino = arduino, * Name = "Keypad", * SharedState = SharedState, * Settings = settings, * VirtualJoysticks = eliteVirtualJoysticks, * Logger = Log * }; * * keyboard.Initialize(KeyboardController, GameService); * * Controllers.Add(keyboard); */ // State Handlers var subscription = SharedState.GearChanged.Subscribe( _ => ffb2.CallActivateButton(vJoyTypes.Virtual, MappedButtons.LandingGearToggle, 200)); virtualControllerUpdater = StartUpdateData(eliteVirtualJoysticks, 300); ClientActions.ClientInformationAction(this, "Controllers Ready"); Log.LogDebug("Controllers Ready"); } catch (Exception ex) { Log.LogError(ex.Message); ClientActions.ClientInformationAction(this, $"Controller Error: {ex.Message}"); } }