private void TerminateThreads() { _rawInputListener?.StopListening(); _controlSender?.Stop(); InputListener?.StopListening(); _serialPortHandler?.StopListening(); _pipe?.Stop(); _killGunListener = true; }
private void TerminateThreads() { _rawInputListener?.StopListening(); _fastIo?.StopListening(); _controlSender?.Stop(); _inputListener?.StopListening(); _serialPortHandler?.StopListening(); _europa?.StopListening(); KillGunListener = true; }
private void TerminateThreads() { _rawInputListener?.StopListening(); _specialControl?.StopListening(); _pokkenControlSender.StopListening(); _gtiClub3ControlSender.StopListening(); _inputListener?.StopListening(); _serialPortHandler?.StopListening(); _europa?.StopListening(); KillGunListener = true; }
private void GameRunning_OnLoaded(object sender, RoutedEventArgs e) { var rawInput = new RawInputListener(); if (_settingsData.UseMouse && (InputCode.ButtonMode == GameProfiles.LetsGoIsland || InputCode.ButtonMode == GameProfiles.SegaDreamRaiders || InputCode.ButtonMode == GameProfiles.GoldenGun)) { rawInput.ListenToDevice(InputCode.ButtonMode == GameProfiles.GoldenGun); } var directInputListener = new DirectInputListener(); var xinputListener = new XInputListener(); KeyboardController kc = new KeyboardController(); var jvsThread = new Thread(() => _serialPortHandler.ListenSerial("COM14")); jvsThread.Start(); var processQueueThread = new Thread(_serialPortHandler.ProcessQueue); processQueueThread.Start(); Thread directInputThreadP1; if (_settingsData.UseMouse && (InputCode.ButtonMode == GameProfiles.LetsGoIsland || InputCode.ButtonMode == GameProfiles.SegaDreamRaiders || InputCode.ButtonMode == GameProfiles.GoldenGun)) { directInputThreadP1 = null; } else { directInputThreadP1 = CreateDirectInputThread(_settingsData.PlayerOneGuid, 1, directInputListener, xinputListener, _joystickMapping1, _xinputMapping1, _settingsData.XInputMode); } // Wait before launching second thread. Thread.Sleep(1000); var directInputThreadP2 = CreateDirectInputThread(_settingsData.PlayerTwoGuid, 2, directInputListener, xinputListener, _joystickMapping2, _xinputMapping2, _settingsData.XInputMode); _gameRunning = true; if (_settingsData.UseKeyboard && (InputCode.ButtonMode == GameProfiles.MeltyBlood || InputCode.ButtonMode == GameProfiles.VirtuaTennis4)) { kc.Subscribe(directInputThreadP1 == null, directInputThreadP2 == null); } var gameThread = new Thread(() => { ProcessStartInfo info; if (_isTest) { if (_testMenuIsExe) { info = new ProcessStartInfo("ParrotLoader.exe", $"\"{Path.Combine(Path.GetDirectoryName(_gameLocation), _testMenuExe)}\" {_testMenuString}"); } else { info = new ProcessStartInfo("ParrotLoader.exe", $"\"{_gameLocation}\" {_testMenuString}"); } } else { info = new ProcessStartInfo("ParrotLoader.exe", $"\"{_gameLocation}\""); } info.UseShellExecute = false; info.WindowStyle = ProcessWindowStyle.Normal; var process = Process.Start(info); while (!process.HasExited) { // We only resurrect this since I had no crashes ever in the other threads. Feel free to improve! if (directInputThreadP1 != null && !directInputThreadP1.IsAlive) { directInputThreadP1 = CreateDirectInputThread(_settingsData.PlayerOneGuid, 1, directInputListener, xinputListener, _joystickMapping1, _xinputMapping1, _settingsData.XInputMode); } if (directInputThreadP2 != null && !directInputThreadP2.IsAlive) { directInputThreadP2 = CreateDirectInputThread(_settingsData.PlayerTwoGuid, 2, directInputListener, xinputListener, _joystickMapping2, _xinputMapping2, _settingsData.XInputMode); } Thread.Sleep(5000); } _serialPortHandler.KillMe = true; directInputListener.KillMe = true; xinputListener.KillMe = true; _gameRunning = false; Dispatcher.Invoke(DispatcherPriority.Normal, new ThreadStart(this.Close)); if (_settingsData.UseKeyboard && (InputCode.ButtonMode == GameProfiles.MeltyBlood || InputCode.ButtonMode == GameProfiles.VirtuaTennis4)) { kc.Unsubscribe(); } if (_settingsData.UseMouse && (InputCode.ButtonMode == GameProfiles.LetsGoIsland || InputCode.ButtonMode == GameProfiles.SegaDreamRaiders || InputCode.ButtonMode == GameProfiles.GoldenGun)) { rawInput.StopListening(); } }); gameThread.Start(); }