Exemple #1
0
        //Play interface sound
        public static void PlayInterfaceSound(Configuration sourceConfig, string soundName, bool forceSound, bool forceMaxVolume)
        {
            try
            {
                if (forceSound || Convert.ToBoolean(Setting_Load(sourceConfig, "InterfaceSound")))
                {
                    double soundVolume = (double)Convert.ToInt32(Setting_Load(sourceConfig, "InterfaceSoundVolume")) / 100;
                    if (forceMaxVolume)
                    {
                        soundVolume = 1.00;
                    }
                    else if (forceSound && soundVolume <= 0.20)
                    {
                        soundVolume = 0.75;
                    }

                    string soundPackName = Setting_Load(sourceConfig, "InterfaceSoundPackName").ToString();
                    string soundFileName = "Assets/Default/Sounds/" + soundPackName + "/" + soundName + ".mp3";
                    if (Directory.Exists("Assets/User/Sounds/" + soundPackName))
                    {
                        soundFileName = "Assets/User/Sounds/" + soundPackName + "/" + soundName + ".mp3";
                    }

                    if (File.Exists(soundFileName))
                    {
                        Uri soundFileUri = new Uri(soundFileName, UriKind.RelativeOrAbsolute);
                        AVActions.ActionDispatcherInvoke(delegate
                        {
                            windowsMediaPlayer.Volume = soundVolume;
                            windowsMediaPlayer.Open(soundFileUri);
                            windowsMediaPlayer.Play();
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed to play sound: " + soundName + " / " + ex.Message);
            }
        }
Exemple #2
0
        //Update the controller status icons
        async Task UpdateControllerConnected()
        {
            try
            {
                //Check if process DirectXInput is running
                if (vProcessDirectXInput == null)
                {
                    //Debug.WriteLine("DirectXInput is not running, skipping controller check.");
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        txt_Main_Battery.Visibility = Visibility.Collapsed;
                        img_Main_Battery.Visibility = Visibility.Collapsed;
                        grid_Main_Time.Visibility   = Visibility.Collapsed;
                    });
                    return;
                }

                //Request controller status from DirectXInput
                await RequestControllerStatus();
            }
            catch { }
        }
Exemple #3
0
 //Update the current time
 void UpdateCurrentTime()
 {
     try
     {
         if (Convert.ToBoolean(Setting_Load(vConfigurationFpsOverlayer, "TimeShowCurrentTime")))
         {
             AVActions.ActionDispatcherInvoke(delegate
             {
                 textblock_CurrentTime.Text        = DateTime.Now.ToShortTimeString();
                 stackpanel_CurrentTime.Visibility = Visibility.Visible;
             });
         }
         else
         {
             AVActions.ActionDispatcherInvoke(delegate
             {
                 stackpanel_CurrentTime.Visibility = Visibility.Collapsed;
             });
         }
     }
     catch { }
 }
Exemple #4
0
        //Update the clipboard status text
        void Clipboard_UpdateStatusText()
        {
            try
            {
                AVActions.ActionDispatcherInvoke(delegate
                {
                    if (vClipboardFiles.Count == 1)
                    {
                        DataBindFile clipboardFile = vClipboardFiles.FirstOrDefault();
                        grid_Popup_FilePicker_textblock_ClipboardStatus.Text       = "Clipboard (" + clipboardFile.FileType.ToString() + " " + clipboardFile.ClipboardType.ToString() + ") " + clipboardFile.PathFile;
                        grid_Popup_FilePicker_textblock_ClipboardStatus.Visibility = Visibility.Visible;
                    }
                    else if (vClipboardFiles.Count > 1)
                    {
                        int copyCount      = vClipboardFiles.Count(x => x.ClipboardType == ClipboardType.Copy);
                        int cutCount       = vClipboardFiles.Count(x => x.ClipboardType == ClipboardType.Cut);
                        string statusCount = string.Empty;
                        if (copyCount > cutCount)
                        {
                            statusCount = "(" + copyCount + "x copy)";
                        }
                        else
                        {
                            statusCount = "(" + cutCount + "x cut)";
                        }

                        grid_Popup_FilePicker_textblock_ClipboardStatus.Text       = "Clipboard " + statusCount + " files or folders.";
                        grid_Popup_FilePicker_textblock_ClipboardStatus.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        grid_Popup_FilePicker_textblock_ClipboardStatus.Text       = string.Empty;
                        grid_Popup_FilePicker_textblock_ClipboardStatus.Visibility = Visibility.Collapsed;
                    }
                });
            }
            catch { }
        }
Exemple #5
0
 //Update all keypad key names
 public void UpdateKeypadNames()
 {
     try
     {
         AVActions.ActionDispatcherInvoke(delegate
         {
             try
             {
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.DPadLeftMod, vKeypadMappingProfile.DPadLeft, grid_DPadLeft, textblock_DPadLeft);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.DPadUpMod, vKeypadMappingProfile.DPadUp, grid_DPadUp, textblock_DPadUp);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.DPadRightMod, vKeypadMappingProfile.DPadRight, grid_DPadRight, textblock_DPadRight);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.DPadDownMod, vKeypadMappingProfile.DPadDown, grid_DPadDown, textblock_DPadDown);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ThumbLeftLeftMod, vKeypadMappingProfile.ThumbLeftLeft, grid_ThumbLeftLeft, textblock_ThumbLeftLeft);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ThumbLeftUpMod, vKeypadMappingProfile.ThumbLeftUp, grid_ThumbLeftUp, textblock_ThumbLeftUp);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ThumbLeftRightMod, vKeypadMappingProfile.ThumbLeftRight, grid_ThumbLeftRight, textblock_ThumbLeftRight);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ThumbLeftDownMod, vKeypadMappingProfile.ThumbLeftDown, grid_ThumbLeftDown, textblock_ThumbLeftDown);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ThumbRightLeftMod, vKeypadMappingProfile.ThumbRightLeft, grid_ThumbRightLeft, textblock_ThumbRightLeft);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ThumbRightUpMod, vKeypadMappingProfile.ThumbRightUp, grid_ThumbRightUp, textblock_ThumbRightUp);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ThumbRightRightMod, vKeypadMappingProfile.ThumbRightRight, grid_ThumbRightRight, textblock_ThumbRightRight);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ThumbRightDownMod, vKeypadMappingProfile.ThumbRightDown, grid_ThumbRightDown, textblock_ThumbRightDown);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonBackMod, vKeypadMappingProfile.ButtonBack, grid_ButtonBack, textblock_ButtonBack);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonStartMod, vKeypadMappingProfile.ButtonStart, grid_ButtonStart, textblock_ButtonStart);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonXMod, vKeypadMappingProfile.ButtonX, grid_ButtonX, textblock_ButtonX);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonYMod, vKeypadMappingProfile.ButtonY, grid_ButtonY, textblock_ButtonY);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonAMod, vKeypadMappingProfile.ButtonA, grid_ButtonA, textblock_ButtonA);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonBMod, vKeypadMappingProfile.ButtonB, grid_ButtonB, textblock_ButtonB);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonShoulderLeftMod, vKeypadMappingProfile.ButtonShoulderLeft, grid_ButtonShoulderLeft, textblock_ButtonShoulderLeft);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonTriggerLeftMod, vKeypadMappingProfile.ButtonTriggerLeft, grid_ButtonTriggerLeft, textblock_ButtonTriggerLeft);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonThumbLeftMod, vKeypadMappingProfile.ButtonThumbLeft, grid_ButtonThumbLeft, textblock_ButtonThumbLeft);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonShoulderRightMod, vKeypadMappingProfile.ButtonShoulderRight, grid_ButtonShoulderRight, textblock_ButtonShoulderRight);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonTriggerRightMod, vKeypadMappingProfile.ButtonTriggerRight, grid_ButtonTriggerRight, textblock_ButtonTriggerRight);
                 UpdateKeypadKeyDetails(vKeypadMappingProfile.ButtonThumbRightMod, vKeypadMappingProfile.ButtonThumbRight, grid_ButtonThumbRight, textblock_ButtonThumbRight);
             }
             catch { }
         });
     }
     catch { }
 }
Exemple #6
0
        //Update the active controller
        void UpdateActiveController()
        {
            try
            {
                //Debug.WriteLine("Updating active controller.");
                ControllerStatus activeController = AppVariables.vActiveController();
                if (activeController == null)
                {
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        stackpanel_ControllerActive.Visibility = Visibility.Collapsed;
                    });
                    return;
                }

                AVActions.ActionDispatcherInvoke(delegate
                {
                    stackpanel_ControllerActive.Visibility = Visibility.Visible;
                    border_ControllerActive.Background     = new SolidColorBrush((Color)activeController.Color);
                });
            }
            catch { }
        }
Exemple #7
0
        //Check for empty lists and hide them
        void ShowHideEmptyList()
        {
            try
            {
                Visibility visibilityGames     = List_Games.Any() ? Visibility.Visible : Visibility.Collapsed;
                Visibility visibilityApps      = List_Apps.Any() ? Visibility.Visible : Visibility.Collapsed;
                Visibility visibilityEmulators = List_Emulators.Any() ? Visibility.Visible : Visibility.Collapsed;
                Visibility visibilityLaunchers = List_Launchers.Any() ? Visibility.Visible : Visibility.Collapsed;
                Visibility visibilityShortcuts = List_Shortcuts.Any() && Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowOtherShortcuts")) ? Visibility.Visible : Visibility.Collapsed;
                Visibility visibilityProcesses = List_Processes.Any() && Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowOtherProcesses")) ? Visibility.Visible : Visibility.Collapsed;

                AVActions.ActionDispatcherInvoke(delegate
                {
                    sp_Games.Visibility     = visibilityGames;
                    sp_Apps.Visibility      = visibilityApps;
                    sp_Emulators.Visibility = visibilityEmulators;
                    sp_Launchers.Visibility = visibilityLaunchers;
                    sp_Shortcuts.Visibility = visibilityShortcuts;
                    sp_Processes.Visibility = visibilityProcesses;
                });
            }
            catch { }
        }
Exemple #8
0
        //Update the battery status position
        public void UpdateBatteryPosition()
        {
            try
            {
                //Check current fps overlay position
                OverlayPosition fpsTextPosition = (OverlayPosition)Convert.ToInt32(Setting_Load(vConfigurationFpsOverlayer, "TextPosition"));
                //Debug.WriteLine("Fps overlayer text position: " + fpsTextPosition);

                //Move the battery status position
                AVActions.ActionDispatcherInvoke(delegate
                {
                    if (vProcessFpsOverlayer == null || (vProcessFpsOverlayer != null && fpsTextPosition != OverlayPosition.BottomLeft))
                    {
                        stackpanel_Battery_Warning.VerticalAlignment = VerticalAlignment.Bottom;
                    }
                    else
                    {
                        stackpanel_Battery_Warning.VerticalAlignment = VerticalAlignment.Top;
                    }
                });
            }
            catch { }
        }
Exemple #9
0
 //Check if there is an actived controller
 async Task ControllerCheckActivated()
 {
     try
     {
         //Debug.WriteLine("There is currently no actived controller.");
         ControllerStatus activeController = vActiveController();
         if (vController0.Connected() && activeController == null)
         {
             await ControllerActivate(vController0);
         }
         else if (vController1.Connected() && activeController == null)
         {
             await ControllerActivate(vController1);
         }
         else if (vController2.Connected() && activeController == null)
         {
             await ControllerActivate(vController2);
         }
         else if (vController3.Connected() && activeController == null)
         {
             await ControllerActivate(vController3);
         }
         else if (activeController == null)
         {
             //Clear the current controller information
             AVActions.ActionDispatcherInvoke(delegate
             {
                 txt_ActiveControllerType.Text       = "Type";
                 txt_ActiveControllerLatency.Text    = "Latency";
                 txt_ActiveControllerBattery.Text    = "Battery";
                 txt_ActiveControllerName.Text       = "No controller";
                 txt_ActiveControllerName.Foreground = (SolidColorBrush)Application.Current.Resources["ApplicationAccentLightBrush"];
             });
         }
     }
     catch { }
 }
Exemple #10
0
 //Check if there is an actived controller
 void ControllerCheckActivated()
 {
     try
     {
         //Debug.WriteLine("There is currently no actived controller.");
         ControllerStatus activeController = vActiveController();
         if (vController0.Connected() && activeController == null)
         {
             ControllerActivate(vController0);
         }
         else if (vController1.Connected() && activeController == null)
         {
             ControllerActivate(vController1);
         }
         else if (vController2.Connected() && activeController == null)
         {
             ControllerActivate(vController2);
         }
         else if (vController3.Connected() && activeController == null)
         {
             ControllerActivate(vController3);
         }
         else if (activeController == null)
         {
             //Clear the current controller information
             AVActions.ActionDispatcherInvoke(delegate
             {
                 txt_ActiveControllerType.Text    = "Type";
                 txt_ActiveControllerLatency.Text = "Latency";
                 txt_ActiveControllerBattery.Text = "Battery";
                 txt_ActiveControllerName.Text    = "No controller";
             });
         }
     }
     catch { }
 }
