public void Initialize() { LanguageManager languageManager = LanguageManager.Instance; try { LoadSettings(SettingsFilePath); logger.Info("Loading settings was successful."); log(string.Format(Translate("LoadSettingsSuccess"), SettingsFilePath)); } catch (Exception ex) { logger.Warning("Loading settings was unsuccessful."); string error = string.Format(Translate("LoadSettingsError"), SettingsFilePath) + Environment.NewLine + ex.Message; log(error); MessageBox.Show(error, Translate("Warning")); } bool vigem = VigemDevice.IsAvailable(); bool scp = ScpDevice.IsAvailable(); if (vigem) { if (scp) { logger.Info("SCPToolkit is installed only."); log(Translate("ScpInstalled")); } installed = true; } else { if (scp) { logger.Info("ViGEm is installed."); log(Translate("VigemNotInstalled")); installed = true; } else { logger.Error("Neither ViGEm nor SCPToolkit is installed."); string error = Translate("VigemAndScpNotInstalled"); log(error); installed = false; MessageBox.Show(error, Translate("Error")); } } Model.Settings = settings; RefreshGameControllers(); var keyboardGameController = new GameController(new Devices.Input.Keyboard.Keyboard(), settings.GetMapper("Keyboard")); var controllerView = new ControllerView(new ControllerViewModel(new ControllerModel(), keyboardGameController, log)); controllerView.ViewModel.Model.CanStart = installed; Model.Controllers.Add(controllerView); log(string.Format(LanguageModel.Instance.Translate("ControllerConnected"), LanguageModel.Instance.Translate("Keyboard"))); HandleArgs(); }
public XOutputManager() { if (VigemDevice.IsAvailable()) { xOutputDevice = new VigemDevice(); } else if (ScpDevice.IsAvailable()) { xOutputDevice = new ScpDevice(); } else { xOutputDevice = null; } }
private IXOutputInterface createXOutput() { if (VigemDevice.IsAvailable()) { logger.Info("ViGEm devices are used."); return(new VigemDevice()); } else if (ScpDevice.IsAvailable()) { logger.Info("SCP Toolkit devices are used."); return(new ScpDevice()); } else { logger.Warning("Neither ViGEm nor SCP devices can be used."); return(null); } }
public DiagnosticsResult GetVigemDeviceResult() { DiagnosticsResult result = new DiagnosticsResult { Type = XInputDiagnosticsTypes.VigemDevice, }; if (VigemDevice.IsAvailable()) { result.Value = true; result.State = DiagnosticsResultState.Passed; } else { result.Value = false; result.State = DiagnosticsResultState.Warning; } return(result); }
private void SetForceFeedback() { if (device.ForceFeedbackCount > 0) { if (VigemDevice.IsAvailable()) { Model.ForceFeedbackText = ""; Model.ForceFeedbackEnabled = device.InputConfiguration.ForceFeedback; Model.ForceFeedbackAvailable = true; } else { Model.ForceFeedbackEnabled = false; Model.ForceFeedbackAvailable = false; Model.ForceFeedbackText = "ForceFeedbackVigemOnly"; } } else { Model.ForceFeedbackEnabled = false; Model.ForceFeedbackAvailable = false; Model.ForceFeedbackText = "ForceFeedbackUnsupported"; } }
public void Initialize(Action <string> log) { this.log = log; LanguageManager languageManager = LanguageManager.Instance; try { LoadSettings(SettingsFilePath); languageManager.Language = settings.Language; logger.Info("Loading settings was successful."); log(string.Format(Translate("LoadSettingsSuccess"), SettingsFilePath)); } catch (Exception ex) { logger.Warning("Loading settings was unsuccessful."); string error = string.Format(Translate("LoadSettingsError"), SettingsFilePath) + Environment.NewLine + ex.Message; log(error); MessageBox.Show(error, Translate("Warning")); } if (settings.HidGuardianEnabled) { try { HidGuardianManager.Instance.ResetPid(pid); Model.IsAdmin = true; logger.Info("HidGuardian registry is set"); log(string.Format(Translate("HidGuardianEnabledSuccessfully"), pid.ToString())); } catch (UnauthorizedAccessException) { Model.IsAdmin = false; logger.Warning("Not running in elevated mode."); log(Translate("HidGuardianNotAdmin")); } catch (Exception ex) { logger.Error(ex); MessageBox.Show(ex.ToString()); } } bool vigem = VigemDevice.IsAvailable(); bool scp = ScpDevice.IsAvailable(); if (vigem) { if (scp) { logger.Info("SCPToolkit is installed only."); log(Translate("ScpInstalled")); } installed = true; } else { if (scp) { logger.Info("ViGEm is installed."); log(Translate("VigemNotInstalled")); installed = true; } else { logger.Error("Neither ViGEm nor SCPToolkit is installed."); string error = Translate("VigemAndScpNotInstalled"); log(error); installed = false; MessageBox.Show(error, Translate("Error")); } } Model.Settings = settings; RefreshGameControllers(); logger.Debug("Creating keyboard controller"); Devices.Input.Keyboard.Keyboard keyboard = new Devices.Input.Keyboard.Keyboard(); InputConfig inputConfig = settings.GetInputConfiguration(keyboard.ToString(), keyboard.InputConfiguration); InputDevices.Instance.Add(keyboard); Model.Inputs.Add(new InputView(new InputViewModel(new InputModel(), keyboard, false))); foreach (var mapping in settings.Mapping) { AddController(mapping); } log(string.Format(LanguageModel.Instance.Translate("ControllerConnected"), LanguageModel.Instance.Translate("Keyboard"))); logger.Info("Keyboard controller is connected"); HandleArgs(); }
public void Initialize(Action <string> log) { try { RegistryKey RegKeyDelCH = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\HidGuardian\\Parameters\\Whitelist"); if (RegKeyDelCH == null) { RegKeyDelCH.Close(); RegistryKey RegKeyAdd = Registry.LocalMachine.CreateSubKey("SYSTEM\\CurrentControlSet\\Services\\HidGuardian\\Parameters\\Whitelist\\" + pid); } else { RegKeyDelCH.Close(); RegistryKey RegKeyDel = Registry.LocalMachine; RegKeyDel.DeleteSubKeyTree("SYSTEM\\CurrentControlSet\\Services\\HidGuardian\\Parameters\\Whitelist"); RegKeyDel.Close(); RegistryKey RegKeyAdd = Registry.LocalMachine.CreateSubKey("SYSTEM\\CurrentControlSet\\Services\\HidGuardian\\Parameters\\Whitelist\\" + pid); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } this.log = log; LanguageManager languageManager = LanguageManager.Instance; try { LoadSettings(SettingsFilePath); logger.Info("Loading settings was successful."); log(string.Format(Translate("LoadSettingsSuccess"), SettingsFilePath)); } catch (Exception ex) { logger.Warning("Loading settings was unsuccessful."); string error = string.Format(Translate("LoadSettingsError"), SettingsFilePath) + Environment.NewLine + ex.Message; log(error); MessageBox.Show(error, Translate("Warning")); } bool vigem = VigemDevice.IsAvailable(); bool scp = ScpDevice.IsAvailable(); if (vigem) { if (scp) { logger.Info("SCPToolkit is installed only."); log(Translate("ScpInstalled")); } installed = true; } else { if (scp) { logger.Info("ViGEm is installed."); log(Translate("VigemNotInstalled")); installed = true; } else { logger.Error("Neither ViGEm nor SCPToolkit is installed."); string error = Translate("VigemAndScpNotInstalled"); log(error); installed = false; MessageBox.Show(error, Translate("Error")); } } Model.Settings = settings; RefreshGameControllers(); var keyboardGameController = new GameController(new Devices.Input.Keyboard.Keyboard(), settings.GetMapper("Keyboard")); var controllerView = new ControllerView(new ControllerViewModel(new ControllerModel(), keyboardGameController, log)); controllerView.ViewModel.Model.CanStart = installed; Model.Controllers.Add(controllerView); log(string.Format(LanguageModel.Instance.Translate("ControllerConnected"), LanguageModel.Instance.Translate("Keyboard"))); HandleArgs(); }