Example #1
0
 public static void UnMapGamePadDevices(UserGame game, UserSetting setting, bool configureHidGuardian)
 {
     // Disable map.
     if (setting != null)
     {
         setting.MapTo = (int)MapTo.Disabled;
     }
     if (configureHidGuardian)
     {
         // Unhide device if no longer mapped.
         var changed = SettingsManager.AutoHideShowMappedDevices(game, new Guid[] { setting.InstanceGuid });
         if (changed)
         {
             AppHelper.SynchronizeToHidGuardian(setting.InstanceGuid);
         }
     }
 }
Example #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            if (ControlsHelper.IsDesignMode(this))
            {
                return;
            }
            StartHelper.OnClose += (sender1, e1)
                                   => Close();
            StartHelper.OnRestore += (sender1, e1)
                                     => Global._TrayManager.RestoreFromTray(true);
            AppHelper.InitializeHidGuardian();
            if (string.IsNullOrEmpty(System.Threading.Thread.CurrentThread.Name))
            {
                System.Threading.Thread.CurrentThread.Name = "MainFormThread";
            }
            Global.DHelper.DevicesUpdated                         += DHelper_DevicesUpdated;
            Global.DHelper.UpdateCompleted                        += DHelper_UpdateCompleted;
            Global.DHelper.FrequencyUpdated                       += DHelper_FrequencyUpdated;
            Global.DHelper.StatesRetrieved                        += DHelper_StatesRetrieved;
            Global.DHelper.XInputReloaded                         += DHelper_XInputReloaded;
            MainBodyPanel.SettingsPanel._ParentControl             = MainPanel._bwm;
            MainBodyPanel.SettingsPanel.MainDataGrid.SelectionMode = System.Windows.Controls.DataGridSelectionMode.Extended;
            MainBodyPanel.SettingsPanel.InitPanel();
            // NotifySettingsChange will be called on event suspension and resume.
            SettingsManager.Current.NotifySettingsStatus = NotifySettingsStatus;
            // NotifySettingsChange will be called on setting changes.
            SettingsManager.Current.SettingChanged      += Current_SettingChanged;
            SettingsManager.Summaries.Items.ListChanged += Summaries_ListChanged;
            XInputMaskScanner.FileInfoCache.Load();
            UpdateTimer = new System.Timers.Timer
            {
                AutoReset = false,
                Interval  = DefaultPoolingInterval
            };
            UpdateTimer.Elapsed += UpdateTimer_Elapsed;
            SettingsTimer        = new System.Timers.Timer
            {
                AutoReset = false,
                Interval  = 500
            };
            SettingsTimer.Elapsed += SettingsTimer_Elapsed;
            CleanStatusTimer       = new System.Timers.Timer
            {
                AutoReset = false,
                Interval  = 3000
            };
            CleanStatusTimer.Elapsed += CleanStatusTimer_Elapsed;
            Title = EngineHelper.GetProductFullName();
            MainBodyPanel.ShowProgramsTab(SettingsManager.Options.ShowProgramsTab);
            MainBodyPanel.ShowSettingsTab(SettingsManager.Options.ShowSettingsTab);
            MainBodyPanel.ShowDevicesTab(SettingsManager.Options.ShowDevicesTab);
            // Start Timers.
            UpdateTimer.Start();
            JocysCom.ClassLibrary.Win32.NativeMethods.CleanSystemTray();
            // If enabling first time and application version changed then...
            ErrorsHelper.InitErrorsHelper(AppVersionChanged, MainPanel.StatusErrorsLabel, MainPanel.StatusErrorsIcon, MainPanel);
            var game = SettingsManager.CurrentGame;

            if (SettingsManager.Options.HidGuardianConfigureAutomatically)
            {
                // Enable Reconfigure HID Guardian.
                var changed             = SettingsManager.AutoHideShowMappedDevices(game);
                var mappedInstanceGuids = SettingsManager.GetMappedDevices(game?.FileName, true)
                                          .Select(x => x.InstanceGuid).ToArray();
                AppHelper.SynchronizeToHidGuardian(mappedInstanceGuids);
            }
        }