Exemple #11
0
        //Show the File Picker Popup
        async Task Popup_Show_FilePicker_Task(string targetPath, int targetIndex, bool storeIndex, FrameworkElement previousFocus)
        {
            try
            {
                //Check if the popup is already open
                if (!vFilePickerOpen)
                {
                    //Play the popup opening sound
                    PlayInterfaceSound(vConfigurationCtrlUI, "PopupOpen", false);

                    //Save the previous focus element
                    FrameworkElementFocusSave(vFilePickerElementFocus, previousFocus);
                }

                //Reset file picker variables
                vFilePickerCompleted = false;
                vFilePickerCancelled = false;
                vFilePickerResult    = null;
                vFilePickerOpen      = true;

                AVActions.ActionDispatcherInvoke(delegate
                {
                    //Disable the file picker list
                    lb_FilePicker.IsEnabled = false;
                    gif_FilePicker_Loading.Show();

                    //Set file picker header texts
                    grid_Popup_FilePicker_txt_Title.Text       = vFilePickerTitle;
                    grid_Popup_FilePicker_txt_Description.Text = vFilePickerDescription;

                    //Change the list picker item style
                    if (vFilePickerShowRoms)
                    {
                        lb_FilePicker.Style        = Application.Current.Resources["ListBoxWrapPanelVertical"] as Style;
                        lb_FilePicker.ItemTemplate = Application.Current.Resources["ListBoxItemRom"] as DataTemplate;
                        grid_Popup_Filepicker_Row1.HorizontalAlignment = HorizontalAlignment.Center;
                    }
                    else
                    {
                        lb_FilePicker.Style        = Application.Current.Resources["ListBoxVertical"] as Style;
                        lb_FilePicker.ItemTemplate = Application.Current.Resources["ListBoxItemFile"] as DataTemplate;
                        grid_Popup_Filepicker_Row1.HorizontalAlignment = HorizontalAlignment.Stretch;
                    }

                    //Update the navigation history index
                    if (storeIndex)
                    {
                        FilePicker_NavigationHistoryAddUpdate(vFilePickerCurrentPath, lb_FilePicker.SelectedIndex);
                    }

                    //Clear the current file picker list
                    List_FilePicker.Clear();
                });

                //Show the popup
                Popup_Show_Element(grid_Popup_FilePicker);

                //Update the current picker path
                vFilePickerSourcePath  = vFilePickerCurrentPath;
                vFilePickerCurrentPath = targetPath;

                //Get and list all the disk drives
                if (targetPath == "PC")
                {
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        //Enable or disable selection button in the list
                        grid_Popup_FilePicker_button_SelectFolder.Visibility = Visibility.Collapsed;

                        //Enable or disable file and folder availability
                        grid_Popup_FilePicker_textblock_NoFilesAvailable.Visibility = Visibility.Collapsed;

                        //Enable or disable the side navigate buttons
                        grid_Popup_FilePicker_button_ControllerLeft.Visibility  = Visibility.Visible;
                        grid_Popup_FilePicker_button_ControllerUp.Visibility    = Visibility.Collapsed;
                        grid_Popup_FilePicker_button_ControllerStart.Visibility = Visibility.Collapsed;

                        //Enable or disable the copy paste status
                        if (vClipboardFiles.Any())
                        {
                            grid_Popup_FilePicker_textblock_ClipboardStatus.Visibility = Visibility.Visible;
                        }

                        //Enable or disable the current path
                        grid_Popup_FilePicker_textblock_CurrentPath.Visibility = Visibility.Collapsed;
                    });

                    //Load folder images
                    BitmapImage imageFolder          = FileToBitmapImage(new string[] { "Assets/Default/Icons/Folder.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    BitmapImage imageFolderDisc      = FileToBitmapImage(new string[] { "Assets/Default/Icons/FolderDisc.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    BitmapImage imageFolderNetwork   = FileToBitmapImage(new string[] { "Assets/Default/Icons/FolderNetwork.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    BitmapImage imageFolderPrevious  = FileToBitmapImage(new string[] { "Assets/Default/Icons/Restart.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    BitmapImage imageFolderDocuments = FileToBitmapImage(new string[] { "Assets/Default/Icons/Copy.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    BitmapImage imageFolderDesktop   = FileToBitmapImage(new string[] { "Assets/Default/Icons/Desktop.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    BitmapImage imageFolderDownload  = FileToBitmapImage(new string[] { "Assets/Default/Icons/Download.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    BitmapImage imageFolderPictures  = FileToBitmapImage(new string[] { "Assets/Default/Icons/Background.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    BitmapImage imageFolderVideos    = FileToBitmapImage(new string[] { "Assets/Default/Icons/BackgroundVideo.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                    BitmapImage imageFolderMusic     = FileToBitmapImage(new string[] { "Assets/Default/Icons/Music.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);

                    //Add launch without a file option
                    if (vFilePickerShowNoFile)
                    {
                        string       fileDescription         = "Launch application without a file";
                        BitmapImage  fileImage               = FileToBitmapImage(new string[] { "Assets/Default/Icons/AppLaunch.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                        DataBindFile dataBindFileWithoutFile = new DataBindFile()
                        {
                            FileType = FileType.FilePre, Name = fileDescription, Description = fileDescription + ".", ImageBitmap = fileImage, PathFile = string.Empty
                        };
                        await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileWithoutFile, false, false);
                    }

                    //Check and add the previous path
                    if (!string.IsNullOrWhiteSpace(vFilePickerPreviousPath))
                    {
                        DataBindFile dataBindFilePreviousPath = new DataBindFile()
                        {
                            FileType = FileType.FolderPre, Name = "Previous", NameSub = "(" + vFilePickerPreviousPath + ")", ImageBitmap = imageFolderPrevious, PathFile = vFilePickerPreviousPath
                        };
                        await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFilePreviousPath, false, false);
                    }

                    //Add special folders
                    DataBindFile dataBindFileDesktop = new DataBindFile()
                    {
                        FileType = FileType.FolderPre, Name = "My Desktop", ImageBitmap = imageFolderDesktop, PathFile = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
                    };
                    await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileDesktop, false, false);

                    DataBindFile dataBindFileDocuments = new DataBindFile()
                    {
                        FileType = FileType.FolderPre, Name = "My Documents", ImageBitmap = imageFolderDocuments, PathFile = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
                    };
                    await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileDocuments, false, false);

                    try
                    {
                        string downloadsPath = Registry.GetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", "{374DE290-123F-4565-9164-39C4925E467B}", string.Empty).ToString();
                        if (!string.IsNullOrWhiteSpace(downloadsPath) && Directory.Exists(downloadsPath))
                        {
                            DataBindFile dataBindFileDownloads = new DataBindFile()
                            {
                                FileType = FileType.FolderPre, Name = "My Downloads", ImageBitmap = imageFolderDownload, PathFile = downloadsPath
                            };
                            await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileDownloads, false, false);
                        }
                    }
                    catch { }

                    DataBindFile dataBindFileMusic = new DataBindFile()
                    {
                        FileType = FileType.FolderPre, Name = "My Music", ImageBitmap = imageFolderMusic, PathFile = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)
                    };
                    await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileMusic, false, false);

                    DataBindFile dataBindFilePictures = new DataBindFile()
                    {
                        FileType = FileType.FolderPre, Name = "My Pictures", ImageBitmap = imageFolderPictures, PathFile = Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)
                    };
                    await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFilePictures, false, false);

                    DataBindFile dataBindFileVideos = new DataBindFile()
                    {
                        FileType = FileType.FolderPre, Name = "My Videos", ImageBitmap = imageFolderVideos, PathFile = Environment.GetFolderPath(Environment.SpecialFolder.MyVideos)
                    };
                    await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileVideos, false, false);

                    //Add all disk drives that are connected
                    DriveInfo[] diskDrives = DriveInfo.GetDrives();
                    foreach (DriveInfo disk in diskDrives)
                    {
                        try
                        {
                            //Skip network drive depending on the setting
                            if (disk.DriveType == DriveType.Network && Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "HideNetworkDrives")))
                            {
                                continue;
                            }

                            //Check if the disk is currently connected
                            if (disk.IsReady)
                            {
                                //Get the current disk size
                                string freeSpace = AVFunctions.ConvertBytesSizeToString(disk.TotalFreeSpace);
                                string usedSpace = AVFunctions.ConvertBytesSizeToString(disk.TotalSize);
                                string diskSpace = freeSpace + "/" + usedSpace;

                                DataBindFile dataBindFileDisk = new DataBindFile()
                                {
                                    FileType = FileType.Folder, Name = disk.Name, NameSub = disk.VolumeLabel, NameDetail = diskSpace, PathFile = disk.Name
                                };
                                if (disk.DriveType == DriveType.CDRom)
                                {
                                    dataBindFileDisk.FileType    = FileType.FolderDisc;
                                    dataBindFileDisk.ImageBitmap = imageFolderDisc;
                                }
                                else if (disk.DriveType == DriveType.Network)
                                {
                                    dataBindFileDisk.ImageBitmap = imageFolderNetwork;
                                }
                                else
                                {
                                    dataBindFileDisk.ImageBitmap = imageFolder;
                                }
                                await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileDisk, false, false);
                            }
                        }
                        catch { }
                    }

                    //Add Json file locations
                    foreach (ProfileShared Locations in vCtrlLocationsFile)
                    {
                        try
                        {
                            if (Directory.Exists(Locations.String2))
                            {
                                //Check if the location is a root folder
                                FileType      locationType = FileType.FolderPre;
                                DirectoryInfo locationInfo = new DirectoryInfo(Locations.String2);
                                if (locationInfo.Parent == null)
                                {
                                    locationType = FileType.Folder;
                                }

                                //Get the current disk size
                                string    diskSpace = string.Empty;
                                DriveType disktype  = DriveType.Unknown;
                                try
                                {
                                    DriveInfo driveInfo = new DriveInfo(Locations.String2);
                                    disktype = driveInfo.DriveType;
                                    string freeSpace = AVFunctions.ConvertBytesSizeToString(driveInfo.TotalFreeSpace);
                                    string usedSpace = AVFunctions.ConvertBytesSizeToString(driveInfo.TotalSize);
                                    diskSpace = freeSpace + "/" + usedSpace;
                                }
                                catch { }

                                DataBindFile dataBindFileLocation = new DataBindFile()
                                {
                                    FileType = locationType, Name = Locations.String2, NameSub = Locations.String1, NameDetail = diskSpace, PathFile = Locations.String2
                                };
                                if (disktype == DriveType.CDRom)
                                {
                                    dataBindFileLocation.FileType    = FileType.FolderDisc;
                                    dataBindFileLocation.ImageBitmap = imageFolderDisc;
                                }
                                else if (disktype == DriveType.Network)
                                {
                                    dataBindFileLocation.ImageBitmap = imageFolderNetwork;
                                }
                                else
                                {
                                    dataBindFileLocation.ImageBitmap = imageFolder;
                                }
                                await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileLocation, false, false);
                            }
                        }
                        catch { }
                    }
                }
                //Get and list all the UWP applications
                else if (targetPath == "UWP")
                {
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        //Enable or disable selection button in the list
                        grid_Popup_FilePicker_button_SelectFolder.Visibility = Visibility.Collapsed;

                        //Enable or disable file and folder availability
                        grid_Popup_FilePicker_textblock_NoFilesAvailable.Visibility = Visibility.Collapsed;

                        //Enable or disable the side navigate buttons
                        grid_Popup_FilePicker_button_ControllerLeft.Visibility  = Visibility.Visible;
                        grid_Popup_FilePicker_button_ControllerUp.Visibility    = Visibility.Collapsed;
                        grid_Popup_FilePicker_button_ControllerStart.Visibility = Visibility.Collapsed;

                        //Enable or disable the copy paste status
                        grid_Popup_FilePicker_textblock_ClipboardStatus.Visibility = Visibility.Collapsed;

                        //Enable or disable the current path
                        grid_Popup_FilePicker_textblock_CurrentPath.Visibility = Visibility.Collapsed;
                    });

                    //Add uwp applications to the filepicker list
                    await ListLoadAllUwpApplications(lb_FilePicker, List_FilePicker);
                }
                else
                {
                    //Clean the target path string
                    targetPath = Path.GetFullPath(targetPath);

                    //Add the Go up directory to the list
                    if (Path.GetPathRoot(targetPath) != targetPath)
                    {
                        BitmapImage  imageBack        = FileToBitmapImage(new string[] { "Assets/Default/Icons/Up.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                        DataBindFile dataBindFileGoUp = new DataBindFile()
                        {
                            FileType = FileType.GoUpPre, Name = "Go up", Description = "Go up to the previous folder.", ImageBitmap = imageBack, PathFile = Path.GetDirectoryName(targetPath)
                        };
                        await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileGoUp, false, false);
                    }
                    else
                    {
                        BitmapImage  imageBack        = FileToBitmapImage(new string[] { "Assets/Default/Icons/Up.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                        DataBindFile dataBindFileGoUp = new DataBindFile()
                        {
                            FileType = FileType.GoUpPre, Name = "Go up", Description = "Go up to the previous folder.", ImageBitmap = imageBack, PathFile = "PC"
                        };
                        await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileGoUp, false, false);
                    }

                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        //Enable or disable the copy paste status
                        if (vClipboardFiles.Any())
                        {
                            grid_Popup_FilePicker_textblock_ClipboardStatus.Visibility = Visibility.Visible;
                        }

                        //Enable or disable the current path
                        grid_Popup_FilePicker_textblock_CurrentPath.Text       = "Current path: " + targetPath;
                        grid_Popup_FilePicker_textblock_CurrentPath.Visibility = Visibility.Visible;
                    });

                    //Add launch emulator options
                    if (vFilePickerShowRoms)
                    {
                        string       fileDescription        = "Launch the emulator without a rom loaded";
                        BitmapImage  fileImage              = FileToBitmapImage(new string[] { "Assets/Default/Icons/Emulator.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                        DataBindFile dataBindFileWithoutRom = new DataBindFile()
                        {
                            FileType = FileType.FilePre, Name = fileDescription, Description = fileDescription + ".", ImageBitmap = fileImage, PathFile = string.Empty
                        };
                        await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileWithoutRom, false, false);

                        string       romDescription        = "Launch the emulator with this folder as rom";
                        BitmapImage  romImage              = FileToBitmapImage(new string[] { "Assets/Default/Icons/Emulator.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                        DataBindFile dataBindFileFolderRom = new DataBindFile()
                        {
                            FileType = FileType.FilePre, Name = romDescription, Description = romDescription + ".", ImageBitmap = romImage, PathFile = targetPath
                        };
                        await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileFolderRom, false, false);
                    }

                    //Enable or disable the side navigate buttons
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        grid_Popup_FilePicker_button_ControllerLeft.Visibility  = Visibility.Visible;
                        grid_Popup_FilePicker_button_ControllerUp.Visibility    = Visibility.Visible;
                        grid_Popup_FilePicker_button_ControllerStart.Visibility = Visibility.Visible;
                    });

                    //Get all the top files and folders
                    DirectoryInfo   directoryInfo    = new DirectoryInfo(targetPath);
                    DirectoryInfo[] directoryFolders = null;
                    FileInfo[]      directoryFiles   = null;
                    if (vFilePickerSortType == SortingType.Name)
                    {
                        directoryFolders = directoryInfo.GetDirectories("*", SearchOption.TopDirectoryOnly).OrderBy(x => x.Name).ToArray();
                        directoryFiles   = directoryInfo.GetFiles("*", SearchOption.TopDirectoryOnly).OrderBy(x => x.Name).ToArray();
                    }
                    else
                    {
                        directoryFolders = directoryInfo.GetDirectories("*", SearchOption.TopDirectoryOnly).OrderByDescending(x => x.LastWriteTime).ToArray();
                        directoryFiles   = directoryInfo.GetFiles("*", SearchOption.TopDirectoryOnly).OrderByDescending(x => x.LastWriteTime).ToArray();
                    }

                    //Get all rom images and descriptions
                    FileInfo[] directoryRomImages       = new FileInfo[] { };
                    FileInfo[] directoryRomDescriptions = new FileInfo[] { };
                    if (vFilePickerShowRoms)
                    {
                        string[] imageFilter       = { "jpg", "png" };
                        string[] descriptionFilter = { "json" };

                        DirectoryInfo          directoryInfoRomsUser     = new DirectoryInfo("Assets/User/Games");
                        FileInfo[]             directoryPathsRomsUser    = directoryInfoRomsUser.GetFiles("*", SearchOption.AllDirectories);
                        DirectoryInfo          directoryInfoRomsDefault  = new DirectoryInfo("Assets/Default/Games");
                        FileInfo[]             directoryPathsRomsDefault = directoryInfoRomsDefault.GetFiles("*", SearchOption.AllDirectories);
                        IEnumerable <FileInfo> directoryPathsRoms        = directoryPathsRomsUser.Concat(directoryPathsRomsDefault);

                        FileInfo[] romsImages  = directoryPathsRoms.Where(file => imageFilter.Any(filter => file.Name.EndsWith(filter, StringComparison.InvariantCultureIgnoreCase))).ToArray();
                        FileInfo[] filesImages = directoryFiles.Where(file => imageFilter.Any(filter => file.Name.EndsWith(filter, StringComparison.InvariantCultureIgnoreCase))).ToArray();
                        directoryRomImages = filesImages.Concat(romsImages).OrderByDescending(x => x.Name.Length).ToArray();

                        FileInfo[] romsDescriptions  = directoryPathsRoms.Where(file => descriptionFilter.Any(filter => file.Name.EndsWith(filter, StringComparison.InvariantCultureIgnoreCase))).ToArray();
                        FileInfo[] filesDescriptions = directoryFiles.Where(file => descriptionFilter.Any(filter => file.Name.EndsWith(filter, StringComparison.InvariantCultureIgnoreCase))).ToArray();
                        directoryRomDescriptions = filesDescriptions.Concat(romsDescriptions).OrderByDescending(x => x.Name.Length).ToArray();
                    }

                    //Get all the directories from target directory
                    if (vFilePickerShowDirectories)
                    {
                        try
                        {
                            //Fill the file picker listbox with folders
                            foreach (DirectoryInfo listFolder in directoryFolders)
                            {
                                try
                                {
                                    BitmapImage listImage       = null;
                                    string      listDescription = string.Empty;

                                    //Load image files for the list
                                    if (vFilePickerShowRoms)
                                    {
                                        GetRomDetails(listFolder.Name, listFolder.FullName, directoryRomImages, directoryRomDescriptions, ref listImage, ref listDescription);
                                    }
                                    else
                                    {
                                        listImage = FileToBitmapImage(new string[] { "Assets/Default/Icons/Folder.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, -1, 0);
                                    }

                                    //Get the folder size
                                    //string folderSize = AVFunctions.ConvertBytesSizeToString(GetDirectorySize(listDirectory));

                                    //Get the folder date
                                    string folderDate = listFolder.LastWriteTime.ToShortDateString().Replace("-", "/");

                                    //Set the detailed text
                                    string folderDetailed = folderDate;

                                    //Check the copy cut type
                                    ClipboardType clipboardType = ClipboardType.None;
                                    DataBindFile  clipboardFile = vClipboardFiles.Where(x => x.PathFile == listFolder.FullName).FirstOrDefault();
                                    if (clipboardFile != null)
                                    {
                                        clipboardType = clipboardFile.ClipboardType;
                                    }

                                    //Add folder to the list
                                    bool systemFileFolder = listFolder.Attributes.HasFlag(FileAttributes.System);
                                    bool hiddenFileFolder = listFolder.Attributes.HasFlag(FileAttributes.Hidden);
                                    if (!systemFileFolder && (!hiddenFileFolder || Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowHiddenFilesFolders"))))
                                    {
                                        DataBindFile dataBindFileFolder = new DataBindFile()
                                        {
                                            FileType = FileType.Folder, ClipboardType = clipboardType, Name = listFolder.Name, NameDetail = folderDetailed, Description = listDescription, DateModified = listFolder.LastWriteTime, ImageBitmap = listImage, PathFile = listFolder.FullName
                                        };
                                        await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileFolder, false, false);
                                    }
                                }
                                catch { }
                            }
                        }
                        catch { }
                    }

                    //Get all the files from target directory
                    if (vFilePickerShowFiles)
                    {
                        try
                        {
                            //Enable or disable selection button in the list
                            AVActions.ActionDispatcherInvoke(delegate
                            {
                                grid_Popup_FilePicker_button_SelectFolder.Visibility = Visibility.Collapsed;
                            });

                            //Filter files in and out
                            if (vFilePickerFilterIn.Any())
                            {
                                directoryFiles = directoryFiles.Where(file => vFilePickerFilterIn.Any(filter => file.Name.EndsWith(filter, StringComparison.InvariantCultureIgnoreCase))).ToArray();
                            }
                            if (vFilePickerFilterOut.Any())
                            {
                                directoryFiles = directoryFiles.Where(file => !vFilePickerFilterOut.Any(filter => file.Name.EndsWith(filter, StringComparison.InvariantCultureIgnoreCase))).ToArray();
                            }

                            //Fill the file picker listbox with files
                            foreach (FileInfo listFile in directoryFiles)
                            {
                                try
                                {
                                    BitmapImage listImage       = null;
                                    string      listDescription = string.Empty;

                                    //Load image files for the list
                                    if (vFilePickerShowRoms)
                                    {
                                        GetRomDetails(listFile.Name, string.Empty, directoryRomImages, directoryRomDescriptions, ref listImage, ref listDescription);
                                    }
                                    else
                                    {
                                        string listFileFullNameLower  = listFile.FullName.ToLower();
                                        string listFileExtensionLower = listFile.Extension.ToLower().Replace(".", string.Empty);
                                        if (listFileFullNameLower.EndsWith(".jpg") || listFileFullNameLower.EndsWith(".png") || listFileFullNameLower.EndsWith(".gif"))
                                        {
                                            listImage = FileToBitmapImage(new string[] { listFile.FullName }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 50, 0);
                                        }
                                        else
                                        {
                                            listImage = FileToBitmapImage(new string[] { "Assets/Default/Extensions/" + listFileExtensionLower + ".png", "Assets/Default/Icons/File.png" }, vImageSourceFolders, vImageBackupSource, IntPtr.Zero, 50, 0);
                                        }
                                    }

                                    //Get the file size
                                    string fileSize = AVFunctions.ConvertBytesSizeToString(listFile.Length);

                                    //Get the file date
                                    string fileDate = listFile.LastWriteTime.ToShortDateString().Replace("-", "/");

                                    //Set the detailed text
                                    string fileDetailed = fileSize + " (" + fileDate + ")";

                                    //Check the copy cut type
                                    ClipboardType clipboardType = ClipboardType.None;
                                    DataBindFile  clipboardFile = vClipboardFiles.Where(x => x.PathFile == listFile.FullName).FirstOrDefault();
                                    if (clipboardFile != null)
                                    {
                                        clipboardType = clipboardFile.ClipboardType;
                                    }

                                    //Add file to the list
                                    bool systemFileFolder = listFile.Attributes.HasFlag(FileAttributes.System);
                                    bool hiddenFileFolder = listFile.Attributes.HasFlag(FileAttributes.Hidden);
                                    if (!systemFileFolder && (!hiddenFileFolder || Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowHiddenFilesFolders"))))
                                    {
                                        FileType fileType      = FileType.File;
                                        string   fileExtension = Path.GetExtension(listFile.Name);
                                        if (fileExtension == ".url" || fileExtension == ".lnk")
                                        {
                                            fileType = FileType.Link;
                                        }
                                        DataBindFile dataBindFileFile = new DataBindFile()
                                        {
                                            FileType = fileType, ClipboardType = clipboardType, Name = listFile.Name, NameDetail = fileDetailed, Description = listDescription, DateModified = listFile.LastWriteTime, ImageBitmap = listImage, PathFile = listFile.FullName
                                        };
                                        await ListBoxAddItem(lb_FilePicker, List_FilePicker, dataBindFileFile, false, false);
                                    }
                                }
                                catch { }
                            }
                        }
                        catch { }
                    }
                    else
                    {
                        //Enable or disable selection button in the list
                        AVActions.ActionDispatcherInvoke(delegate
                        {
                            grid_Popup_FilePicker_button_SelectFolder.Visibility = Visibility.Visible;
                        });
                    }

                    //Check if there are files or folders
                    FilePicker_CheckFilesAndFoldersCount();
                }

                //Enable the file picker list
                AVActions.ActionDispatcherInvoke(delegate
                {
                    lb_FilePicker.IsEnabled = true;
                    gif_FilePicker_Loading.Hide();
                });

                //Get navigation history index
                if (targetIndex == -1)
                {
                    targetIndex = FilePicker_NavigationHistoryGetIndex(targetPath);
                }

                //Check the navigation index
                if (targetIndex == -1 && !string.IsNullOrWhiteSpace(vFilePickerSourcePath))
                {
                    DataBindFile sourceFileItem = List_FilePicker.Where(x => x.PathFile == vFilePickerSourcePath).FirstOrDefault();
                    if (sourceFileItem != null)
                    {
                        Debug.WriteLine("Source file path found: " + vFilePickerSourcePath);

                        //Focus on the file picker listbox item
                        await ListBoxFocusItem(lb_FilePicker, sourceFileItem, vProcessCurrent.MainWindowHandle);

                        return;
                    }
                }

                //Focus on the file picker listbox index
                await ListboxFocusIndex(lb_FilePicker, false, false, targetIndex, vProcessCurrent.MainWindowHandle);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed loading filepicker: " + ex.Message);
                await FilePicker_Failed();
            }
        }
Exemple #12
0
        //Stop the desired controller as async
        async Task <bool> StopControllerAsync(ControllerStatus Controller, string disconnectTag)
        {
            try
            {
                //Check if the controller is connected
                if (Controller == null || !Controller.Connected())
                {
                    Debug.WriteLine("Controller " + Controller.NumberId + " is already disconnected.");
                    return(false);
                }

                //Update controller block status
                Controller.BlockOutput = true;

                //Update last disconnect time
                vControllerLastDisconnect = DateTime.Now;

                //Get controller display number
                Debug.WriteLine("Disconnecting the controller " + Controller.NumberId + ": " + Controller.Details.DisplayName);
                string controllerNumberDisplay = (Controller.NumberId + 1).ToString();

                //Show controller disconnect notification
                NotificationDetails notificationDetails = new NotificationDetails();
                notificationDetails.Icon = "Controller";
                if (string.IsNullOrWhiteSpace(disconnectTag))
                {
                    notificationDetails.Text = "Disconnected (" + controllerNumberDisplay + ")";
                }
                else
                {
                    notificationDetails.Text = "Disconnected " + disconnectTag + " (" + controllerNumberDisplay + ")";
                }
                App.vWindowOverlay.Notification_Show_Status(notificationDetails);

                //Update user interface controller status
                AVActions.ActionDispatcherInvoke(delegate
                {
                    txt_Controller_Information.Text = "Disconnected controller " + controllerNumberDisplay + ": " + Controller.Details.DisplayName;
                    if (Controller.NumberId == 0)
                    {
                        image_Controller0.Source            = vImagePreloadIconControllerDark;
                        textblock_Controller0.Text          = "No controller connected";
                        textblock_Controller0CodeName.Text  = string.Empty;
                        textblock_LiveDebugInformation.Text = "No controller connected to debug";
                    }
                    else if (Controller.NumberId == 1)
                    {
                        image_Controller1.Source            = vImagePreloadIconControllerDark;
                        textblock_Controller1.Text          = "No controller connected";
                        textblock_Controller1CodeName.Text  = string.Empty;
                        textblock_LiveDebugInformation.Text = "No controller connected to debug";
                    }
                    else if (Controller.NumberId == 2)
                    {
                        image_Controller2.Source            = vImagePreloadIconControllerDark;
                        textblock_Controller2.Text          = "No controller connected";
                        textblock_Controller2CodeName.Text  = string.Empty;
                        textblock_LiveDebugInformation.Text = "No controller connected to debug";
                    }
                    else if (Controller.NumberId == 3)
                    {
                        image_Controller3.Source            = vImagePreloadIconControllerDark;
                        textblock_Controller3.Text          = "No controller connected";
                        textblock_Controller3CodeName.Text  = string.Empty;
                        textblock_LiveDebugInformation.Text = "No controller connected to debug";
                    }
                });

                //Disconnect virtual controller
                if (vVirtualBusDevice != null)
                {
                    //Prepare empty xinput data
                    PrepareXInputDataEmpty(Controller);

                    //Send empty input to the virtual bus
                    vVirtualBusDevice.VirtualInput(ref Controller);

                    //Close the controller virtual events
                    SetAndCloseEvent(Controller.InputVirtualOverlapped.EventHandle);
                    SetAndCloseEvent(Controller.OutputVirtualOverlapped.EventHandle);

                    //Stop the controller loop tasks
                    await TaskStopLoop(Controller.InputControllerTask);
                    await TaskStopLoop(Controller.OutputControllerTask);
                    await TaskStopLoop(Controller.OutputVirtualTask);
                    await TaskStopLoop(Controller.OutputGyroTask);

                    //Disconnect the virtual controller
                    vVirtualBusDevice.VirtualUnplug(Controller.NumberId);
                    await Task.Delay(500);
                }

                //Stop and Close the Win Usb Device
                if (Controller.WinUsbDevice != null)
                {
                    try
                    {
                        //Dispose and stop connection with the controller
                        Controller.WinUsbDevice.CloseDevice();
                    }
                    catch { }
                }

                //Close and dispose the Hid Usb Device
                if (Controller.HidDevice != null)
                {
                    //Disconnect controller from bluetooth
                    try
                    {
                        if (Controller.Details.Wireless)
                        {
                            Controller.HidDevice.BluetoothDisconnect();
                        }
                    }
                    catch
                    {
                        Debug.WriteLine("Failed disconnecting device from bluetooth.");
                    }

                    //Dispose and stop connection with the controller
                    try
                    {
                        Controller.HidDevice.CloseDevice();
                    }
                    catch
                    {
                        Debug.WriteLine("Failed disposing and stopping the controller.");
                    }
                }

                //Reset the controller status
                Controller.ResetControllerStatus();

                //Check if any controller is connected
                if (!vControllerAnyConnected() && Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "KeyboardCloseNoController")))
                {
                    Debug.WriteLine("No controller connected closing open popups.");
                    await HideOpenPopups();
                }

                Debug.WriteLine("Succesfully stopped direct input controller " + Controller.NumberId);
                return(true);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed stopping the controller direct input " + Controller.NumberId + ": " + ex.Message);
                return(false);
            }
        }
Exemple #13
0
        //Update the battery icons and level
        void UpdateBatteryStatus()
        {
            try
            {
                //Debug.WriteLine("Updating battery level of controller.");
                ControllerStatus activeController = AppVariables.vActiveController();
                if (activeController == null)
                {
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        txt_Main_Battery.Visibility = Visibility.Collapsed;
                        img_Main_Battery.Visibility = Visibility.Collapsed;
                        grid_Main_Time.Visibility   = Visibility.Collapsed;
                    });
                    return;
                }
                ControllerBattery controllerBattery = activeController.BatteryCurrent;

                //Check if battery level is available
                if (controllerBattery.BatteryStatus == BatteryStatus.Unknown)
                {
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        txt_Main_Battery.Visibility = Visibility.Collapsed;
                        img_Main_Battery.Visibility = Visibility.Collapsed;
                        grid_Main_Time.Visibility   = Visibility.Collapsed;
                    });
                    return;
                }

                //Check if battery is charging
                if (controllerBattery.BatteryStatus == BatteryStatus.Charging)
                {
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        txt_Main_Battery.Visibility = Visibility.Collapsed;
                        img_Main_Battery.Source     = FileToBitmapImage(new string[] { "Assets/Default/Icons/Battery/BatteryVerCharge.png" }, AppVariables.vImageSourceFolders, AppVariables.vImageBackupSource, IntPtr.Zero, -1, 0);
                        img_Main_Battery.Visibility = Visibility.Visible;
                        grid_Main_Time.Visibility   = Visibility.Visible;
                    });
                    return;
                }

                //Check the battery percentage
                string percentageNumber = "100";
                if (controllerBattery.BatteryPercentage <= 10)
                {
                    percentageNumber = "10";
                }
                else if (controllerBattery.BatteryPercentage <= 20)
                {
                    percentageNumber = "20";
                }
                else if (controllerBattery.BatteryPercentage <= 30)
                {
                    percentageNumber = "30";
                }
                else if (controllerBattery.BatteryPercentage <= 40)
                {
                    percentageNumber = "40";
                }
                else if (controllerBattery.BatteryPercentage <= 50)
                {
                    percentageNumber = "50";
                }
                else if (controllerBattery.BatteryPercentage <= 60)
                {
                    percentageNumber = "60";
                }
                else if (controllerBattery.BatteryPercentage <= 70)
                {
                    percentageNumber = "70";
                }
                else if (controllerBattery.BatteryPercentage <= 80)
                {
                    percentageNumber = "80";
                }
                else if (controllerBattery.BatteryPercentage <= 90)
                {
                    percentageNumber = "90";
                }

                //Set the battery percentage
                AVActions.ActionDispatcherInvoke(delegate
                {
                    //Set the used battery percentage text
                    txt_Main_Battery.Text = Convert.ToString(controllerBattery.BatteryPercentage) + "%";

                    //Set the used battery status icon
                    string currentImage = img_Main_Battery.Source.ToString();
                    string updatedImage = "Assets/Default/Icons/Battery/BatteryVerDis" + percentageNumber + ".png";
                    if (currentImage.ToLower() != updatedImage.ToLower())
                    {
                        img_Main_Battery.Source = FileToBitmapImage(new string[] { updatedImage }, AppVariables.vImageSourceFolders, AppVariables.vImageBackupSource, IntPtr.Zero, -1, 0);
                    }

                    //Show the battery image and clock
                    txt_Main_Battery.Visibility = Visibility.Visible;
                    img_Main_Battery.Visibility = Visibility.Visible;
                    grid_Main_Time.Visibility   = Visibility.Visible;
                });
            }
            catch
            {
                AVActions.ActionDispatcherInvoke(delegate
                {
                    txt_Main_Battery.Visibility = Visibility.Collapsed;
                    img_Main_Battery.Visibility = Visibility.Collapsed;
                    grid_Main_Time.Visibility   = Visibility.Collapsed;
                });
            }
        }
