Exemple #1
0
            //Reset controller status to defaults
            public void ResetControllerStatus()
            {
                try
                {
                    Debug.WriteLine("Reset the controller status for controller: " + NumberId);

                    //Controller Status
                    Activated = false;

                    //Battery Status
                    BatteryCurrent  = new ControllerBattery();
                    BatteryPrevious = new ControllerBattery();

                    //Time Variables
                    PrevInputTicks  = 0;
                    LastInputTicks  = 0;
                    LastActiveTicks = 0;

                    //Controller Details
                    Details     = null;
                    BlockOutput = false;

                    //Controller Tasks
                    InputVirtualOverlapped = new NativeOverlapped()
                    {
                        EventHandle = CreateEvent(IntPtr.Zero, true, false, null)
                    };
                    OutputVirtualOverlapped = new NativeOverlapped()
                    {
                        EventHandle = CreateEvent(IntPtr.Zero, true, false, null)
                    };
                    InputControllerTask  = new AVTaskDetails();
                    OutputControllerTask = new AVTaskDetails();
                    OutputVirtualTask    = new AVTaskDetails();
                    OutputGyroTask       = new AVTaskDetails();

                    //WinUsb Device Variables
                    WinUsbDevice = null;

                    //Hid Device Variables
                    HidDevice = null;

                    //Gyro Dsu Client Variables
                    GyroDsuClientPacketNumber = 0;
                    GyroDsuClientEndPoint     = null;

                    //Device In and Output
                    InputButtonCountLoop1     = 0;
                    InputButtonCountTotal1    = 80;
                    InputButtonCountLoop2     = 0;
                    InputButtonCountTotal2    = 80;
                    InputButtonCountLoop3     = 0;
                    InputButtonCountTotal3    = 80;
                    InputHeaderOffsetFinished = false;
                    InputHeaderOffsetByte     = 0;
                    InputButtonOffsetFinished = false;
                    InputButtonOffsetByte     = 0;
                    InputReport  = null;
                    OutputReport = null;
                    XInputData   = new XUSB_INPUT_REPORT();
                    XOutputData  = new XUSB_OUTPUT_REPORT();
                    XOutputCurrentRumbleHeavy  = 0;
                    XOutputCurrentRumbleLight  = 0;
                    XOutputPreviousRumbleHeavy = 0;
                    XOutputPreviousRumbleLight = 0;

                    //Controller Input
                    InputCurrent     = new ControllerInput();
                    SupportedCurrent = new ControllerSupported();
                }
                catch { }
            }
Exemple #2
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;
                });
            }
        }