private void GameRunning_OnLoaded(object sender, RoutedEventArgs e) { JvsPackageEmulator.Initialize(); if (InputCode.ButtonMode == EmulationProfile.EuropaRFordRacing || InputCode.ButtonMode == EmulationProfile.EuropaRSegaRally3) { if (_europa == null) { _europa = new EuropaRPipeHandler(); } _europa.StartListening(InputCode.ButtonMode == EmulationProfile.EuropaRSegaRally3); } if (InputCode.ButtonMode == EmulationProfile.FastIo) { if (_fastIo == null) { _fastIo = new FastIoPipe(); } _fastIo.StartListening(); } if (_rawInputListener == null) { _rawInputListener = new RawInputListener(); } if (InputCode.ButtonMode == EmulationProfile.SegaJvsLetsGoIsland || InputCode.ButtonMode == EmulationProfile.SegaJvsLetsGoJungle) { InputCode.AnalogBytes[0] = 127; InputCode.AnalogBytes[2] = 127; InputCode.AnalogBytes[4] = 127; InputCode.AnalogBytes[6] = 127; } else { InputCode.AnalogBytes[0] = 0; InputCode.AnalogBytes[2] = 0; InputCode.AnalogBytes[4] = 0; InputCode.AnalogBytes[6] = 0; } if (_parrotData.UseMouse && _gameProfile.GunGame) { _rawInputListener.ListenToDevice(InputCode.ButtonMode == EmulationProfile.SegaJvsGoldenGun || InputCode.ButtonMode == EmulationProfile.Hotd4); } switch (InputCode.ButtonMode) { case EmulationProfile.NamcoPokken: _controlSender = new Pokken(); break; case EmulationProfile.ExBoard: _controlSender = new ExBoard(); break; case EmulationProfile.GtiClub3: _controlSender = new GtiClub3(); break; case EmulationProfile.Daytona3: _controlSender = new Daytona3(); break; case EmulationProfile.GRID: _controlSender = new GRID(); break; } _controlSender?.Start(); if (_gameProfile.GunGame) { KillGunListener = false; LgiThread = new Thread(HandleLgiControls); LgiThread.Start(); } if (!_runEmuOnly) { WriteConfigIni(); } if (InputCode.ButtonMode != EmulationProfile.EuropaRFordRacing && InputCode.ButtonMode != EmulationProfile.EuropaRSegaRally3 && InputCode.ButtonMode != EmulationProfile.FastIo) { // TODO: MAYBE MAKE THESE XML BASED? switch (InputCode.ButtonMode) { case EmulationProfile.VirtuaRLimit: case EmulationProfile.ChaseHq2: case EmulationProfile.WackyRaces: { JvsPackageEmulator.EnableTaito = true; JvsPackageEmulator.JvsSwitchCount = 0x18; } break; case EmulationProfile.TaitoTypeXBattleGear: { JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.EnableTaitoStick = true; JvsPackageEmulator.EnableTaitoBattleGear = true; JvsPackageEmulator.JvsSwitchCount = 0x18; } break; case EmulationProfile.TaitoTypeXGeneric: { JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.EnableTaitoStick = true; JvsPackageEmulator.JvsSwitchCount = 0x18; } break; case EmulationProfile.BorderBreak: { InputCode.AnalogBytes[0] = 0x7F; // Center analog InputCode.AnalogBytes[2] = 0x7F; // Center analog } break; case EmulationProfile.NamcoPokken: { JvsPackageEmulator.JvsVersion = 0x31; JvsPackageEmulator.JvsCommVersion = 0x31; JvsPackageEmulator.JvsCommandRevision = 0x31; JvsPackageEmulator.JvsIdentifier = JvsHelper.JVS_IDENTIFIER_NBGI_Pokken; JvsPackageEmulator.EnableNamco = true; } break; case EmulationProfile.NamcoWmmt5: case EmulationProfile.NamcoMkdx: { JvsPackageEmulator.JvsVersion = 0x31; JvsPackageEmulator.JvsCommVersion = 0x31; JvsPackageEmulator.JvsCommandRevision = 0x31; JvsPackageEmulator.JvsIdentifier = JvsHelper.JVS_IDENTIFIER_NBGI_MarioKart3; JvsPackageEmulator.EnableNamco = true; JvsPackageEmulator.JvsSwitchCount = 0x18; } break; case EmulationProfile.NamcoMachStorm: { JvsPackageEmulator.JvsVersion = 0x31; JvsPackageEmulator.JvsCommVersion = 0x31; JvsPackageEmulator.JvsCommandRevision = 0x31; JvsPackageEmulator.JvsIdentifier = JvsHelper.JVS_IDENTIFIER_StarWars; JvsPackageEmulator.EnableNamco = true; JvsPackageEmulator.JvsSwitchCount = 0x18; } break; case EmulationProfile.DevThing1: { JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.EnableTaitoStick = true; JvsPackageEmulator.EnableTaitoBattleGear = true; JvsPackageEmulator.EnableDualJvsEmulation = true; JvsPackageEmulator.JvsSwitchCount = 0x18; } break; case EmulationProfile.VirtuaTennis4: case EmulationProfile.ArcadeLove: { JvsPackageEmulator.EnableDualJvsEmulation = true; } break; case EmulationProfile.LGS: { JvsPackageEmulator.JvsCommVersion = 0x30; JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.JvsCommandRevision = 0x30; JvsPackageEmulator.JvsIdentifier = JvsHelper.JVS_IDENTIFIER_SegaLetsGoSafari; } break; } _serialPortHandler.StopListening(); Thread.Sleep(1000); _jvsThread = new Thread(() => _serialPortHandler.ListenPipe("TeknoParrot_JVS")); _jvsThread.Start(); _processQueueThread = new Thread(_serialPortHandler.ProcessQueue); _processQueueThread.Start(); } if (_parrotData.UseMouse && _gameProfile.GunGame) { _diThread?.Abort(0); _diThread = null; } else { _diThread?.Abort(0); _diThread = CreateInputListenerThread(_parrotData.XInputMode); } if (_parrotData.UseDiscordRPC) { DiscordRPC.UpdatePresence(new DiscordRPC.RichPresence { details = _gameProfile.GameName, largeImageKey = _gameProfile.GameName.Replace(" ", "").ToLower(), //https://stackoverflow.com/a/17632585 startTimestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds }); } // Wait before launching second thread. if (!_runEmuOnly) { Thread.Sleep(1000); _gameRunning = true; CreateGameProcess(); } else { if (_parrotData.UseHaptic && _gameProfile.ForceFeedback) { StartFfb(); } } }
private void GameRunning_OnLoaded(object sender, RoutedEventArgs e) { JvsPackageEmulator.Initialize(); switch (InputCode.ButtonMode) { case EmulationProfile.EuropaRFordRacing: if (_pipe == null) { _pipe = new EuropaRPipe(); } break; case EmulationProfile.EuropaRSegaRally3: if (_pipe == null) { _pipe = new SegaRallyPipe(); } break; case EmulationProfile.FastIo: if (_pipe == null) { _pipe = new FastIOPipe(); } break; } _pipe?.Start(); var invertButtons = _gameProfile.ConfigValues.Any(x => x.FieldName == "Invert Buttons" && x.FieldValue == "1"); if (invertButtons) { JvsPackageEmulator.InvertMaiMaiButtons = true; } if (_rawInputListener == null) { _rawInputListener = new RawInputListener(); } if (InputCode.ButtonMode == EmulationProfile.SegaJvsLetsGoIsland || InputCode.ButtonMode == EmulationProfile.SegaJvsLetsGoJungle) { InputCode.AnalogBytes[0] = 127; InputCode.AnalogBytes[2] = 127; InputCode.AnalogBytes[4] = 127; InputCode.AnalogBytes[6] = 127; } else { InputCode.AnalogBytes[0] = 0; InputCode.AnalogBytes[2] = 0; InputCode.AnalogBytes[4] = 0; InputCode.AnalogBytes[6] = 0; } bool useMouseForGun = _gameProfile.ConfigValues.Any(x => x.FieldName == "UseMouseForGun" && x.FieldValue == "1"); if (useMouseForGun && _gameProfile.GunGame) { _rawInputListener.ListenToDevice(InputCode.ButtonMode == EmulationProfile.SegaJvsGoldenGun || InputCode.ButtonMode == EmulationProfile.Hotd4); } switch (InputCode.ButtonMode) { case EmulationProfile.NamcoPokken: _controlSender = new Pokken(); break; case EmulationProfile.ExBoard: _controlSender = new ExBoard(); break; case EmulationProfile.GtiClub3: _controlSender = new GtiClub3(); break; case EmulationProfile.Daytona3: _controlSender = new Daytona3(); break; case EmulationProfile.GRID: _controlSender = new GRID(); break; } _controlSender?.Start(); if (_gameProfile.GunGame) { _killGunListener = false; _gunThread = new Thread(HandleGun); _gunThread.Start(); } if (!_runEmuOnly) { WriteConfigIni(); } if (InputCode.ButtonMode != EmulationProfile.EuropaRFordRacing && InputCode.ButtonMode != EmulationProfile.EuropaRSegaRally3 && InputCode.ButtonMode != EmulationProfile.FastIo) { // TODO: MAYBE MAKE THESE XML BASED? switch (InputCode.ButtonMode) { case EmulationProfile.VirtuaRLimit: case EmulationProfile.ChaseHq2: case EmulationProfile.WackyRaces: JvsPackageEmulator.Taito = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.TaitoTypeXBattleGear: JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.TaitoStick = true; JvsPackageEmulator.TaitoBattleGear = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.TaitoTypeXGeneric: JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.TaitoStick = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.BorderBreak: InputCode.AnalogBytes[0] = 0x7F; // Center analog InputCode.AnalogBytes[2] = 0x7F; // Center analog break; case EmulationProfile.NamcoPokken: JvsPackageEmulator.JvsVersion = 0x31; JvsPackageEmulator.JvsCommVersion = 0x31; JvsPackageEmulator.JvsCommandRevision = 0x31; JvsPackageEmulator.JvsIdentifier = JVSIdentifiers.NBGI_Pokken; JvsPackageEmulator.Namco = true; break; case EmulationProfile.NamcoWmmt5: case EmulationProfile.NamcoMkdx: JvsPackageEmulator.JvsVersion = 0x31; JvsPackageEmulator.JvsCommVersion = 0x31; JvsPackageEmulator.JvsCommandRevision = 0x31; JvsPackageEmulator.JvsIdentifier = JVSIdentifiers.NBGI_MarioKart3; JvsPackageEmulator.Namco = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.NamcoMachStorm: JvsPackageEmulator.JvsVersion = 0x31; JvsPackageEmulator.JvsCommVersion = 0x31; JvsPackageEmulator.JvsCommandRevision = 0x31; JvsPackageEmulator.JvsIdentifier = JVSIdentifiers.NamcoMultipurpose; JvsPackageEmulator.Namco = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.DevThing1: JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.TaitoStick = true; JvsPackageEmulator.TaitoBattleGear = true; JvsPackageEmulator.DualJvsEmulation = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.VirtuaTennis4: case EmulationProfile.ArcadeLove: JvsPackageEmulator.DualJvsEmulation = true; break; case EmulationProfile.LGS: JvsPackageEmulator.JvsCommVersion = 0x30; JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.JvsCommandRevision = 0x30; JvsPackageEmulator.JvsIdentifier = JVSIdentifiers.SegaLetsGoSafari; break; } _serialPortHandler.StopListening(); Thread.Sleep(1000); _jvsThread = new Thread(() => _serialPortHandler.ListenPipe("TeknoParrot_JVS")); _jvsThread.Start(); _processQueueThread = new Thread(_serialPortHandler.ProcessQueue); _processQueueThread.Start(); } if (useMouseForGun && _gameProfile.GunGame) { _diThread?.Abort(0); _diThread = null; } else { _diThread?.Abort(0); _diThread = CreateInputListenerThread( _gameProfile.ConfigValues.Any(x => x.FieldName == "XInput" && x.FieldValue == "1")); } if (_parrotData.UseDiscordRPC) { DiscordRPC.UpdatePresence(new DiscordRPC.RichPresence { details = _gameProfile.GameName, largeImageKey = _gameProfile.GameName.Replace(" ", "").ToLower(), //https://stackoverflow.com/a/17632585 startTimestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds }); } // Wait before launching second thread. if (!_runEmuOnly) { Thread.Sleep(1000); _gameRunning = true; CreateGameProcess(); } }
private void GameRunning_OnLoaded(object sender, RoutedEventArgs e) { JvsPackageEmulator.Initialize(); switch (InputCode.ButtonMode) { case EmulationProfile.EuropaRFordRacing: if (_pipe == null) { _pipe = new EuropaRPipe(); } break; case EmulationProfile.EuropaRSegaRally3: if (_pipe == null) { _pipe = new SegaRallyPipe(); } break; case EmulationProfile.FastIo: if (_pipe == null) { _pipe = new FastIOPipe(); } break; case EmulationProfile.Theatrhythm: if (_pipe == null) { _pipe = new FastIOPipe(); } break; } _pipe?.Start(_runEmuOnly); var invertButtons = _gameProfile.ConfigValues.Any(x => x.FieldName == "Invert Buttons" && x.FieldValue == "1"); if (invertButtons) { JvsPackageEmulator.InvertMaiMaiButtons = true; } if (_rawInputListener == null) { _rawInputListener = new RawInputListener(); } bool flag = InputCode.ButtonMode == EmulationProfile.SegaJvsLetsGoIsland || InputCode.ButtonMode == EmulationProfile.SegaJvsLetsGoJungle || InputCode.ButtonMode == EmulationProfile.LuigisMansion; //fills 0, 2, 4, 6 for (int i = 0; i <= 6; i += 2) { InputCode.AnalogBytes[i] = flag ? (byte)127 : (byte)0; } bool useMouseForGun = _gameProfile.ConfigValues.Any(x => x.FieldName == "UseMouseForGun" && x.FieldValue == "1"); if (useMouseForGun && _gameProfile.GunGame) { _rawInputListener.ListenToDevice(_gameProfile.InvertedMouseAxis, _gameProfile); } switch (InputCode.ButtonMode) { case EmulationProfile.NamcoPokken: _controlSender = new Pokken(); break; case EmulationProfile.ExBoard: _controlSender = new ExBoard(); break; case EmulationProfile.GtiClub3: _controlSender = new GtiClub3(); break; case EmulationProfile.Daytona3: _controlSender = new Daytona3(); break; case EmulationProfile.GRID: _controlSender = new GRID(); break; case EmulationProfile.RawThrillsFNF: _controlSender = new RawThrills(); break; case EmulationProfile.LuigisMansion: _controlSender = new LuigisMansion(); break; case EmulationProfile.GHA: _controlSender = new GHA(); break; } _controlSender?.Start(); if (_gameProfile.GunGame) { _killGunListener = false; if (_gameProfile.EmulationProfile == EmulationProfile.TooSpicy) { new Thread(HandleGunControls2Spicy).Start(); } else { new Thread(HandleGunControls).Start(); } } if (!_runEmuOnly) { WriteConfigIni(); } if (InputCode.ButtonMode != EmulationProfile.EuropaRFordRacing && InputCode.ButtonMode != EmulationProfile.EuropaRSegaRally3 && InputCode.ButtonMode != EmulationProfile.Theatrhythm && InputCode.ButtonMode != EmulationProfile.FastIo) { bool DualJvsEmulation = _gameProfile.ConfigValues.Any(x => x.FieldName == "DualJvsEmulation" && x.FieldValue == "1"); // TODO: MAYBE MAKE THESE XML BASED? switch (InputCode.ButtonMode) { case EmulationProfile.VirtuaRLimit: case EmulationProfile.ChaseHq2: case EmulationProfile.WackyRaces: JvsPackageEmulator.Taito = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.TaitoTypeXBattleGear: JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.TaitoStick = true; JvsPackageEmulator.TaitoBattleGear = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.TaitoTypeXGeneric: JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.TaitoStick = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.BorderBreak: InputCode.AnalogBytes[0] = 0x7F; // Center analog InputCode.AnalogBytes[2] = 0x7F; // Center analog break; case EmulationProfile.NamcoPokken: JvsPackageEmulator.JvsVersion = 0x31; JvsPackageEmulator.JvsCommVersion = 0x31; JvsPackageEmulator.JvsCommandRevision = 0x31; JvsPackageEmulator.JvsIdentifier = JVSIdentifiers.NBGI_Pokken; JvsPackageEmulator.Namco = true; break; case EmulationProfile.NamcoWmmt5: case EmulationProfile.NamcoMkdx: JvsPackageEmulator.JvsVersion = 0x31; JvsPackageEmulator.JvsCommVersion = 0x31; JvsPackageEmulator.JvsCommandRevision = 0x31; JvsPackageEmulator.JvsIdentifier = JVSIdentifiers.NBGI_MarioKart3; JvsPackageEmulator.Namco = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.NamcoMachStorm: JvsPackageEmulator.JvsVersion = 0x31; JvsPackageEmulator.JvsCommVersion = 0x31; JvsPackageEmulator.JvsCommandRevision = 0x31; JvsPackageEmulator.JvsIdentifier = JVSIdentifiers.NamcoMultipurpose; JvsPackageEmulator.Namco = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.DevThing1: JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.TaitoStick = true; JvsPackageEmulator.TaitoBattleGear = true; JvsPackageEmulator.DualJvsEmulation = true; JvsPackageEmulator.JvsSwitchCount = 0x18; break; case EmulationProfile.VirtuaTennis4: JvsPackageEmulator.DualJvsEmulation = DualJvsEmulation; break; case EmulationProfile.ArcadeLove: JvsPackageEmulator.DualJvsEmulation = true; break; case EmulationProfile.LGS: JvsPackageEmulator.JvsCommVersion = 0x30; JvsPackageEmulator.JvsVersion = 0x30; JvsPackageEmulator.JvsCommandRevision = 0x30; JvsPackageEmulator.JvsIdentifier = JVSIdentifiers.SegaLetsGoSafari; JvsPackageEmulator.LetsGoSafari = true; JvsPackageEmulator.JvsSwitchCount = 0x16; break; } _serialPortHandler.StopListening(); Thread.Sleep(1000); new Thread(() => _serialPortHandler.ListenPipe("TeknoParrot_JVS")).Start(); new Thread(_serialPortHandler.ProcessQueue).Start(); } if (useMouseForGun && _gameProfile.GunGame) { _diThread?.Abort(0); _diThread = null; } else { _diThread?.Abort(0); _diThread = CreateInputListenerThread( _gameProfile.ConfigValues.Any(x => x.FieldName == "XInput" && x.FieldValue == "1")); } if (Lazydata.ParrotData.UseDiscordRPC) { DiscordRPC.UpdatePresence(new DiscordRPC.RichPresence { details = _gameProfile.GameName, largeImageKey = _gameProfile.GameName.Replace(" ", "").ToLower(), //https://stackoverflow.com/a/17632585 startTimestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds }); } // Wait before launching second thread. if (!_runEmuOnly) { Thread.Sleep(1000); CreateGameProcess(); } else { #if DEBUG if (jvsDebug != null) { new Thread(() => { while (true) { if (jvsDebug.JvsOverride) { Dispatcher.Invoke(DispatcherPriority.Normal, new ThreadStart(jvsDebug.DoCheckBoxesDude)); } } }).Start(); } #endif } }