Exemple #14
0
        async Task LoopTraceEventOutput()
        {
            try
            {
                while (!vTask_TraceEventOutput.TaskStopRequest)
                {
                    try
                    {
                        //Check the total available frames and last added frame time
                        int  TotalFrameTimes   = vListFrameTime.Count;
                        bool SkipCurrentFrames = (GetSystemTicksMs() - vLastFrameTimeAdded) >= 1000;
                        if (SkipCurrentFrames || TotalFrameTimes <= 0)
                        {
                            AVActions.ActionDispatcherInvoke(delegate
                            {
                                stackpanel_CurrentFps.Visibility = Visibility.Collapsed;
                            });

                            //Delay the loop task
                            await TaskDelayLoop(1000, vTask_TraceEventOutput);

                            continue;
                        }

                        //Reverse the frames list
                        IEnumerable <double> ReversedFrameList = vListFrameTime.AsEnumerable().Reverse();

                        //Calculate the current fps
                        double CurrentFrameTimes      = ReversedFrameList.Take(100).Average(); //1sec
                        int    CurrentFramesPerSecond = Convert.ToInt32(1000 / CurrentFrameTimes);

                        //Calculate the average fps
                        double AverageFrameTimes      = ReversedFrameList.Average();
                        int    AverageFramesPerSecond = Convert.ToInt32(1000 / AverageFrameTimes);

                        //Convert fps to string
                        string StringCurrentFramesPerSecond = string.Empty;
                        if (Convert.ToBoolean(Setting_Load(vConfigurationFpsOverlayer, "FpsShowCurrentFps")))
                        {
                            StringCurrentFramesPerSecond = " " + CurrentFramesPerSecond.ToString() + "FPS";
                        }
                        string StringCurrentFrameTimes = string.Empty;
                        if (Convert.ToBoolean(Setting_Load(vConfigurationFpsOverlayer, "FpsShowCurrentLatency")))
                        {
                            StringCurrentFrameTimes = " " + CurrentFrameTimes.ToString("0.00") + "MS";
                        }
                        string StringAverageFramesPerSecond = string.Empty;
                        if (Convert.ToBoolean(Setting_Load(vConfigurationFpsOverlayer, "FpsShowAverageFps")))
                        {
                            StringAverageFramesPerSecond = " " + AverageFramesPerSecond.ToString() + "AVG";
                        }

                        //Update the fps counter
                        Debug.WriteLine("(" + vTargetProcess.Identifier + ") MS" + CurrentFrameTimes.ToString("0.00") + " / FPS " + CurrentFramesPerSecond + " / AVG " + AverageFramesPerSecond);
                        string StringDisplay = AVFunctions.StringRemoveStart(vTitleFPS + StringCurrentFramesPerSecond + StringCurrentFrameTimes + StringAverageFramesPerSecond, " ");

                        if (!string.IsNullOrWhiteSpace(StringDisplay))
                        {
                            AVActions.ActionDispatcherInvoke(delegate
                            {
                                textblock_CurrentFps.Text        = StringDisplay;
                                stackpanel_CurrentFps.Visibility = Visibility.Visible;
                            });
                        }
                        else
                        {
                            AVActions.ActionDispatcherInvoke(delegate
                            {
                                stackpanel_CurrentFps.Visibility = Visibility.Collapsed;
                            });
                        }
                    }
                    catch { }

                    //Delay the loop task
                    await TaskDelayLoop(1000, vTask_TraceEventOutput);
                }
            }
            catch { }
        }
Exemple #15
0
        //Update the controller status from DirectXInput
        async Task UpdateControllerStatus(List <ControllerStatusDetails> controllerStatusSummaryList)
        {
            try
            {
                //Update the controller status
                foreach (ControllerStatusDetails controllerStatusNew in controllerStatusSummaryList)
                {
                    //Get current controller status
                    Image      controllerStatusImage            = null;
                    StackPanel controllerStatusStackpanel       = null;
                    ControllerStatusDetails controllerStatusOld = null;
                    if (controllerStatusNew.NumberId == 0)
                    {
                        controllerStatusStackpanel = stackpanel_Menu_Controller0;
                        controllerStatusImage      = img_Menu_Controller0;
                        controllerStatusOld        = vController0;
                    }
                    else if (controllerStatusNew.NumberId == 1)
                    {
                        controllerStatusStackpanel = stackpanel_Menu_Controller1;
                        controllerStatusImage      = img_Menu_Controller1;
                        controllerStatusOld        = vController1;
                    }
                    else if (controllerStatusNew.NumberId == 2)
                    {
                        controllerStatusStackpanel = stackpanel_Menu_Controller2;
                        controllerStatusImage      = img_Menu_Controller2;
                        controllerStatusOld        = vController2;
                    }
                    else if (controllerStatusNew.NumberId == 3)
                    {
                        controllerStatusStackpanel = stackpanel_Menu_Controller3;
                        controllerStatusImage      = img_Menu_Controller3;
                        controllerStatusOld        = vController3;
                    }

                    //Check if controller is active controller
                    if (controllerStatusNew.Activated && vControllerActiveId != controllerStatusNew.NumberId)
                    {
                        ActivateController(controllerStatusNew.NumberId);
                    }

                    //Update the battery icons and level
                    if (controllerStatusNew.Activated)
                    {
                        UpdateBatteryStatus(controllerStatusNew.BatteryCurrent);
                    }

                    //Update the controller status for comparison
                    if (controllerStatusNew.NumberId == 0)
                    {
                        vController0 = controllerStatusNew;
                    }
                    else if (controllerStatusNew.NumberId == 1)
                    {
                        vController1 = controllerStatusNew;
                    }
                    else if (controllerStatusNew.NumberId == 2)
                    {
                        vController2 = controllerStatusNew;
                    }
                    else if (controllerStatusNew.NumberId == 3)
                    {
                        vController3 = controllerStatusNew;
                    }

                    //Show controller connection popup and update the controller menu image
                    if (controllerStatusOld.Connected != controllerStatusNew.Connected)
                    {
                        if (controllerStatusNew.Connected)
                        {
                            AVActions.ActionDispatcherInvoke(delegate { controllerStatusStackpanel.Opacity = 1.00; });
                            string ControllerIdDisplay = Convert.ToString(controllerStatusNew.NumberId + 1);
                            //await Notification_Send_Status("Controller", "Connected (" + ControllerIdDisplay + ")");

                            //Hide the mouse cursor
                            await MouseCursorHide();

                            //Update the controller help
                            UpdateControllerHelp();
                        }
                        else
                        {
                            AVActions.ActionDispatcherInvoke(delegate { controllerStatusStackpanel.Opacity = 0.40; });
                            string ControllerIdDisplay = Convert.ToString(controllerStatusNew.NumberId + 1);
                            //await Notification_Send_Status("Controller", "Disconnected (" + ControllerIdDisplay + ")");

                            //Hide the battery status
                            if (vControllerActiveId == controllerStatusNew.NumberId)
                            {
                                HideBatteryStatus(true);
                            }

                            //Update the controller help
                            UpdateControllerHelp();
                        }
                    }
                }
            }
            catch { }
        }
