private static void UserDevices_Items_ListChanged(object sender, ListChangedEventArgs e)
        {
            var pd = e.PropertyDescriptor;

            if (pd != null && e.ListChangedType == ListChangedType.ItemChanged)
            {
                if (e.PropertyDescriptor.Name == nameof(Engine.Data.UserDevice.IsHidden))
                {
                    var ud = UserDevices.Items[e.NewIndex];
                    if (ud.AllowHide)
                    {
                        var canModify = ViGEm.HidGuardianHelper.CanModifyParameters(true);
                        if (canModify)
                        {
                            //var ids = AppHelper.GetIdsToAffect(ud.HidDeviceId, ud.HidHardwareIds);
                            var ids = new string[] { ud.DevDeviceId };
                            //ud.IsHidden = !ud.IsHidden;
                            // Use begin invoke which will prevent mouse multi-select rows.
                            ControlsHelper.BeginInvoke(() =>
                            {
                                AppHelper.SynchronizeToHidGuardian(ud.InstanceGuid);
                            });
                        }
                        else
                        {
                            var form = new MessageBoxWindow();
                            form.ShowDialog("Can't modify HID Guardian registry.\r\nPlease run this application as Administrator once in order to fix permissions.", "Permission Denied",
                                            System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void UserDevices_Items_ListChanged(object sender, ListChangedEventArgs e)
        {
            // If list item was not changed then return.
            if (e.ListChangedType != ListChangedType.ItemChanged)
            {
                return;
            }
            // If not IsHidden changed then return.
            if (e.PropertyDescriptor?.Name != nameof(Engine.Data.UserDevice.IsHidden))
            {
                return;
            }
            var ud = UserDevices.Items[e.NewIndex];

            // If device allowed to be hidden then...
            if (ud.AllowHide)
            {
                var canModify = ViGEm.HidGuardianHelper.CanModifyParameters(true);
                if (canModify)
                {
                    var ids = new string[] { ud.DevDeviceId };
                    // Use begin invoke which will prevent mouse multi-select rows.
                    ControlsHelper.BeginInvoke(()
                                               => AppHelper.SynchronizeToHidGuardian(ud.InstanceGuid));
                }
                else
                {
                    var form = new MessageBoxWindow();
                    form.ShowDialog("Can't modify HID Guardian registry.\r\nPlease run this application as Administrator once in order to fix permissions.", "Permission Denied",
                                    System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
                }
            }
        }
Ejemplo n.º 3
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);
         }
     }
 }
Ejemplo n.º 4
0
 public static void MapGamePadDevices(UserGame game, MapTo mappedTo, UserDevice[] devices, bool configureHidGuardian)
 {
     foreach (var ud in devices)
     {
         // Try to get existing setting by instance guid and file name.
         var setting = GetSetting(ud.InstanceGuid, game.FileName);
         // If device setting for the game was not found then.
         if (setting == null)
         {
             // Create new setting.
             setting = AppHelper.GetNewSetting(ud, game, mappedTo);
             // Get auto-configured pad setting.
             var ps = AutoMapHelper.GetAutoPreset(ud);
             Current.LoadPadSettingAndCleanup(setting, ps, true);
             Current.SyncFormFromPadSetting(mappedTo, ps);
             // Refresh online status
             RefreshDeviceIsOnlineValueOnSettings(setting);
             // Load created setting.
             //SettingsManager.Current.LoadPadSettings(MappedTo, ps);
         }
         else
         {
             // Enable if not enabled.
             if (!setting.IsEnabled)
             {
                 setting.IsEnabled = true;
             }
             // Map setting to current pad.
             setting.MapTo = (int)mappedTo;
         }
     }
     if (configureHidGuardian)
     {
         var instanceGuids = devices.Select(x => x.InstanceGuid).ToArray();
         var changed       = AutoHideShowMappedDevices(game, instanceGuids);
         if (changed)
         {
             AppHelper.SynchronizeToHidGuardian(instanceGuids);
         }
     }
 }
Ejemplo n.º 5
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);
            }
        }