Esempio n. 1
0
        public static void SetActiveController(IController Controller)
        {
            _activeController?.SetLightbar(0, 0, 0);
            _activeController = Controller;

            ControllerChanged?.Invoke();
            ControllersUpdated?.Invoke();
            MainWindow.UpdateChildren();
        }
Esempio n. 2
0
        private async void ControllerListenerLoopAsync()
        {
            CancellationToken cancellationTokenSource = m_CancellationTokenSource.Token;
            XBoxController    connectedController     = XBoxController.GetConnectedControllers().FirstOrDefault();

            while (!cancellationTokenSource.IsCancellationRequested)
            {
                await Task.Delay(20);

                if (connectedController.IsConnected)
                {
                    StickValues newValues = new StickValues(connectedController.ThumbLeftX, connectedController.ThumbLeftY, connectedController.ThumbRightX, connectedController.ThumbRightY);
                    if (m_LastUpdate < Environment.TickCount)
                    {
                        m_LastUpdate = Environment.TickCount + UpdateFrequency;
                        ControllerUpdate?.Invoke(this, newValues);
                    }
                    if (newValues != m_LastValues)
                    {
                        m_LastValues = newValues;
                        ControllerChanged?.Invoke(this, newValues);
                    }
                    CheckButton("A", connectedController.ButtonAPressed);
                    CheckButton("B", connectedController.ButtonBPressed);
                    CheckButton("X", connectedController.ButtonXPressed);
                    CheckButton("Y", connectedController.ButtonYPressed);
                    CheckButton("Back", connectedController.ButtonBackPressed);
                    CheckButton("Start", connectedController.ButtonStartPressed);
                    CheckButton("Up", connectedController.ButtonUpPressed);
                    CheckButton("Down", connectedController.ButtonDownPressed);
                    CheckButton("Left", connectedController.ButtonLeftPressed);
                    CheckButton("Right", connectedController.ButtonRightPressed);
                    CheckButton("LB", connectedController.ButtonShoulderLeftPressed);
                    CheckButton("RB", connectedController.ButtonShoulderRightPressed);
                    CheckButton("LT", connectedController.TriggerLeftPressed);
                    CheckButton("RT", connectedController.TriggerRightPressed);
                    CheckButton("LS", connectedController.ThumbpadLeftPressed);
                    CheckButton("RS", connectedController.ThumbpadRightPressed);
                }
            }
        }