Exemple #16
0
        //Update interface keypad preview
        void UpdateKeypadPreview()
        {
            try
            {
                AVActions.ActionDispatcherInvoke(delegate
                {
                    try
                    {
                        SolidColorBrush targetSolidColorBrushDarkLight = null;
                        SolidColorBrush targetSolidColorBrushAccent    = (SolidColorBrush)Application.Current.Resources["ApplicationAccentLightBrush"];
                        if (vKeypadMappingProfile.KeypadDisplayStyle == 0)
                        {
                            targetSolidColorBrushDarkLight = (SolidColorBrush) new BrushConverter().ConvertFrom("#FFFFFF");
                        }
                        else
                        {
                            targetSolidColorBrushDarkLight = (SolidColorBrush) new BrushConverter().ConvertFrom("#000000");
                        }

                        //DPad
                        if (vKeypadDownStatus.DPadLeft.Pressed)
                        {
                            textblock_DPadLeft.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_DPadLeft.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.DPadUp.Pressed)
                        {
                            textblock_DPadUp.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_DPadUp.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.DPadRight.Pressed)
                        {
                            textblock_DPadRight.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_DPadRight.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.DPadDown.Pressed)
                        {
                            textblock_DPadDown.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_DPadDown.Foreground = targetSolidColorBrushDarkLight;
                        }

                        //Thumb Left
                        if (vKeypadDownStatus.ThumbLeftLeft.Pressed)
                        {
                            textblock_ThumbLeftLeft.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ThumbLeftLeft.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ThumbLeftUp.Pressed)
                        {
                            textblock_ThumbLeftUp.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ThumbLeftUp.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ThumbLeftRight.Pressed)
                        {
                            textblock_ThumbLeftRight.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ThumbLeftRight.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ThumbLeftDown.Pressed)
                        {
                            textblock_ThumbLeftDown.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ThumbLeftDown.Foreground = targetSolidColorBrushDarkLight;
                        }

                        //Thumb Right
                        if (vKeypadDownStatus.ThumbRightLeft.Pressed)
                        {
                            textblock_ThumbRightLeft.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ThumbRightLeft.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ThumbRightUp.Pressed)
                        {
                            textblock_ThumbRightUp.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ThumbRightUp.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ThumbRightRight.Pressed)
                        {
                            textblock_ThumbRightRight.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ThumbRightRight.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ThumbRightDown.Pressed)
                        {
                            textblock_ThumbRightDown.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ThumbRightDown.Foreground = targetSolidColorBrushDarkLight;
                        }

                        //Buttons
                        if (vKeypadDownStatus.ButtonA.Pressed)
                        {
                            textblock_ButtonA.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonA.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ButtonB.Pressed)
                        {
                            textblock_ButtonB.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonB.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ButtonX.Pressed)
                        {
                            textblock_ButtonX.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonX.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ButtonY.Pressed)
                        {
                            textblock_ButtonY.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonY.Foreground = targetSolidColorBrushDarkLight;
                        }

                        if (vKeypadDownStatus.ButtonBack.Pressed)
                        {
                            textblock_ButtonBack.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonBack.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ButtonStart.Pressed)
                        {
                            textblock_ButtonStart.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonStart.Foreground = targetSolidColorBrushDarkLight;
                        }

                        if (vKeypadDownStatus.ButtonShoulderLeft.Pressed)
                        {
                            textblock_ButtonShoulderLeft.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonShoulderLeft.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ButtonTriggerLeft.Pressed)
                        {
                            textblock_ButtonTriggerLeft.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonTriggerLeft.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ButtonThumbLeft.Pressed)
                        {
                            textblock_ButtonThumbLeft.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonThumbLeft.Foreground = targetSolidColorBrushDarkLight;
                        }

                        if (vKeypadDownStatus.ButtonShoulderRight.Pressed)
                        {
                            textblock_ButtonShoulderRight.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonShoulderRight.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ButtonTriggerRight.Pressed)
                        {
                            textblock_ButtonTriggerRight.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonTriggerRight.Foreground = targetSolidColorBrushDarkLight;
                        }
                        if (vKeypadDownStatus.ButtonThumbRight.Pressed)
                        {
                            textblock_ButtonThumbRight.Foreground = targetSolidColorBrushAccent;
                        }
                        else
                        {
                            textblock_ButtonThumbRight.Foreground = targetSolidColorBrushDarkLight;
                        }
                    }
                    catch { }
                });
            }
            catch { }
        }
Exemple #17
0
        async Task LoadLauncherApplications()
        {
            try
            {
                //Check if already refreshing
                if (vBusyRefreshingLaunchers)
                {
                    Debug.WriteLine("Launchers are already refreshing, cancelling.");
                    return;
                }

                //Update the refreshing status
                vBusyRefreshingLaunchers = true;

                //Show the loading gif
                AVActions.ActionDispatcherInvoke(delegate
                {
                    gif_Launchers_Loading.Show();
                });

                //Check if sorting is required
                bool sortByName = !List_Launchers.Any();

                //Clear the app remove check list
                vLauncherAppAvailableCheck.Clear();

                //Scan and add library from Steam
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibrarySteam")))
                {
                    await SteamScanAddLibrary();
                }

                //Scan and add library from EA Desktop
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryEADesktop")))
                {
                    await EADesktopScanAddLibrary();
                }

                //Scan and add library from Epic
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryEpic")))
                {
                    await EpicScanAddLibrary();
                }

                //Scan and add library from Ubisoft
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryUbisoft")))
                {
                    await UbisoftScanAddLibrary();
                }

                //Scan and add library from GoG
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryGoG")))
                {
                    await GoGScanAddLibrary();
                }

                //Scan and add library from Battle.net
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryBattleNet")))
                {
                    await BattleNetScanAddLibrary();
                }

                //Scan and add library from Bethesda
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryBethesda")))
                {
                    await BethesdaScanAddLibrary();
                }

                //Scan and add library from Rockstar
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryRockstar")))
                {
                    await RockstarScanAddLibrary();
                }

                //Scan and add library from Amazon
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryAmazon")))
                {
                    await AmazonScanAddLibrary();
                }

                //Scan and add library from UWP games
                if (Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowLibraryUwp")))
                {
                    await UwpScanAddLibrary();
                }

                //Remove deleted launcher applications
                Func <DataBindApp, bool> filterLauncherApp = x => x.Category == AppCategory.Launcher && !vLauncherAppAvailableCheck.Any(y => y == x.PathExe);
                await ListBoxRemoveAll(lb_Launchers, List_Launchers, filterLauncherApp);
                await ListBoxRemoveAll(lb_Search, List_Search, filterLauncherApp);

                //Sort applications and select first item
                if (sortByName)
                {
                    SortFunction <DataBindApp> sortFuncName = new SortFunction <DataBindApp>();
                    sortFuncName.function = x => x.Name;

                    List <SortFunction <DataBindApp> > orderListLaunchers = new List <SortFunction <DataBindApp> >();
                    orderListLaunchers.Add(sortFuncName);

                    SortObservableCollection(lb_Launchers, List_Launchers, orderListLaunchers, null);

                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        lb_Launchers.SelectedIndex = 0;
                    });
                }

                //Hide the loading gif
                AVActions.ActionDispatcherInvoke(delegate
                {
                    gif_Launchers_Loading.Hide();
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed loading launchers: " + ex.Message);
            }
            //Update the refreshing status
            vBusyRefreshingLaunchers = false;
        }
Exemple #18
0
        //Update interface controller buttons preview
        void UpdateControllerPreviewButtons(ControllerStatus Controller)
        {
            try
            {
                AVActions.ActionDispatcherInvoke(delegate
                {
                    try
                    {
                        //Update name and type
                        txt_ActiveControllerType.Text = Controller.Details.Wireless ? "Wireless" : "Wired";
                        txt_ActiveControllerName.Text = Controller.Details.DisplayName;

                        //Update latency
                        long latencyMs = Controller.LastInputTicks - Controller.PrevInputTicks;
                        txt_ActiveControllerLatency.Text = "Latency " + latencyMs + "ms";

                        //Update battery
                        if (Controller.BatteryCurrent.BatteryStatus == BatteryStatus.Charging)
                        {
                            txt_ActiveControllerBattery.Text = "Battery charging";
                        }
                        else if (Controller.BatteryCurrent.BatteryStatus == BatteryStatus.Unknown)
                        {
                            txt_ActiveControllerBattery.Text = "Battery unknown";
                        }
                        else
                        {
                            txt_ActiveControllerBattery.Text = "Battery is at " + Controller.BatteryCurrent.BatteryPercentage + "%";
                        }

                        //Update debug information
                        if (Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "ShowDebugInformation")))
                        {
                            textblock_LiveDebugInformation.Text       = GenerateControllerDebugInformation();
                            textblock_LiveDebugInformation.Visibility = Visibility.Visible;
                            btn_CopyDebugInformation.Visibility       = Visibility.Visible;
                        }
                        else
                        {
                            textblock_LiveDebugInformation.Visibility = Visibility.Collapsed;
                            btn_CopyDebugInformation.Visibility       = Visibility.Collapsed;
                        }

                        //D-Pad
                        if (Controller.InputCurrent.DPadLeft.PressedRaw)
                        {
                            img_ControllerPreview_DPadLeft.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_DPadLeft.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.DPadUp.PressedRaw)
                        {
                            img_ControllerPreview_DPadUp.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_DPadUp.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.DPadRight.PressedRaw)
                        {
                            img_ControllerPreview_DPadRight.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_DPadRight.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.DPadDown.PressedRaw)
                        {
                            img_ControllerPreview_DPadDown.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_DPadDown.Visibility = Visibility.Collapsed;
                        }

                        //Buttons
                        if (Controller.InputCurrent.ButtonA.PressedRaw)
                        {
                            img_ControllerPreview_ButtonA.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonA.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.ButtonB.PressedRaw)
                        {
                            img_ControllerPreview_ButtonB.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonB.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.ButtonX.PressedRaw)
                        {
                            img_ControllerPreview_ButtonX.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonX.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.ButtonY.PressedRaw)
                        {
                            img_ControllerPreview_ButtonY.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonY.Visibility = Visibility.Collapsed;
                        }

                        if (Controller.InputCurrent.ButtonBack.PressedRaw)
                        {
                            img_ControllerPreview_ButtonBack.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonBack.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.ButtonStart.PressedRaw)
                        {
                            img_ControllerPreview_ButtonStart.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonStart.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.ButtonGuide.PressedRaw)
                        {
                            img_ControllerPreview_ButtonGuide.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonGuide.Visibility = Visibility.Collapsed;
                        }

                        if (Controller.InputCurrent.ButtonTouchpad.PressedRaw)
                        {
                            img_ControllerPreview_ButtonTouchpad.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonTouchpad.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.ButtonMedia.PressedRaw)
                        {
                            img_ControllerPreview_ButtonMedia.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonMedia.Visibility = Visibility.Collapsed;
                        }

                        if (Controller.InputCurrent.ButtonShoulderLeft.PressedRaw)
                        {
                            img_ControllerPreview_ButtonShoulderLeft.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonShoulderLeft.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.ButtonShoulderRight.PressedRaw)
                        {
                            img_ControllerPreview_ButtonShoulderRight.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonShoulderRight.Visibility = Visibility.Collapsed;
                        }

                        if (Controller.InputCurrent.ButtonThumbLeft.PressedRaw)
                        {
                            img_ControllerPreview_ButtonThumbLeft.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonThumbLeft.Visibility = Visibility.Collapsed;
                        }
                        if (Controller.InputCurrent.ButtonThumbRight.PressedRaw)
                        {
                            img_ControllerPreview_ButtonThumbRight.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            img_ControllerPreview_ButtonThumbRight.Visibility = Visibility.Collapsed;
                        }

                        //Triggers
                        if (!Controller.Details.Profile.UseButtonTriggers)
                        {
                            img_ControllerPreview_TriggerLeft.Opacity  = (double)(Controller.InputCurrent.TriggerLeft * 257) / 65535;
                            img_ControllerPreview_TriggerRight.Opacity = (double)(Controller.InputCurrent.TriggerRight * 257) / 65535;
                        }
                        else
                        {
                            if (Controller.InputCurrent.ButtonTriggerLeft.PressedRaw)
                            {
                                img_ControllerPreview_TriggerLeft.Opacity = 1.00;
                            }
                            else
                            {
                                img_ControllerPreview_TriggerLeft.Opacity = 0.00;
                            }
                            if (Controller.InputCurrent.ButtonTriggerRight.PressedRaw)
                            {
                                img_ControllerPreview_TriggerRight.Opacity = 1.00;
                            }
                            else
                            {
                                img_ControllerPreview_TriggerRight.Opacity = 0.00;
                            }
                        }

                        //Thumb Left and Right Image
                        int LeftX  = Controller.InputCurrent.ThumbLeftX / 1000;
                        int LeftY  = -Controller.InputCurrent.ThumbLeftY / 1000;
                        int RightX = Controller.InputCurrent.ThumbRightX / 1000;
                        int RightY = -Controller.InputCurrent.ThumbRightY / 1000;
                        img_ControllerPreview_LeftAxe.Margin  = new Thickness(LeftX, LeftY, 0, 0);
                        img_ControllerPreview_RightAxe.Margin = new Thickness(RightX, RightY, 0, 0);

                        //Thumb Left and Right Percentage
                        int PercentageLeftYUp = (Controller.InputCurrent.ThumbLeftY * 257) / 65535;
                        if (PercentageLeftYUp < 0)
                        {
                            PercentageLeftYUp = 0;
                        }
                        int PercentageLeftYDown = (-Controller.InputCurrent.ThumbLeftY * 257) / 65535;
                        if (PercentageLeftYDown < 0)
                        {
                            PercentageLeftYDown = 0;
                        }
                        int PercentageLeftXLeft = (-Controller.InputCurrent.ThumbLeftX * 257) / 65535;
                        if (PercentageLeftXLeft < 0)
                        {
                            PercentageLeftXLeft = 0;
                        }
                        int PercentageLeftXRight = (Controller.InputCurrent.ThumbLeftX * 257) / 65535;
                        if (PercentageLeftXRight < 0)
                        {
                            PercentageLeftXRight = 0;
                        }
                        textblock_Thumb_Left_Y_Up.Text    = PercentageLeftYUp.ToString();
                        textblock_Thumb_Left_Y_Down.Text  = PercentageLeftYDown.ToString();
                        textblock_Thumb_Left_X_Left.Text  = PercentageLeftXLeft.ToString();
                        textblock_Thumb_Left_X_Right.Text = PercentageLeftXRight.ToString();
                        int PercentageRightYUp            = (Controller.InputCurrent.ThumbRightY * 257) / 65535;
                        if (PercentageRightYUp < 0)
                        {
                            PercentageRightYUp = 0;
                        }
                        int PercentageRightYDown = (-Controller.InputCurrent.ThumbRightY * 257) / 65535;
                        if (PercentageRightYDown < 0)
                        {
                            PercentageRightYDown = 0;
                        }
                        int PercentageRightXLeft = (-Controller.InputCurrent.ThumbRightX * 257) / 65535;
                        if (PercentageRightXLeft < 0)
                        {
                            PercentageRightXLeft = 0;
                        }
                        int PercentageRightXRight = (Controller.InputCurrent.ThumbRightX * 257) / 65535;
                        if (PercentageRightXRight < 0)
                        {
                            PercentageRightXRight = 0;
                        }
                        textblock_Thumb_Right_Y_Up.Text    = PercentageRightYUp.ToString();
                        textblock_Thumb_Right_Y_Down.Text  = PercentageRightYDown.ToString();
                        textblock_Thumb_Right_X_Left.Text  = PercentageRightXLeft.ToString();
                        textblock_Thumb_Right_X_Right.Text = PercentageRightXRight.ToString();
                    }
                    catch { }
                });
            }
            catch { }
        }
Exemple #19
0
        //Check controller for low battery level
        void ControllerLowBattery(ControllerStatus Controller)
        {
            try
            {
                //Debug.WriteLine("Checking if controller " + Controller.NumberId + " has a low battery level " + Controller.BatteryPercentageCurrent + "/" + Controller.BatteryPercentagePrevious);
                string controllerNumberDisplay = (Controller.NumberId + 1).ToString();

                //Check the controller id
                TextBlock  targetControllerTextblock  = null;
                StackPanel targetControllerStackpanel = null;
                if (Controller.NumberId == 0)
                {
                    targetControllerTextblock  = App.vWindowOverlay.textblock_Battery_Warning_Controller1;
                    targetControllerStackpanel = App.vWindowOverlay.stackpanel_Battery_Warning_Controller1;
                }
                else if (Controller.NumberId == 1)
                {
                    targetControllerTextblock  = App.vWindowOverlay.textblock_Battery_Warning_Controller2;
                    targetControllerStackpanel = App.vWindowOverlay.stackpanel_Battery_Warning_Controller2;
                }
                else if (Controller.NumberId == 2)
                {
                    targetControllerTextblock  = App.vWindowOverlay.textblock_Battery_Warning_Controller3;
                    targetControllerStackpanel = App.vWindowOverlay.stackpanel_Battery_Warning_Controller3;
                }
                else if (Controller.NumberId == 3)
                {
                    targetControllerTextblock  = App.vWindowOverlay.textblock_Battery_Warning_Controller4;
                    targetControllerStackpanel = App.vWindowOverlay.stackpanel_Battery_Warning_Controller4;
                }

                //Check if the controller is connected
                if (Controller == null || !Controller.Connected())
                {
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        targetControllerStackpanel.Visibility = Visibility.Collapsed;
                    });
                    return;
                }

                //Check the current battery level
                bool batteryShowIconLow       = Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "BatteryShowIconLow"));
                bool BatteryShowPercentageLow = Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "BatteryShowPercentageLow"));
                bool batteryLevelChanged      = Controller.BatteryCurrent.BatteryPercentage != Controller.BatteryPrevious.BatteryPercentage || Controller.BatteryCurrent.BatteryStatus != Controller.BatteryPrevious.BatteryStatus;
                bool batteryLevelLow          = Controller.BatteryCurrent.BatteryPercentage <= 20 && Controller.BatteryCurrent.BatteryStatus == BatteryStatus.Normal;

                //Update controller battery led
                if (batteryLevelChanged)
                {
                    Debug.WriteLine("Controller " + Controller.NumberId + " battery level changed, updating led.");
                    ControllerOutput(vController0, false, false);
                    ControllerOutput(vController1, false, false);
                    ControllerOutput(vController2, false, false);
                    ControllerOutput(vController3, false, false);
                }

                //Show or hide battery level overlay
                if (batteryLevelLow && batteryShowIconLow)
                {
                    //Debug.WriteLine("Controller " + Controller.NumberId + " has a low battery level, showing overlay.");
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        App.vWindowOverlay.UpdateBatteryPosition();
                        if (BatteryShowPercentageLow)
                        {
                            targetControllerTextblock.Text       = Controller.BatteryCurrent.BatteryPercentage + "%";
                            targetControllerTextblock.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            targetControllerTextblock.Visibility = Visibility.Collapsed;
                        }
                        targetControllerStackpanel.Visibility = Visibility.Visible;
                    });
                }
                else
                {
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        targetControllerStackpanel.Visibility = Visibility.Collapsed;
                    });
                }

                //Battery level sound and notification
                if (batteryLevelLow && batteryLevelChanged)
                {
                    Debug.WriteLine("Controller " + Controller.NumberId + " has a low battery level, showing notification.");
                    NotificationDetails notificationDetails = new NotificationDetails();
                    notificationDetails.Icon = "Battery/BatteryVerDis20";
                    notificationDetails.Text = "Controller (" + controllerNumberDisplay + ") battery " + Controller.BatteryCurrent.BatteryPercentage + "%";
                    App.vWindowOverlay.Notification_Show_Status(notificationDetails);

                    if (Convert.ToBoolean(Setting_Load(vConfigurationDirectXInput, "BatteryPlaySoundLow")))
                    {
                        PlayInterfaceSound(vConfigurationCtrlUI, "BatteryLow", true);
                    }
                }

                //Update the previous battery level
                CloneObjectShallow(Controller.BatteryCurrent, out Controller.BatteryPrevious);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed checking low battery level: " + ex.Message);
            }
        }
Exemple #20
0
        //Show the File Picker Popup
        async Task Popup_Show_FilePicker_Task(string targetPath, int targetIndex, bool storeIndex, FrameworkElement previousFocus)
        {
            try
            {
                //Check if the popup is already open
                if (!vFilePickerOpen)
                {
                    //Play the popup opening sound
                    PlayInterfaceSound(vConfigurationCtrlUI, "PopupOpen", false, false);

                    //Save the previous focus element
                    FrameworkElementFocusSave(vFilePickerElementFocus, previousFocus);
                }

                //Reset file picker variables
                vFilePickerCompleted = false;
                vFilePickerCancelled = false;
                vFilePickerResult    = null;
                vFilePickerOpen      = true;

                //Check file picker busy status
                while (vFilePickerLoadBusy)
                {
                    vFilePickerLoadCancel = true;
                    await Task.Delay(100);
                }
                vFilePickerLoadBusy = true;

                AVActions.ActionDispatcherInvoke(delegate
                {
                    //Show file picker loading animation
                    gif_FilePicker_Loading.Show();

                    //Set file picker header texts
                    grid_Popup_FilePicker_txt_Title.Text       = vFilePickerTitle;
                    grid_Popup_FilePicker_txt_Description.Text = vFilePickerDescription;

                    //Change the list picker item style
                    if (vFilePickerShowRoms)
                    {
                        lb_FilePicker.Style        = Application.Current.Resources["ListBoxWrapPanelVertical"] as Style;
                        lb_FilePicker.ItemTemplate = Application.Current.Resources["ListBoxItemRom"] as DataTemplate;
                        grid_Popup_Filepicker_Row1.HorizontalAlignment = HorizontalAlignment.Center;
                    }
                    else
                    {
                        lb_FilePicker.Style        = Application.Current.Resources["ListBoxVertical"] as Style;
                        lb_FilePicker.ItemTemplate = Application.Current.Resources["ListBoxItemFile"] as DataTemplate;
                        grid_Popup_Filepicker_Row1.HorizontalAlignment = HorizontalAlignment.Stretch;
                    }

                    //Update the navigation history index
                    if (storeIndex)
                    {
                        FilePicker_NavigationHistoryAddUpdate(vFilePickerCurrentPath, lb_FilePicker.SelectedIndex);
                    }

                    //Clear the current file picker list
                    List_FilePicker.Clear();
                });

                //Show the popup
                Popup_Show_Element(grid_Popup_FilePicker);

                //Update the current picker path
                vFilePickerSourcePath  = vFilePickerCurrentPath;
                vFilePickerCurrentPath = targetPath;

                //Check target type
                if (targetPath == "PC")
                {
                    //Get and list all the disk drives
                    await PickerLoadPC();
                }
                else if (targetPath == "UWP")
                {
                    //Get and list all uwp applications
                    await PickerLoadUwpApps();
                }
                else
                {
                    //Get and list all files and folders
                    await PickerLoadFilesFolders(targetPath, targetIndex);
                }

                //Update file picker loading status
                vFilePickerLoadCancel = false;
                vFilePickerLoadBusy   = false;

                //Hide file picker loading animation
                AVActions.ActionDispatcherInvoke(delegate
                {
                    gif_FilePicker_Loading.Hide();
                });

                //File Picker focus on item
                await FilePicker_Focus(targetIndex, targetPath);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed loading filepicker: " + ex.Message);
                await Notification_Send_Status("Close", "Picker loading failed");
                await FilePicker_GoFolderUp();
            }
        }
Exemple #21
0
        //Connect with the controller
        async Task ControllerConnect(ControllerDetails ConnectedController)
        {
            try
            {
                //Check if the controller is already in use
                bool ControllerInuse = false;
                if (vController0.Connected() && vController0.Details.Path == ConnectedController.Path)
                {
                    ControllerInuse = true;
                }
                if (vController1.Connected() && vController1.Details.Path == ConnectedController.Path)
                {
                    ControllerInuse = true;
                }
                if (vController2.Connected() && vController2.Details.Path == ConnectedController.Path)
                {
                    ControllerInuse = true;
                }
                if (vController3.Connected() && vController3.Details.Path == ConnectedController.Path)
                {
                    ControllerInuse = true;
                }
                if (ControllerInuse)
                {
                    return;
                }

                Debug.WriteLine("Found a connected " + ConnectedController.Type + " controller to use: " + ConnectedController.DisplayName);

                //Connect the controller to available slot
                if (!vController0.Connected())
                {
                    vController0.Details = ConnectedController;
                    bool controllerStarted = await StartControllerDirectInput(vController0);

                    if (controllerStarted)
                    {
                        AVActions.ActionDispatcherInvoke(delegate
                        {
                            image_Controller0.Source           = vImagePreloadIconControllerAccent;
                            textblock_Controller0.Text         = vController0.Details.DisplayName;
                            textblock_Controller0CodeName.Text = vController0.SupportedCurrent.CodeName;
                        });
                    }
                }
                else if (!vController1.Connected())
                {
                    vController1.Details = ConnectedController;
                    bool controllerStarted = await StartControllerDirectInput(vController1);

                    if (controllerStarted)
                    {
                        AVActions.ActionDispatcherInvoke(delegate
                        {
                            image_Controller1.Source           = vImagePreloadIconControllerAccent;
                            textblock_Controller1.Text         = vController1.Details.DisplayName;
                            textblock_Controller1CodeName.Text = vController1.SupportedCurrent.CodeName;
                        });
                    }
                }
                else if (!vController2.Connected())
                {
                    vController2.Details = ConnectedController;
                    bool controllerStarted = await StartControllerDirectInput(vController2);

                    if (controllerStarted)
                    {
                        AVActions.ActionDispatcherInvoke(delegate
                        {
                            image_Controller2.Source           = vImagePreloadIconControllerAccent;
                            textblock_Controller2.Text         = vController2.Details.DisplayName;
                            textblock_Controller2CodeName.Text = vController2.SupportedCurrent.CodeName;
                        });
                    }
                }
                else if (!vController3.Connected())
                {
                    vController3.Details = ConnectedController;
                    bool controllerStarted = await StartControllerDirectInput(vController3);

                    if (controllerStarted)
                    {
                        AVActions.ActionDispatcherInvoke(delegate
                        {
                            image_Controller3.Source           = vImagePreloadIconControllerAccent;
                            textblock_Controller3.Text         = vController3.Details.DisplayName;
                            textblock_Controller3CodeName.Text = vController3.SupportedCurrent.CodeName;
                        });
                    }
                }
            }
            catch { }
        }
Exemple #22
0
        //Switch the emoji type list by trigger
        async Task SwitchEmojiTypeListTrigger(bool previous)
        {
            try
            {
                int selectIndex = 0;
                AVActions.ActionDispatcherInvoke(delegate
                {
                    //Update the emoji selected index
                    UpdateSelectedIndexEmoji();

                    //Background brush variable
                    SolidColorBrush selectedBrush = (SolidColorBrush)Application.Current.Resources["ApplicationAccentDarkBrush"];
                    SolidColorBrush defaultBrush  = (SolidColorBrush)Application.Current.Resources["ApplicationAccentLightBrush"];

                    //Reset background brush
                    key_EmojiSmiley.Background    = defaultBrush;
                    key_EmojiSmiley.BorderBrush   = defaultBrush;
                    key_EmojiActivity.Background  = defaultBrush;
                    key_EmojiActivity.BorderBrush = defaultBrush;
                    key_EmojiFood.Background      = defaultBrush;
                    key_EmojiFood.BorderBrush     = defaultBrush;
                    key_EmojiNature.Background    = defaultBrush;
                    key_EmojiNature.BorderBrush   = defaultBrush;
                    key_EmojiOther.Background     = defaultBrush;
                    key_EmojiOther.BorderBrush    = defaultBrush;
                    key_EmojiPeople.Background    = defaultBrush;
                    key_EmojiPeople.BorderBrush   = defaultBrush;
                    key_EmojiSymbol.Background    = defaultBrush;
                    key_EmojiSymbol.BorderBrush   = defaultBrush;
                    key_EmojiTravel.Background    = defaultBrush;
                    key_EmojiTravel.BorderBrush   = defaultBrush;

                    //Switch the emoji list
                    if (!previous)
                    {
                        if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListSmiley)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListActivity;
                            key_EmojiActivity.Background  = selectedBrush;
                            key_EmojiActivity.BorderBrush = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexActivity;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListActivity)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListFood;
                            key_EmojiFood.Background      = selectedBrush;
                            key_EmojiFood.BorderBrush     = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexFood;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListFood)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListNature;
                            key_EmojiNature.Background    = selectedBrush;
                            key_EmojiNature.BorderBrush   = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexNature;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListNature)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListOther;
                            key_EmojiOther.Background     = selectedBrush;
                            key_EmojiOther.BorderBrush    = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexOther;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListOther)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListPeople;
                            key_EmojiPeople.Background    = selectedBrush;
                            key_EmojiPeople.BorderBrush   = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexPeople;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListPeople)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListSymbol;
                            key_EmojiSymbol.Background    = selectedBrush;
                            key_EmojiSymbol.BorderBrush   = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexSymbol;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListSymbol)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListTravel;
                            key_EmojiTravel.Background    = selectedBrush;
                            key_EmojiTravel.BorderBrush   = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexTravel;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListTravel)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListSmiley;
                            key_EmojiSmiley.Background    = selectedBrush;
                            key_EmojiSmiley.BorderBrush   = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexSmiley;
                        }
                    }
                    else
                    {
                        if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListSmiley)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListTravel;
                            key_EmojiTravel.Background    = selectedBrush;
                            key_EmojiTravel.BorderBrush   = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexTravel;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListTravel)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListSymbol;
                            key_EmojiSymbol.Background    = selectedBrush;
                            key_EmojiSymbol.BorderBrush   = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexSymbol;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListSymbol)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListPeople;
                            key_EmojiPeople.Background    = selectedBrush;
                            key_EmojiPeople.BorderBrush   = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexPeople;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListPeople)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListOther;
                            key_EmojiOther.Background     = selectedBrush;
                            key_EmojiOther.BorderBrush    = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexOther;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListOther)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListNature;
                            key_EmojiNature.Background    = selectedBrush;
                            key_EmojiNature.BorderBrush   = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexNature;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListNature)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListFood;
                            key_EmojiFood.Background      = selectedBrush;
                            key_EmojiFood.BorderBrush     = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexFood;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListFood)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListActivity;
                            key_EmojiActivity.Background  = selectedBrush;
                            key_EmojiActivity.BorderBrush = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexActivity;
                        }
                        else if (listbox_EmojiList.ItemsSource == vDirectKeyboardEmojiListActivity)
                        {
                            listbox_EmojiList.ItemsSource = vDirectKeyboardEmojiListSmiley;
                            key_EmojiSmiley.Background    = selectedBrush;
                            key_EmojiSmiley.BorderBrush   = selectedBrush;
                            selectIndex = vDirectKeyboardEmojiIndexSmiley;
                        }
                    }
                });

                //Focus on the first emoji
                FrameworkElementFocus focusListbox = new FrameworkElementFocus();
                focusListbox.FocusListBox = listbox_EmojiList;
                focusListbox.FocusIndex   = selectIndex;
                await FrameworkElementFocusFocus(focusListbox, vProcessCurrent.MainWindowHandle);
            }
            catch { }
        }
Exemple #23
0
        //Check the applications running status
        void CheckAppRunningStatus(Process[] processesList)
        {
            try
            {
                //Check if processes list is provided
                if (processesList == null)
                {
                    processesList = Process.GetProcesses();
                }

                //Update main menu launchers status
                bool runningSteam        = processesList.Any(x => x.ProcessName.ToLower() == "steam");
                bool runningEADesktop    = processesList.Any(x => x.ProcessName.ToLower() == "eadesktop" || x.ProcessName.ToLower() == "origin");
                bool runningGog          = processesList.Any(x => x.ProcessName.ToLower() == "galaxyclient");
                bool runningUbisoft      = processesList.Any(x => x.ProcessName.ToLower() == "ubisoftconnect" || x.ProcessName.ToLower() == "upc");
                bool runningBethesda     = processesList.Any(x => x.ProcessName.ToLower() == "bethesdanetlauncher");
                bool runningEpic         = processesList.Any(x => x.ProcessName.ToLower() == "epicgameslauncher");
                bool runningBlizzard     = processesList.Any(x => x.ProcessName.ToLower() == "battle.net");
                bool runningRockstar     = processesList.Any(x => x.ProcessName.ToLower() == "rockstarservice");
                bool runningDiscord      = processesList.Any(x => x.ProcessName.ToLower() == "discord");
                bool runningDirectXInput = processesList.Any(x => x.ProcessName.ToLower() == "directxinput");
                bool runningFpsOverlayer = processesList.Any(x => x.ProcessName.ToLower() == "fpsoverlayer");

                AVActions.ActionDispatcherInvoke(delegate
                {
                    if (runningSteam)
                    {
                        img_Menu_SteamStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_SteamStatus.Opacity = 0.40;
                    }

                    if (runningEADesktop)
                    {
                        img_Menu_EADesktopStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_EADesktopStatus.Opacity = 0.40;
                    }

                    if (runningGog)
                    {
                        img_Menu_GoGStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_GoGStatus.Opacity = 0.40;
                    }

                    if (runningUbisoft)
                    {
                        img_Menu_UbisoftStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_UbisoftStatus.Opacity = 0.40;
                    }

                    if (runningBethesda)
                    {
                        img_Menu_BethesdaStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_BethesdaStatus.Opacity = 0.40;
                    }

                    if (runningEpic)
                    {
                        img_Menu_EpicStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_EpicStatus.Opacity = 0.40;
                    }

                    if (runningBlizzard)
                    {
                        img_Menu_BattleNetStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_BattleNetStatus.Opacity = 0.40;
                    }

                    if (runningRockstar)
                    {
                        img_Menu_RockstarStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_RockstarStatus.Opacity = 0.40;
                    }

                    if (runningDiscord)
                    {
                        img_Menu_DiscordStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_DiscordStatus.Opacity = 0.40;
                    }

                    if (runningDirectXInput)
                    {
                        img_Menu_DirectXInputStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_DirectXInputStatus.Opacity = 0.40;
                    }

                    if (runningFpsOverlayer)
                    {
                        img_Menu_FpsOverlayerStatus.Opacity = 1.00;
                    }
                    else
                    {
                        img_Menu_FpsOverlayerStatus.Opacity = 0.40;
                    }
                });
            }
            catch { }
        }
Exemple #24
0
        //Switch capslock on and off
        public void SwitchCapsLock()
        {
            try
            {
                PlayInterfaceSound(vConfigurationCtrlUI, "Click", false, false);
                Debug.WriteLine("Switching caps lock.");

                //Disable hardware capslock
                DisableHardwareCapsLock();

                //Enable hardware numlock
                EnableHardwareNumLock();

                //Enable or disable software capslock
                if (vCapsEnabled)
                {
                    vCapsEnabled = false;
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        textblock_ButtonLeft.Text = "Backspace";

                        key_Delete.Content = "Delete";
                        key_Delete.Tag     = KeyboardKeys.Delete;

                        key_End.Content = "End";
                        key_End.Tag     = KeyboardKeys.End;

                        key_Tilde_Normal.Text = "`";
                        key_Tilde_Caps.Text   = "~";

                        key_1_Normal.Text = "1";
                        key_1_Caps.Text   = "!";

                        key_2_Normal.Text = "2";
                        key_2_Caps.Text   = "@";

                        key_3_Normal.Text = "3";
                        key_3_Caps.Text   = "#";

                        key_4_Normal.Text = "4";
                        key_4_Caps.Text   = "$";

                        key_5_Normal.Text = "5";
                        key_5_Caps.Text   = "%";

                        key_6_Normal.Text = "6";
                        key_6_Caps.Text   = "^";

                        key_7_Normal.Text = "7";
                        key_7_Caps.Text   = "&";

                        key_8_Normal.Text = "8";
                        key_8_Caps.Text   = "*";

                        key_9_Normal.Text = "9";
                        key_9_Caps.Text   = "(";

                        key_0_Normal.Text = "0";
                        key_0_Caps.Text   = ")";

                        key_Minus_Normal.Text = "-";
                        key_Minus_Caps.Text   = "_";

                        key_Plus_Normal.Text = "=";
                        key_Plus_Caps.Text   = "+";

                        key_Tab.Content = "Tab>";
                        key_q.Content   = key_q.Content.ToString().ToLower();
                        key_w.Content   = key_w.Content.ToString().ToLower();
                        key_e.Content   = key_e.Content.ToString().ToLower();
                        key_r.Content   = key_r.Content.ToString().ToLower();
                        key_t.Content   = key_t.Content.ToString().ToLower();
                        key_y.Content   = key_y.Content.ToString().ToLower();
                        key_u.Content   = key_u.Content.ToString().ToLower();
                        key_i.Content   = key_i.Content.ToString().ToLower();
                        key_o.Content   = key_o.Content.ToString().ToLower();
                        key_p.Content   = key_p.Content.ToString().ToLower();

                        key_OpenBracket_Normal.Text = "[";
                        key_OpenBracket_Caps.Text   = "{";

                        key_CloseBracket_Normal.Text = "]";
                        key_CloseBracket_Caps.Text   = "}";

                        key_CapsLock.Content = "Caps";
                        key_a.Content        = key_a.Content.ToString().ToLower();
                        key_s.Content        = key_s.Content.ToString().ToLower();
                        key_d.Content        = key_d.Content.ToString().ToLower();
                        key_f.Content        = key_f.Content.ToString().ToLower();
                        key_g.Content        = key_g.Content.ToString().ToLower();
                        key_h.Content        = key_h.Content.ToString().ToLower();
                        key_j.Content        = key_j.Content.ToString().ToLower();
                        key_k.Content        = key_k.Content.ToString().ToLower();
                        key_l.Content        = key_l.Content.ToString().ToLower();

                        key_Semicolon_Normal.Text = ";";
                        key_Semicolon_Caps.Text   = ":";

                        key_Quote_Normal.Text = "'";
                        key_Quote_Caps.Text   = "\"";

                        key_Pipe_Normal.Text = "\\";
                        key_Pipe_Caps.Text   = "|";

                        key_z.Content = key_z.Content.ToString().ToLower();
                        key_x.Content = key_x.Content.ToString().ToLower();
                        key_c.Content = key_c.Content.ToString().ToLower();
                        key_v.Content = key_v.Content.ToString().ToLower();
                        key_b.Content = key_b.Content.ToString().ToLower();
                        key_n.Content = key_n.Content.ToString().ToLower();
                        key_m.Content = key_m.Content.ToString().ToLower();

                        key_Comma_Normal.Text = ",";
                        key_Comma_Caps.Text   = "<";

                        key_Period_Normal.Text = ".";
                        key_Period_Caps.Text   = ">";

                        key_Question_Normal.Text = "/";
                        key_Question_Caps.Text   = "?";

                        key_Shift.Content       = "Shift";
                        key_Control.Content     = "Ctrl";
                        key_Alt.Content         = "Alt";
                        key_LeftWindows.Content = "Windows";
                        key_Enter.Content       = "Enter";

                        key_Escape.Content = "Escape";
                        key_Escape.Tag     = KeyboardKeys.Escape;
                    });
                }
                else
                {
                    vCapsEnabled = true;
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        textblock_ButtonLeft.Text = "Delete";

                        key_Delete.Content = "Insert";
                        key_Delete.Tag     = KeyboardKeys.Insert;

                        key_End.Content = "Home";
                        key_End.Tag     = KeyboardKeys.Home;

                        key_Tilde_Normal.Text = "~";
                        key_Tilde_Caps.Text   = "`";

                        key_1_Normal.Text = "!";
                        key_1_Caps.Text   = "1";

                        key_2_Normal.Text = "@";
                        key_2_Caps.Text   = "2";

                        key_3_Normal.Text = "#";
                        key_3_Caps.Text   = "3";

                        key_4_Normal.Text = "$";
                        key_4_Caps.Text   = "4";

                        key_5_Normal.Text = "%";
                        key_5_Caps.Text   = "5";

                        key_6_Normal.Text = "^";
                        key_6_Caps.Text   = "6";

                        key_7_Normal.Text = "&";
                        key_7_Caps.Text   = "7";

                        key_8_Normal.Text = "*";
                        key_8_Caps.Text   = "8";

                        key_9_Normal.Text = "(";
                        key_9_Caps.Text   = "9";

                        key_0_Normal.Text = ")";
                        key_0_Caps.Text   = "0";

                        key_Minus_Normal.Text = "_";
                        key_Minus_Caps.Text   = "-";

                        key_Plus_Normal.Text = "+";
                        key_Plus_Caps.Text   = "=";

                        key_Tab.Content = "<Tab";
                        key_q.Content   = key_q.Content.ToString().ToUpper();
                        key_w.Content   = key_w.Content.ToString().ToUpper();
                        key_e.Content   = key_e.Content.ToString().ToUpper();
                        key_r.Content   = key_r.Content.ToString().ToUpper();
                        key_t.Content   = key_t.Content.ToString().ToUpper();
                        key_y.Content   = key_y.Content.ToString().ToUpper();
                        key_u.Content   = key_u.Content.ToString().ToUpper();
                        key_i.Content   = key_i.Content.ToString().ToUpper();
                        key_o.Content   = key_o.Content.ToString().ToUpper();
                        key_p.Content   = key_p.Content.ToString().ToUpper();

                        key_OpenBracket_Normal.Text = "{";
                        key_OpenBracket_Caps.Text   = "[";

                        key_CloseBracket_Normal.Text = "}";
                        key_CloseBracket_Caps.Text   = "]";

                        key_CapsLock.Content = "CAPS";
                        key_a.Content        = key_a.Content.ToString().ToUpper();
                        key_s.Content        = key_s.Content.ToString().ToUpper();
                        key_d.Content        = key_d.Content.ToString().ToUpper();
                        key_f.Content        = key_f.Content.ToString().ToUpper();
                        key_g.Content        = key_g.Content.ToString().ToUpper();
                        key_h.Content        = key_h.Content.ToString().ToUpper();
                        key_j.Content        = key_j.Content.ToString().ToUpper();
                        key_k.Content        = key_k.Content.ToString().ToUpper();
                        key_l.Content        = key_l.Content.ToString().ToUpper();

                        key_Semicolon_Normal.Text = ":";
                        key_Semicolon_Caps.Text   = ";";

                        key_Quote_Normal.Text = "\"";
                        key_Quote_Caps.Text   = "'";

                        key_Pipe_Normal.Text = "|";
                        key_Pipe_Caps.Text   = "\\";

                        key_z.Content = key_z.Content.ToString().ToUpper();
                        key_x.Content = key_x.Content.ToString().ToUpper();
                        key_c.Content = key_c.Content.ToString().ToUpper();
                        key_v.Content = key_v.Content.ToString().ToUpper();
                        key_b.Content = key_b.Content.ToString().ToUpper();
                        key_n.Content = key_n.Content.ToString().ToUpper();
                        key_m.Content = key_m.Content.ToString().ToUpper();

                        key_Comma_Normal.Text = "<";
                        key_Comma_Caps.Text   = ",";

                        key_Period_Normal.Text = ">";
                        key_Period_Caps.Text   = ".";

                        key_Question_Normal.Text = "?";
                        key_Question_Caps.Text   = "/";

                        key_Shift.Content       = "Cut";
                        key_Control.Content     = "Copy";
                        key_Alt.Content         = "Paste";
                        key_LeftWindows.Content = "Select all";
                        key_Enter.Content       = "Undo";

                        key_Escape.Content = "Menu";
                        key_Escape.Tag     = KeyboardKeys.Menu;
                    });
                }
            }
            catch { }
        }
Exemple #25
0
        //Update keypad preview
        public void ControllerInteractionKeypadPreview(ControllerInput controllerInput)
        {
            try
            {
                if (GetSystemTicksMs() >= vControllerDelay_KeypadPreview)
                {
                    AVActions.ActionDispatcherInvoke(delegate
                    {
                        try
                        {
                            //DPad
                            if (controllerInput.DPadLeft.PressedRaw)
                            {
                                textblock_DPadLeft.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_DPadLeft.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.DPadUp.PressedRaw)
                            {
                                textblock_DPadUp.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_DPadUp.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.DPadRight.PressedRaw)
                            {
                                textblock_DPadRight.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_DPadRight.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.DPadDown.PressedRaw)
                            {
                                textblock_DPadDown.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_DPadDown.Foreground = vKeypadNormalBrush;
                            }

                            //Thumb Left
                            if (controllerInput.ThumbLeftX < -vControllerThumbOffset7500)
                            {
                                textblock_ThumbLeftLeft.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ThumbLeftLeft.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ThumbLeftY > vControllerThumbOffset7500)
                            {
                                textblock_ThumbLeftUp.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ThumbLeftUp.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ThumbLeftX > vControllerThumbOffset7500)
                            {
                                textblock_ThumbLeftRight.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ThumbLeftRight.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ThumbLeftY < -vControllerThumbOffset7500)
                            {
                                textblock_ThumbLeftDown.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ThumbLeftDown.Foreground = vKeypadNormalBrush;
                            }

                            //Thumb Right
                            if (controllerInput.ThumbRightX < -vControllerThumbOffset7500)
                            {
                                textblock_ThumbRightLeft.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ThumbRightLeft.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ThumbRightY > vControllerThumbOffset7500)
                            {
                                textblock_ThumbRightUp.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ThumbRightUp.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ThumbRightX > vControllerThumbOffset7500)
                            {
                                textblock_ThumbRightRight.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ThumbRightRight.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ThumbRightY < -vControllerThumbOffset7500)
                            {
                                textblock_ThumbRightDown.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ThumbRightDown.Foreground = vKeypadNormalBrush;
                            }

                            //Buttons
                            if (controllerInput.ButtonA.PressedRaw)
                            {
                                textblock_ButtonA.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ButtonA.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ButtonB.PressedRaw)
                            {
                                textblock_ButtonB.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ButtonB.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ButtonX.PressedRaw)
                            {
                                textblock_ButtonX.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ButtonX.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ButtonY.PressedRaw)
                            {
                                textblock_ButtonY.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ButtonY.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ButtonBack.PressedRaw)
                            {
                                textblock_ButtonBack.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ButtonBack.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ButtonStart.PressedRaw)
                            {
                                textblock_ButtonStart.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ButtonStart.Foreground = vKeypadNormalBrush;
                            }

                            //Shoulder
                            if (controllerInput.ButtonShoulderLeft.PressedRaw)
                            {
                                textblock_ButtonShoulderLeft.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ButtonShoulderLeft.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ButtonShoulderRight.PressedRaw)
                            {
                                textblock_ButtonShoulderRight.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ButtonShoulderRight.Foreground = vKeypadNormalBrush;
                            }

                            //Trigger
                            if (controllerInput.ButtonTriggerLeft.PressedRaw)
                            {
                                textblock_ButtonTriggerLeft.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ButtonTriggerLeft.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ButtonTriggerRight.PressedRaw)
                            {
                                textblock_ButtonTriggerRight.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ButtonTriggerRight.Foreground = vKeypadNormalBrush;
                            }

                            //Thumb
                            if (controllerInput.ButtonThumbLeft.PressedRaw)
                            {
                                textblock_ThumbLeftButton.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ThumbLeftButton.Foreground = vKeypadNormalBrush;
                            }
                            if (controllerInput.ButtonThumbRight.PressedRaw)
                            {
                                textblock_ThumbRightButton.Foreground = vApplicationAccentLightBrush;
                            }
                            else
                            {
                                textblock_ThumbRightButton.Foreground = vKeypadNormalBrush;
                            }
                        }
                        catch { }
                    });

                    vControllerDelay_KeypadPreview = GetSystemTicksMs() + vControllerDelayTicks125;
                }
            }
            catch { }
        }
Exemple #26
0
        //Update the currently playing media
        async Task UpdateCurrentMediaInformation()
        {
            try
            {
                //Check if volume is currently muted
                bool currentOutputVolumeMuted = AudioMuteGetStatus(false);
                bool currentInputVolumeMuted  = AudioMuteGetStatus(true);
                await AVActions.ActionDispatcherInvokeAsync(delegate
                {
                    img_Main_VolumeMute.Visibility     = currentOutputVolumeMuted ? Visibility.Visible : Visibility.Collapsed;
                    img_Main_MicrophoneMute.Visibility = currentInputVolumeMuted ? Visibility.Visible : Visibility.Collapsed;
                });

                //Check if the application window is activated
                if (!vAppActivated)
                {
                    //Debug.WriteLine("Not updating media information, not activated.");
                    return;
                }

                //Check if the media popup is opened or setting is enabled
                bool mediaUpdateSetting = Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowMediaMain"));

                await AVActions.ActionDispatcherInvokeAsync(delegate
                {
                    if (!mediaUpdateSetting)
                    {
                        main_Media_Information.Visibility = Visibility.Collapsed;
                        //Debug.WriteLine("Not updating media information, disabled.");
                        return;
                    }
                    else
                    {
                        //Update the media information margin
                        double widthTopButtons        = stackpanel_TopButtons.ActualWidth + 10;
                        double widthClockBattery      = grid_ClockBattery.ActualWidth + grid_ClockBattery.Margin.Right + 10;
                        main_Media_Information.Margin = new Thickness(widthTopButtons, 10, widthClockBattery, 0);
                    }
                });

                //Get the media session manager
                GlobalSystemMediaTransportControlsSessionManager smtcSessionManager = await GlobalSystemMediaTransportControlsSessionManager.RequestAsync();

                if (smtcSessionManager == null)
                {
                    HideMediaInformation();
                    return;
                }

                //Get the current media session
                GlobalSystemMediaTransportControlsSession smtcSession = smtcSessionManager.GetCurrentSession();
                if (smtcSession == null)
                {
                    HideMediaInformation();
                    return;
                }

                GlobalSystemMediaTransportControlsSessionMediaProperties mediaProperties = await smtcSession.TryGetMediaPropertiesAsync();

                GlobalSystemMediaTransportControlsSessionPlaybackInfo mediaPlayInfo = smtcSession.GetPlaybackInfo();
                //Debug.WriteLine("Media: " + mediaProperties.Title + "/" + mediaProperties.Artist + "/" + mediaProperties.AlbumTitle + "/" + mediaProperties.Subtitle + "/" + mediaProperties.PlaybackType + "/" + mediaProperties.TrackNumber + "/" + mediaProperties.AlbumTrackCount);
                //Debug.WriteLine("Play: " + mediaPlayInfo.PlaybackStatus + "/" + mediaPlayInfo.PlaybackType);

                //Load the media artist
                string mediaArtist = mediaProperties.Artist;
                if (string.IsNullOrWhiteSpace(mediaArtist))
                {
                    mediaArtist = mediaProperties.Subtitle;
                    if (string.IsNullOrWhiteSpace(mediaArtist))
                    {
                        mediaArtist = "Unknown artist";
                    }
                }

                //Load the media title
                string mediaTitle = mediaProperties.Title;
                if (string.IsNullOrWhiteSpace(mediaTitle))
                {
                    mediaTitle = "Unknown title";
                }

                //Update the media and volume information
                AVActions.ActionDispatcherInvoke(delegate
                {
                    main_Media_Information_Artist.Text = mediaArtist;
                    main_Media_Information_Title.Text  = " " + mediaTitle;
                    main_Media_Information.Visibility  = Visibility.Visible;

                    if (mediaPlayInfo.PlaybackStatus == GlobalSystemMediaTransportControlsSessionPlaybackStatus.Playing)
                    {
                        main_Media_Information_Artist.Opacity = 1;
                        main_Media_Information_Title.Opacity  = 1;
                    }
                    else
                    {
                        main_Media_Information_Artist.Opacity = 0.40;
                        main_Media_Information_Title.Opacity  = 0.40;
                    }
                });
            }
            catch
            {
                //Debug.WriteLine("Failed updating playing media.");
                HideMediaInformation();
            }
        }
Exemple #27
0
        //Get all the shortcuts and update the list
        async Task RefreshListShortcuts(bool showStatus)
        {
            try
            {
                //Check if shortcuts need to be updated
                if (!Convert.ToBoolean(Setting_Load(vConfigurationCtrlUI, "ShowOtherShortcuts")))
                {
                    //Debug.WriteLine("Shortcuts don't need to be updated, cancelling.");
                    return;
                }

                //Check if already refreshing
                if (vBusyRefreshingShortcuts)
                {
                    Debug.WriteLine("Shortcuts are already refreshing, cancelling.");
                    return;
                }

                //Update the refreshing status
                vBusyRefreshingShortcuts = true;

                //Show the loading gif
                AVActions.ActionDispatcherInvoke(delegate
                {
                    gif_Shortcuts_Loading.Show();
                });

                //Show refresh status message
                if (showStatus)
                {
                    await Notification_Send_Status("Refresh", "Refreshing shortcuts");
                }

                //Get all files from the shortcut directories
                IEnumerable <FileInfo> directoryShortcuts = Enumerable.Empty <FileInfo>();
                foreach (ProfileShared shortcutFolder in vCtrlLocationsShortcut)
                {
                    try
                    {
                        string editedShortcutFolder = shortcutFolder.String1;
                        editedShortcutFolder = editedShortcutFolder.Replace("%DESKTOPUSER%", Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
                        editedShortcutFolder = editedShortcutFolder.Replace("%DESKTOPPUBLIC%", Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory));
                        if (Directory.Exists(editedShortcutFolder))
                        {
                            DirectoryInfo          directoryInfo   = new DirectoryInfo(editedShortcutFolder);
                            IEnumerable <FileInfo> filterShortcuts = directoryInfo.GetFiles("*", SearchOption.TopDirectoryOnly).Where(x => x.Name.ToLower().EndsWith(".url") || x.Name.ToLower().EndsWith(".lnk"));
                            directoryShortcuts = directoryShortcuts.Concat(filterShortcuts);
                        }
                    }
                    catch { }
                }

                //Sort and filter the list by shortcut name
                directoryShortcuts = directoryShortcuts.OrderBy(x => x.Name);

                //Remove shortcuts that are no longer available from the list
                Func <DataBindApp, bool> filterShortcutApp = x => x.Category == AppCategory.Shortcut && !directoryShortcuts.Any(y => StripShortcutFilename(y.Name) == x.Name);
                await ListBoxRemoveAll(lb_Shortcuts, List_Shortcuts, filterShortcutApp);
                await ListBoxRemoveAll(lb_Search, List_Search, filterShortcutApp);

                //Get shortcut information and add it to the list
                foreach (FileInfo file in directoryShortcuts)
                {
                    try
                    {
                        //Read shortcut file information
                        ShortcutDetails shortcutDetails     = ReadShortcutFile(file.FullName);
                        string          targetTitleLower    = shortcutDetails.Title.ToLower();
                        string          targetPathLower     = shortcutDetails.TargetPath.ToLower();
                        string          targetArgumentLower = shortcutDetails.Argument.ToLower();

                        //Check if already in combined list and remove it
                        if (CombineAppLists(false, false, true).Any(x => x.Name.ToLower() == targetTitleLower || x.PathExe.ToLower() == targetPathLower))
                        {
                            //Debug.WriteLine("Shortcut is in the combined list skipping: " + fileNameStripped.ToLower());
                            await ListBoxRemoveAll(lb_Shortcuts, List_Shortcuts, x => x.PathExe.ToLower() == targetPathLower);

                            continue;
                        }

                        //Check if shortcut name is in shortcut blacklist
                        if (vCtrlIgnoreShortcutName.Any(x => x.String1.ToLower() == targetTitleLower))
                        {
                            //Debug.WriteLine("Shortcut is on the blacklist skipping: " + fileNameStripped.ToLower());
                            await ListBoxRemoveAll(lb_Shortcuts, List_Shortcuts, x => x.PathExe.ToLower() == targetPathLower);

                            continue;
                        }

                        //Check if shortcut uri is in shortcut uri blacklist
                        if (vCtrlIgnoreShortcutUri.Any(x => targetPathLower.Contains(x.String1.ToLower())))
                        {
                            //Debug.WriteLine("Shortcut uri is on the uri blacklist skipping: " + targetPathLower);
                            await ListBoxRemoveAll(lb_Shortcuts, List_Shortcuts, x => x.PathExe.ToLower() == targetPathLower);

                            continue;
                        }

                        //Check if shortcut is already in the shortcut list
                        DataBindApp shortcutExistCheck = List_Shortcuts.Where(x => x.PathExe.ToLower() == targetPathLower && x.Argument.ToLower() == targetArgumentLower).FirstOrDefault();
                        if (shortcutExistCheck != null)
                        {
                            //Debug.WriteLine("Shortcut is already in list, updating: " + targetPathLower);
                            shortcutExistCheck.Name         = shortcutDetails.Title;
                            shortcutExistCheck.ShortcutPath = shortcutDetails.ShortcutPath;
                            continue;
                        }

                        //Add shortcut to the shortcuts list
                        await ShortcutAddToListWithDetails(shortcutDetails);
                    }
                    catch { }
                }

                //Hide the loading gif
                AVActions.ActionDispatcherInvoke(delegate
                {
                    gif_Shortcuts_Loading.Hide();
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("Failed loading shortcuts: " + ex.Message);
            }
            //Update the refreshing status
            vBusyRefreshingShortcuts = false;
        }
Exemple #28
0
        //Process active XInput controller buttons
        async Task <bool> Controller_ButtonPress(ControllerInput ControllerInput)
        {
            bool ControllerUsed        = false;
            bool ControllerDelayShort  = false;
            bool ControllerDelayMedium = false;
            bool ControllerDelayLonger = false;

            try
            {
                if (GetSystemTicksMs() >= vControllerDelay_Button)
                {
                    if (ControllerInput.ButtonA.PressedRaw)
                    {
                        Debug.WriteLine("Button: APressed");

                        await AVActions.ActionDispatcherInvokeAsync(async delegate
                        {
                            FrameworkElement frameworkElement = (FrameworkElement)Keyboard.FocusedElement;
                            if (frameworkElement != null && frameworkElement.GetType() == typeof(TextBox))
                            {
                                //Launch the keyboard controller
                                if (vAppActivated && vControllerAnyConnected())
                                {
                                    await KeyboardControllerHideShow(true);
                                }
                            }
                            else
                            {
                                //Press on the space bar
                                await KeySendSingle(KeysVirtual.Space, vProcessCurrent.MainWindowHandle);
                            }
                        });

                        ControllerUsed        = true;
                        ControllerDelayMedium = true;
                    }
                    else if (ControllerInput.ButtonB.PressedRaw)
                    {
                        Debug.WriteLine("Button: BPressed");

                        if (Popup_Any_Open())
                        {
                            await KeySendSingle(KeysVirtual.Escape, vProcessCurrent.MainWindowHandle);
                        }
                        else
                        {
                            await SortAppListsSwitch(false);
                        }

                        ControllerUsed        = true;
                        ControllerDelayMedium = true;
                    }
                    else if (ControllerInput.ButtonY.PressedRaw)
                    {
                        Debug.WriteLine("Button: YPressed");

                        if (vTextInputOpen)
                        {
                            Debug.WriteLine("Resetting the text input popup.");
                            await AVActions.ActionDispatcherInvokeAsync(async delegate { await Popup_Reset_TextInput(true, string.Empty); });
                        }
                        else if (vSearchOpen)
                        {
                            Debug.WriteLine("Resetting the search popup.");
                            await AVActions.ActionDispatcherInvokeAsync(async delegate { await Popup_Reset_Search(true); });
                        }
                        else if (vFilePickerOpen)
                        {
                            await KeySendSingle(KeysVirtual.BackSpace, vProcessCurrent.MainWindowHandle);
                        }
                        else
                        {
                            await AVActions.ActionDispatcherInvokeAsync(async delegate { await QuickActionPrompt(); });
                        }

                        ControllerUsed        = true;
                        ControllerDelayMedium = true;
                    }
                    else if (ControllerInput.ButtonX.PressedRaw)
                    {
                        Debug.WriteLine("Button: XPressed");

                        await KeySendSingle(KeysVirtual.Delete, vProcessCurrent.MainWindowHandle);

                        ControllerUsed        = true;
                        ControllerDelayMedium = true;
                    }
                    else if (ControllerInput.ButtonShoulderLeft.PressedRaw)
                    {
                        Debug.WriteLine("Button: ShoulderLeftPressed");
                        await AVActions.ActionDispatcherInvokeAsync(async delegate
                        {
                            if (grid_Popup_Settings.Visibility == Visibility.Visible)
                            {
                                await SettingsChangeTab(true);
                                await KeySendSingle(KeysVirtual.F13, vProcessCurrent.MainWindowHandle);
                            }
                            else
                            {
                                await KeyPressComboAuto(KeysVirtual.Shift, KeysVirtual.Tab);
                            }
                        });

                        ControllerUsed       = true;
                        ControllerDelayShort = true;
                    }
                    else if (ControllerInput.ButtonShoulderRight.PressedRaw)
                    {
                        Debug.WriteLine("Button: ShoulderRightPressed");
                        await AVActions.ActionDispatcherInvokeAsync(async delegate
                        {
                            if (grid_Popup_Settings.Visibility == Visibility.Visible)
                            {
                                await SettingsChangeTab(false);
                                await KeySendSingle(KeysVirtual.F13, vProcessCurrent.MainWindowHandle);
                            }
                            else
                            {
                                await KeySendSingle(KeysVirtual.Tab, vProcessCurrent.MainWindowHandle);
                            }
                        });

                        ControllerUsed       = true;
                        ControllerDelayShort = true;
                    }
                    else if (ControllerInput.ButtonBack.PressedRaw)
                    {
                        Debug.WriteLine("Button: BackPressed / Show hide menu");
                        await AVActions.ActionDispatcherInvokeAsync(async delegate
                        {
                            await Popup_ShowHide_Search(false);
                        });

                        ControllerUsed        = true;
                        ControllerDelayLonger = true;
                    }
                    else if (ControllerInput.ButtonStart.PressedRaw)
                    {
                        Debug.WriteLine("Button: StartPressed / Show hide search");
                        if (vFilePickerOpen)
                        {
                            AVActions.ActionDispatcherInvoke(delegate
                            {
                                FilePicker_CheckItem();
                            });
                        }
                        else
                        {
                            await AVActions.ActionDispatcherInvokeAsync(async delegate
                            {
                                await Popup_ShowHide_MainMenu(false);
                            });
                        }

                        ControllerUsed        = true;
                        ControllerDelayLonger = true;
                    }
                    else if (ControllerInput.ButtonThumbLeft.PressedRaw)
                    {
                        Debug.WriteLine("Button: ThumbLeftPressed");
                        await KeySendSingle(KeysVirtual.Home, vProcessCurrent.MainWindowHandle);

                        ControllerUsed       = true;
                        ControllerDelayShort = true;
                    }
                    else if (ControllerInput.ButtonThumbRight.PressedRaw)
                    {
                        Debug.WriteLine("Button: ThumbRightPressed");
                        await KeySendSingle(KeysVirtual.End, vProcessCurrent.MainWindowHandle);

                        ControllerUsed       = true;
                        ControllerDelayShort = true;
                    }

                    if (ControllerDelayShort)
                    {
                        vControllerDelay_Button = GetSystemTicksMs() + vControllerDelayShortTicks;
                    }
                    else if (ControllerDelayMedium)
                    {
                        vControllerDelay_Button = GetSystemTicksMs() + vControllerDelayMediumTicks;
                    }
                    else if (ControllerDelayLonger)
                    {
                        vControllerDelay_Button = GetSystemTicksMs() + vControllerDelayLongerTicks;
                    }
                }
            }
            catch { }
            return(ControllerUsed);
        }
Exemple #29
0
        //Receive and translate DirectInput
        async Task LoopInputHidDevice(ControllerStatus Controller)
        {
            try
            {
                Debug.WriteLine("Receive and translate Hid DirectInput for: " + Controller.Details.DisplayName);

                //Receive input from the selected controller
                while (!Controller.InputControllerTask.TaskStopRequest && Controller.Connected())
                {
                    try
                    {
                        //Read data from the controller
                        if (!Controller.HidDevice.ReadBytesFile(Controller.InputReport))
                        {
                            Debug.WriteLine("Failed to read input data from hid controller: " + Controller.NumberId);
                            continue;
                        }

                        //Update the controller last input time
                        Controller.PrevInputTicks = Controller.LastInputTicks;
                        Controller.LastInputTicks = GetSystemTicksMs();

                        //Detect and adjust controller header offset
                        if (HidAdjustHeaderOffset(Controller))
                        {
                            continue;
                        }

                        //Set controller read offsets
                        int OffsetThumbLeftX    = Controller.InputHeaderOffsetByte;
                        int OffsetThumbLeftY    = Controller.InputHeaderOffsetByte;
                        int OffsetThumbRightX   = Controller.InputHeaderOffsetByte;
                        int OffsetThumbRightY   = Controller.InputHeaderOffsetByte;
                        int OffsetButtonsGroup1 = Controller.InputHeaderOffsetByte + Controller.InputButtonOffsetByte; //D-Pad and A,B,X,Y
                        int OffsetButtonsGroup2 = Controller.InputHeaderOffsetByte + Controller.InputButtonOffsetByte; //ShoulderLeftRight, TriggerLeftRight, ThumbLeftRight, Back, Start
                        int OffsetButtonsGroup3 = Controller.InputHeaderOffsetByte + Controller.InputButtonOffsetByte; //Guide, Touchpad, Mute
                        int OffsetTriggerLeft   = Controller.InputHeaderOffsetByte + Controller.InputButtonOffsetByte;
                        int OffsetTriggerRight  = Controller.InputHeaderOffsetByte + Controller.InputButtonOffsetByte;
                        int OffsetTouchpad      = Controller.InputHeaderOffsetByte + Controller.InputButtonOffsetByte;
                        int OffsetGyroscope     = Controller.InputHeaderOffsetByte + Controller.InputButtonOffsetByte;
                        int OffsetAccelerometer = Controller.InputHeaderOffsetByte + Controller.InputButtonOffsetByte;
                        if (Controller.Details.Wireless)
                        {
                            OffsetThumbLeftX    += Controller.SupportedCurrent.OffsetWireless.ThumbLeftX + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetThumbLeftY    += Controller.SupportedCurrent.OffsetWireless.ThumbLeftY + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetThumbRightX   += Controller.SupportedCurrent.OffsetWireless.ThumbRightX + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetThumbRightY   += Controller.SupportedCurrent.OffsetWireless.ThumbRightY + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetButtonsGroup1 += Controller.SupportedCurrent.OffsetWireless.ButtonsGroup1 + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetButtonsGroup2 += Controller.SupportedCurrent.OffsetWireless.ButtonsGroup2 + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetButtonsGroup3 += Controller.SupportedCurrent.OffsetWireless.ButtonsGroup3 + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetTriggerLeft   += Controller.SupportedCurrent.OffsetWireless.TriggerLeft + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetTriggerRight  += Controller.SupportedCurrent.OffsetWireless.TriggerRight + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetTouchpad      += Controller.SupportedCurrent.OffsetWireless.Touchpad + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetGyroscope     += Controller.SupportedCurrent.OffsetWireless.Gyroscope + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                            OffsetAccelerometer += Controller.SupportedCurrent.OffsetWireless.Accelerometer + Controller.SupportedCurrent.OffsetWireless.BeginOffset;
                        }
                        else
                        {
                            OffsetThumbLeftX    += Controller.SupportedCurrent.OffsetUsb.ThumbLeftX + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetThumbLeftY    += Controller.SupportedCurrent.OffsetUsb.ThumbLeftY + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetThumbRightX   += Controller.SupportedCurrent.OffsetUsb.ThumbRightX + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetThumbRightY   += Controller.SupportedCurrent.OffsetUsb.ThumbRightY + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetButtonsGroup1 += Controller.SupportedCurrent.OffsetUsb.ButtonsGroup1 + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetButtonsGroup2 += Controller.SupportedCurrent.OffsetUsb.ButtonsGroup2 + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetButtonsGroup3 += Controller.SupportedCurrent.OffsetUsb.ButtonsGroup3 + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetTriggerLeft   += Controller.SupportedCurrent.OffsetUsb.TriggerLeft + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetTriggerRight  += Controller.SupportedCurrent.OffsetUsb.TriggerRight + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetTouchpad      += Controller.SupportedCurrent.OffsetUsb.Touchpad + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetGyroscope     += Controller.SupportedCurrent.OffsetUsb.Gyroscope + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                            OffsetAccelerometer += Controller.SupportedCurrent.OffsetUsb.Accelerometer + Controller.SupportedCurrent.OffsetUsb.BeginOffset;
                        }

                        //Detect and adjust controller button offset
                        if (HidAdjustButtonOffset(Controller, OffsetButtonsGroup1))
                        {
                            continue;
                        }

                        //Count available controller buttons in arrays
                        if (HidCountButtonArray(Controller.InputReport, 4, OffsetButtonsGroup1, ref Controller.InputButtonCountLoop1, ref Controller.InputButtonCountTotal1))
                        {
                            continue;
                        }
                        if (HidCountButtonArray(Controller.InputReport, 0, OffsetButtonsGroup2, ref Controller.InputButtonCountLoop2, ref Controller.InputButtonCountTotal2))
                        {
                            continue;
                        }
                        if (HidCountButtonArray(Controller.InputReport, 0, OffsetButtonsGroup3, ref Controller.InputButtonCountLoop3, ref Controller.InputButtonCountTotal3))
                        {
                            continue;
                        }

                        //Calculate left thumbs
                        int ThumbLeftX = Controller.InputReport[OffsetThumbLeftX];
                        int ThumbLeftY = Controller.InputReport[OffsetThumbLeftY];
                        ThumbLeftX = (ThumbLeftX * 257) - (int)32767.5;
                        ThumbLeftY = (int)32767.5 - (ThumbLeftY * 257);

                        //Calculate right thumbs
                        int ThumbRightX = Controller.InputReport[OffsetThumbRightX];
                        int ThumbRightY = Controller.InputReport[OffsetThumbRightY];
                        ThumbRightX = (ThumbRightX * 257) - (int)32767.5;
                        ThumbRightY = (int)32767.5 - (ThumbRightY * 257);

                        //Flip the thumbs
                        if (Controller.Details.Profile.ThumbFlipMovement)
                        {
                            int CurrentLeftX  = ThumbLeftX;
                            int CurrentLeftY  = ThumbLeftY;
                            int CurrentRightX = ThumbRightX;
                            int CurrentRightY = ThumbRightY;
                            ThumbLeftX  = CurrentRightX;
                            ThumbLeftY  = CurrentRightY;
                            ThumbRightX = CurrentLeftX;
                            ThumbRightY = CurrentLeftY;
                        }

                        //Flip thumb axes
                        if (Controller.Details.Profile.ThumbFlipAxesLeft)
                        {
                            int CurrentLeftX = ThumbLeftX;
                            int CurrentLeftY = ThumbLeftY;
                            ThumbLeftX = CurrentLeftY;
                            ThumbLeftY = CurrentLeftX;
                        }
                        if (Controller.Details.Profile.ThumbFlipAxesRight)
                        {
                            int CurrentRightX = ThumbRightX;
                            int CurrentRightY = ThumbRightY;
                            ThumbRightX = CurrentRightY;
                            ThumbRightY = CurrentRightX;
                        }

                        //Reverse the thumbs
                        if (Controller.Details.Profile.ThumbReverseAxesLeft)
                        {
                            ThumbLeftX = -ThumbLeftX;
                            ThumbLeftY = -ThumbLeftY;
                        }
                        if (Controller.Details.Profile.ThumbReverseAxesRight)
                        {
                            ThumbRightX = -ThumbRightX;
                            ThumbRightY = -ThumbRightY;
                        }

                        //Check the thumbs deadzone
                        if (Controller.Details.Profile.DeadzoneThumbLeft != 0)
                        {
                            int deadzoneRangeLeft = ((int)32767.5 * Controller.Details.Profile.DeadzoneThumbLeft) / 100;
                            if (Math.Abs(ThumbLeftX) < deadzoneRangeLeft)
                            {
                                ThumbLeftX = 0;
                            }
                            if (Math.Abs(ThumbLeftY) < deadzoneRangeLeft)
                            {
                                ThumbLeftY = 0;
                            }
                        }
                        if (Controller.Details.Profile.DeadzoneThumbRight != 0)
                        {
                            int deadzoneRangeRight = ((int)32767.5 * Controller.Details.Profile.DeadzoneThumbRight) / 100;
                            if (Math.Abs(ThumbRightX) < deadzoneRangeRight)
                            {
                                ThumbRightX = 0;
                            }
                            if (Math.Abs(ThumbRightY) < deadzoneRangeRight)
                            {
                                ThumbRightY = 0;
                            }
                        }

                        //Calculate thumbs sensitivity
                        if (Controller.Details.Profile.SensitivityThumb != 1)
                        {
                            ThumbLeftX  = Convert.ToInt32(ThumbLeftX * Controller.Details.Profile.SensitivityThumb);
                            ThumbLeftY  = Convert.ToInt32(ThumbLeftY * Controller.Details.Profile.SensitivityThumb);
                            ThumbRightX = Convert.ToInt32(ThumbRightX * Controller.Details.Profile.SensitivityThumb);
                            ThumbRightY = Convert.ToInt32(ThumbRightY * Controller.Details.Profile.SensitivityThumb);
                        }

                        //Check the thumbs range
                        if (ThumbLeftX > 32767)
                        {
                            ThumbLeftX = 32767;
                        }
                        else if (ThumbLeftX < -32767)
                        {
                            ThumbLeftX = -32767;
                        }
                        if (ThumbLeftY > 32767)
                        {
                            ThumbLeftY = 32767;
                        }
                        else if (ThumbLeftY < -32767)
                        {
                            ThumbLeftY = -32767;
                        }
                        if (ThumbRightX > 32767)
                        {
                            ThumbRightX = 32767;
                        }
                        else if (ThumbRightX < -32767)
                        {
                            ThumbRightX = -32767;
                        }
                        if (ThumbRightY > 32767)
                        {
                            ThumbRightY = 32767;
                        }
                        else if (ThumbRightY < -32767)
                        {
                            ThumbRightY = -32767;
                        }

                        //Store the thumbs
                        Controller.InputCurrent.ThumbLeftX  = ThumbLeftX;
                        Controller.InputCurrent.ThumbLeftY  = ThumbLeftY;
                        Controller.InputCurrent.ThumbRightX = ThumbRightX;
                        Controller.InputCurrent.ThumbRightY = ThumbRightY;

                        //Raw Triggers
                        if (Controller.InputReport.Length >= OffsetTriggerRight)
                        {
                            int triggerLeftBytes  = Controller.InputReport[OffsetTriggerLeft];
                            int triggerRightBytes = Controller.InputReport[OffsetTriggerRight];

                            //Check the triggers deadzone
                            if (Controller.Details.Profile.DeadzoneTriggerLeft != 0)
                            {
                                int deadzoneRangeLeft = (255 * Controller.Details.Profile.DeadzoneTriggerLeft) / 100;
                                if (triggerLeftBytes < deadzoneRangeLeft)
                                {
                                    triggerLeftBytes = 0;
                                }
                            }
                            if (Controller.Details.Profile.DeadzoneTriggerRight != 0)
                            {
                                int deadzoneRangeRight = (255 * Controller.Details.Profile.DeadzoneTriggerRight) / 100;
                                if (triggerRightBytes < deadzoneRangeRight)
                                {
                                    triggerRightBytes = 0;
                                }
                            }

                            //Calculate trigger sensitivity
                            if (Controller.Details.Profile.SensitivityTrigger != 1)
                            {
                                triggerLeftBytes  = Convert.ToInt32(triggerLeftBytes * Controller.Details.Profile.SensitivityTrigger);
                                triggerRightBytes = Convert.ToInt32(triggerRightBytes * Controller.Details.Profile.SensitivityTrigger);
                            }

                            //Check the triggers range
                            if (triggerLeftBytes > 255)
                            {
                                triggerLeftBytes = 255;
                            }
                            if (triggerRightBytes > 255)
                            {
                                triggerRightBytes = 255;
                            }

                            Controller.InputCurrent.TriggerLeft  = Convert.ToByte(triggerLeftBytes);
                            Controller.InputCurrent.TriggerRight = Convert.ToByte(triggerRightBytes);
                        }
                        else if (!Controller.Details.Profile.UseButtonTriggers)
                        {
                            Debug.WriteLine("Controller without triggers detected.");
                            App.vWindowOverlay.Notification_Show_Status("Controller", "Controller has no triggers");

                            AVActions.ActionDispatcherInvoke(delegate { cb_ControllerUseButtonTriggers.IsChecked = true; });
                            Controller.Details.Profile.UseButtonTriggers = true;

                            //Save changes to Json file
                            JsonSaveObject(vDirectControllersProfile, "DirectControllersProfile");
                        }

                        //Raw Buttons (Group 1)
                        int ButtonOffset1 = 4;
                        int ButtonTotal1  = 0 + Controller.InputButtonCountTotal1;
                        for (int ButtonByte = 0; ButtonByte < ButtonTotal1; ButtonByte++)
                        {
                            Controller.InputCurrent.ButtonPressStatus[ButtonByte] = (Controller.InputReport[OffsetButtonsGroup1] & (1 << ButtonOffset1)) != 0;
                            ButtonOffset1++;
                        }

                        //Raw Buttons (Group 2)
                        int ButtonOffset2 = 0;
                        int ButtonTotal2  = 100 + Controller.InputButtonCountTotal2;
                        for (int ButtonByte = 100; ButtonByte < ButtonTotal2; ButtonByte++)
                        {
                            Controller.InputCurrent.ButtonPressStatus[ButtonByte] = (Controller.InputReport[OffsetButtonsGroup2] & (1 << ButtonOffset2)) != 0;
                            ButtonOffset2++;
                        }

                        //Raw Buttons (Group 3)
                        int ButtonOffset3 = 0;
                        int ButtonTotal3  = 200 + Controller.InputButtonCountTotal3;
                        for (int ButtonByte = 200; ButtonByte < ButtonTotal3; ButtonByte++)
                        {
                            Controller.InputCurrent.ButtonPressStatus[ButtonByte] = (Controller.InputReport[OffsetButtonsGroup3] & (1 << ButtonOffset3)) != 0;
                            ButtonOffset3++;
                        }

                        //Raw DPad (Group 1)
                        Controller.InputCurrent.DPadLeft.PressedRaw  = (Controller.InputReport[OffsetButtonsGroup1] & (1 << 1)) != 0;
                        Controller.InputCurrent.DPadUp.PressedRaw    = (Controller.InputReport[OffsetButtonsGroup1] & (1 << 3)) != 0;
                        Controller.InputCurrent.DPadRight.PressedRaw = (Controller.InputReport[OffsetButtonsGroup1] & (1 << 0)) != 0;
                        Controller.InputCurrent.DPadDown.PressedRaw  = (Controller.InputReport[OffsetButtonsGroup1] & (1 << 2)) != 0;
                        byte DPadState = (byte)(((Controller.InputCurrent.DPadRight.PressedRaw ? 1 : 0) << 0) | ((Controller.InputCurrent.DPadLeft.PressedRaw ? 1 : 0) << 1) | ((Controller.InputCurrent.DPadDown.PressedRaw ? 1 : 0) << 2) | ((Controller.InputCurrent.DPadUp.PressedRaw ? 1 : 0) << 3));
                        if (Controller.Details.Profile.DPadFourWayMovement)
                        {
                            switch (DPadState)
                            {
                            case 0: Controller.InputCurrent.DPadUp.PressedRaw = true; Controller.InputCurrent.DPadDown.PressedRaw = false; Controller.InputCurrent.DPadLeft.PressedRaw = false; Controller.InputCurrent.DPadRight.PressedRaw = false; break;

                            case 2: Controller.InputCurrent.DPadUp.PressedRaw = false; Controller.InputCurrent.DPadDown.PressedRaw = false; Controller.InputCurrent.DPadLeft.PressedRaw = false; Controller.InputCurrent.DPadRight.PressedRaw = true; break;

                            case 4: Controller.InputCurrent.DPadUp.PressedRaw = false; Controller.InputCurrent.DPadDown.PressedRaw = true; Controller.InputCurrent.DPadLeft.PressedRaw = false; Controller.InputCurrent.DPadRight.PressedRaw = false; break;

                            case 6: Controller.InputCurrent.DPadUp.PressedRaw = false; Controller.InputCurrent.DPadDown.PressedRaw = false; Controller.InputCurrent.DPadLeft.PressedRaw = true; Controller.InputCurrent.DPadRight.PressedRaw = false; break;

                            default: Controller.InputCurrent.DPadUp.PressedRaw = false; Controller.InputCurrent.DPadDown.PressedRaw = false; Controller.InputCurrent.DPadLeft.PressedRaw = false; Controller.InputCurrent.DPadRight.PressedRaw = false; break;
                            }
                        }
                        else
                        {
                            switch (DPadState)
                            {
                            case 0: Controller.InputCurrent.DPadUp.PressedRaw = true; Controller.InputCurrent.DPadDown.PressedRaw = false; Controller.InputCurrent.DPadLeft.PressedRaw = false; Controller.InputCurrent.DPadRight.PressedRaw = false; break;

                            case 1: Controller.InputCurrent.DPadUp.PressedRaw = true; Controller.InputCurrent.DPadDown.PressedRaw = false; Controller.InputCurrent.DPadLeft.PressedRaw = false; Controller.InputCurrent.DPadRight.PressedRaw = true; break;

                            case 2: Controller.InputCurrent.DPadUp.PressedRaw = false; Controller.InputCurrent.DPadDown.PressedRaw = false; Controller.InputCurrent.DPadLeft.PressedRaw = false; Controller.InputCurrent.DPadRight.PressedRaw = true; break;

                            case 3: Controller.InputCurrent.DPadUp.PressedRaw = false; Controller.InputCurrent.DPadDown.PressedRaw = true; Controller.InputCurrent.DPadLeft.PressedRaw = false; Controller.InputCurrent.DPadRight.PressedRaw = true; break;

                            case 4: Controller.InputCurrent.DPadUp.PressedRaw = false; Controller.InputCurrent.DPadDown.PressedRaw = true; Controller.InputCurrent.DPadLeft.PressedRaw = false; Controller.InputCurrent.DPadRight.PressedRaw = false; break;

                            case 5: Controller.InputCurrent.DPadUp.PressedRaw = false; Controller.InputCurrent.DPadDown.PressedRaw = true; Controller.InputCurrent.DPadLeft.PressedRaw = true; Controller.InputCurrent.DPadRight.PressedRaw = false; break;

                            case 6: Controller.InputCurrent.DPadUp.PressedRaw = false; Controller.InputCurrent.DPadDown.PressedRaw = false; Controller.InputCurrent.DPadLeft.PressedRaw = true; Controller.InputCurrent.DPadRight.PressedRaw = false; break;

                            case 7: Controller.InputCurrent.DPadUp.PressedRaw = true; Controller.InputCurrent.DPadDown.PressedRaw = false; Controller.InputCurrent.DPadLeft.PressedRaw = true; Controller.InputCurrent.DPadRight.PressedRaw = false; break;

                            default: Controller.InputCurrent.DPadUp.PressedRaw = false; Controller.InputCurrent.DPadDown.PressedRaw = false; Controller.InputCurrent.DPadLeft.PressedRaw = false; Controller.InputCurrent.DPadRight.PressedRaw = false; break;
                            }
                        }

                        //Raw Touchpad
                        if (Controller.SupportedCurrent.HasTouchpad)
                        {
                            byte touchByte0 = Controller.InputReport[OffsetTouchpad];
                            byte touchByte1 = Controller.InputReport[OffsetTouchpad + 1];
                            byte touchByte2 = Controller.InputReport[OffsetTouchpad + 2];
                            byte touchByte3 = Controller.InputReport[OffsetTouchpad + 3];

                            if ((touchByte0 & 0x80) == 0)
                            {
                                Controller.InputCurrent.TouchpadActive = 1;
                            }
                            else
                            {
                                Controller.InputCurrent.TouchpadActive = 0;
                            }
                            Controller.InputCurrent.TouchpadId = (byte)(touchByte0 & 0x7F);
                            Controller.InputCurrent.TouchpadX  = ((ushort)(touchByte2 & 0x0F) << 8) | touchByte1;
                            Controller.InputCurrent.TouchpadY  = (touchByte3 << 4) | ((ushort)(touchByte2 & 0xF0) >> 4);
                        }

                        //Raw Gyroscope
                        if (Controller.SupportedCurrent.HasGyroscope)
                        {
                            byte gyroByte0 = Controller.InputReport[OffsetGyroscope];
                            byte gyroByte1 = Controller.InputReport[OffsetGyroscope + 1];
                            byte gyroByte2 = Controller.InputReport[OffsetGyroscope + 2];
                            byte gyroByte3 = Controller.InputReport[OffsetGyroscope + 3];
                            byte gyroByte4 = Controller.InputReport[OffsetGyroscope + 4];
                            byte gyroByte5 = Controller.InputReport[OffsetGyroscope + 5];

                            short gyroPitch = (short)((ushort)(gyroByte1 << 8) | gyroByte0);
                            short gyroYaw   = (short)((ushort)(gyroByte3 << 8) | gyroByte2);
                            short gyroRoll  = (short)((ushort)(gyroByte5 << 8) | gyroByte4);

                            Controller.InputCurrent.GyroPitch = gyroPitch / (float)16;
                            Controller.InputCurrent.GyroYaw   = -gyroYaw / (float)16;
                            Controller.InputCurrent.GyroRoll  = -gyroRoll / (float)16;
                        }

                        //Raw Accelerometer
                        if (Controller.SupportedCurrent.HasAccelerometer)
                        {
                            byte accelByte0 = Controller.InputReport[OffsetAccelerometer];
                            byte accelByte1 = Controller.InputReport[OffsetAccelerometer + 1];
                            byte accelByte2 = Controller.InputReport[OffsetAccelerometer + 2];
                            byte accelByte3 = Controller.InputReport[OffsetAccelerometer + 3];
                            byte accelByte4 = Controller.InputReport[OffsetAccelerometer + 4];
                            byte accelByte5 = Controller.InputReport[OffsetAccelerometer + 5];

                            short accelX = (short)((ushort)(accelByte1 << 8) | accelByte0);
                            short accelY = (short)((ushort)(accelByte3 << 8) | accelByte2);
                            short accelZ = (short)((ushort)(accelByte5 << 8) | accelByte4);

                            Controller.InputCurrent.AccelX = -accelX / (float)8192;
                            Controller.InputCurrent.AccelY = -accelY / (float)8192;
                            Controller.InputCurrent.AccelZ = -accelZ / (float)8192;
                        }

                        //Save controller button mapping
                        if (!ControllerSaveMapping(Controller))
                        {
                            //Set button mapping input data
                            if (Controller.Details.Profile.ButtonA == null)
                            {
                                Controller.InputCurrent.ButtonA.PressedRaw = Controller.InputCurrent.ButtonPressStatus[1];
                            }
                            else if (Controller.Details.Profile.ButtonA != -1)
                            {
                                Controller.InputCurrent.ButtonA.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonA.Value];
                            }

                            if (Controller.Details.Profile.ButtonB == null)
                            {
                                Controller.InputCurrent.ButtonB.PressedRaw = Controller.InputCurrent.ButtonPressStatus[2];
                            }
                            else if (Controller.Details.Profile.ButtonB != -1)
                            {
                                Controller.InputCurrent.ButtonB.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonB.Value];
                            }

                            if (Controller.Details.Profile.ButtonX == null)
                            {
                                Controller.InputCurrent.ButtonX.PressedRaw = Controller.InputCurrent.ButtonPressStatus[0];
                            }
                            else if (Controller.Details.Profile.ButtonX != -1)
                            {
                                Controller.InputCurrent.ButtonX.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonX.Value];
                            }

                            if (Controller.Details.Profile.ButtonY == null)
                            {
                                Controller.InputCurrent.ButtonY.PressedRaw = Controller.InputCurrent.ButtonPressStatus[3];
                            }
                            else if (Controller.Details.Profile.ButtonY != -1)
                            {
                                Controller.InputCurrent.ButtonY.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonY.Value];
                            }

                            if (Controller.Details.Profile.ButtonBack == null)
                            {
                                Controller.InputCurrent.ButtonBack.PressedRaw = Controller.InputCurrent.ButtonPressStatus[104];
                            }
                            else if (Controller.Details.Profile.ButtonBack != -1)
                            {
                                Controller.InputCurrent.ButtonBack.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonBack.Value];
                            }

                            if (Controller.Details.Profile.ButtonStart == null)
                            {
                                Controller.InputCurrent.ButtonStart.PressedRaw = Controller.InputCurrent.ButtonPressStatus[105];
                            }
                            else if (Controller.Details.Profile.ButtonStart != -1)
                            {
                                Controller.InputCurrent.ButtonStart.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonStart.Value];
                            }

                            if (Controller.Details.Profile.ButtonGuide == null)
                            {
                                Controller.InputCurrent.ButtonGuide.PressedRaw = Controller.InputCurrent.ButtonPressStatus[200];
                            }
                            else if (Controller.Details.Profile.ButtonGuide != -1)
                            {
                                Controller.InputCurrent.ButtonGuide.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonGuide.Value];
                            }

                            if (Controller.Details.Profile.ButtonTouchpad == null)
                            {
                                Controller.InputCurrent.ButtonTouchpad.PressedRaw = Controller.InputCurrent.ButtonPressStatus[201];
                            }
                            else if (Controller.Details.Profile.ButtonTouchpad != -1)
                            {
                                Controller.InputCurrent.ButtonTouchpad.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonTouchpad.Value];
                            }

                            if (Controller.Details.Profile.ButtonMedia == null)
                            {
                                Controller.InputCurrent.ButtonMedia.PressedRaw = Controller.InputCurrent.ButtonPressStatus[202];
                            }
                            else if (Controller.Details.Profile.ButtonMedia != -1)
                            {
                                Controller.InputCurrent.ButtonMedia.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonMedia.Value];
                            }

                            if (Controller.Details.Profile.ButtonTriggerLeft == null)
                            {
                                Controller.InputCurrent.ButtonTriggerLeft.PressedRaw = Controller.InputCurrent.ButtonPressStatus[102];
                            }
                            else if (Controller.Details.Profile.ButtonTriggerLeft != -1)
                            {
                                Controller.InputCurrent.ButtonTriggerLeft.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonTriggerLeft.Value];
                            }

                            if (Controller.Details.Profile.ButtonTriggerRight == null)
                            {
                                Controller.InputCurrent.ButtonTriggerRight.PressedRaw = Controller.InputCurrent.ButtonPressStatus[103];
                            }
                            else if (Controller.Details.Profile.ButtonTriggerRight != -1)
                            {
                                Controller.InputCurrent.ButtonTriggerRight.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonTriggerRight.Value];
                            }

                            if (Controller.Details.Profile.ButtonShoulderLeft == null)
                            {
                                Controller.InputCurrent.ButtonShoulderLeft.PressedRaw = Controller.InputCurrent.ButtonPressStatus[100];
                            }
                            else if (Controller.Details.Profile.ButtonShoulderLeft != -1)
                            {
                                Controller.InputCurrent.ButtonShoulderLeft.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonShoulderLeft.Value];
                            }

                            if (Controller.Details.Profile.ButtonShoulderRight == null)
                            {
                                Controller.InputCurrent.ButtonShoulderRight.PressedRaw = Controller.InputCurrent.ButtonPressStatus[101];
                            }
                            else if (Controller.Details.Profile.ButtonShoulderRight != -1)
                            {
                                Controller.InputCurrent.ButtonShoulderRight.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonShoulderRight.Value];
                            }

                            if (Controller.Details.Profile.ButtonThumbLeft == null)
                            {
                                Controller.InputCurrent.ButtonThumbLeft.PressedRaw = Controller.InputCurrent.ButtonPressStatus[106];
                            }
                            else if (Controller.Details.Profile.ButtonThumbLeft != -1)
                            {
                                Controller.InputCurrent.ButtonThumbLeft.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonThumbLeft.Value];
                            }

                            if (Controller.Details.Profile.ButtonThumbRight == null)
                            {
                                Controller.InputCurrent.ButtonThumbRight.PressedRaw = Controller.InputCurrent.ButtonPressStatus[107];
                            }
                            else if (Controller.Details.Profile.ButtonThumbRight != -1)
                            {
                                Controller.InputCurrent.ButtonThumbRight.PressedRaw = Controller.InputCurrent.ButtonPressStatus[Controller.Details.Profile.ButtonThumbRight.Value];
                            }

                            //Fake Guide button press with Start and Back
                            if (Controller.Details.Profile.FakeGuideButton && Controller.InputCurrent.ButtonStart.PressedRaw && Controller.InputCurrent.ButtonBack.PressedRaw)
                            {
                                Controller.InputCurrent.ButtonStart.PressedRaw = false;
                                Controller.InputCurrent.ButtonBack.PressedRaw  = false;
                                Controller.InputCurrent.ButtonGuide.PressedRaw = true;
                            }

                            //Update the controller battery level
                            ControllerReadBatteryLevel(Controller);

                            //Send input to the virtual device
                            await SendInputVirtual(Controller);
                        }
                    }
                    catch
                    {
                        Debug.WriteLine("Direct input hid data report is out of range or empty, skipping.");
                    }
                }
            }
            catch { }
        }
Exemple #30
0
        //Save controller button mapping
        bool ControllerSaveMapping(ControllerStatus Controller)
        {
            try
            {
                //Check if controller mapping is enabled
                if (vMappingControllerStatus == MappingStatus.Mapping)
                {
                    //Store new button mapping in Json controller
                    int buttonMapId = Array.FindIndex(Controller.InputCurrent.ButtonPressStatus, ButtonPressed => ButtonPressed);
                    if (buttonMapId != -1)
                    {
                        AVActions.ActionDispatcherInvoke(delegate
                        {
                            try
                            {
                                string mapNameString = vMappingControllerButton.ToolTip.ToString();
                                Debug.WriteLine("Mapped button " + mapNameString + " to: " + buttonMapId);
                                if (vMappingControllerButton == btn_SetA)
                                {
                                    Controller.Details.Profile.ButtonA = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetB)
                                {
                                    Controller.Details.Profile.ButtonB = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetX)
                                {
                                    Controller.Details.Profile.ButtonX = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetY)
                                {
                                    Controller.Details.Profile.ButtonY = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetShoulderLeft)
                                {
                                    Controller.Details.Profile.ButtonShoulderLeft = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetShoulderRight)
                                {
                                    Controller.Details.Profile.ButtonShoulderRight = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetBack)
                                {
                                    Controller.Details.Profile.ButtonBack = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetStart)
                                {
                                    Controller.Details.Profile.ButtonStart = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetGuide)
                                {
                                    Controller.Details.Profile.ButtonGuide = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetThumbLeft)
                                {
                                    Controller.Details.Profile.ButtonThumbLeft = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetThumbRight)
                                {
                                    Controller.Details.Profile.ButtonThumbRight = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetTriggerLeft)
                                {
                                    Controller.Details.Profile.ButtonTriggerLeft = buttonMapId;
                                }
                                else if (vMappingControllerButton == btn_SetTriggerRight)
                                {
                                    Controller.Details.Profile.ButtonTriggerRight = buttonMapId;
                                }
                            }
                            catch { }
                        });

                        //Reset controller button mapping
                        vMappingControllerStatus = MappingStatus.Done;
                        vMappingControllerButton = null;

                        //Save changes to Json file
                        JsonSaveObject(vDirectControllersProfile, "DirectControllersProfile");
                    }
                    return(true);
                }
            }
            catch { }
            return(false);
        }