Esempio n. 1
0
        public Screen()
        {
            InitializeComponent();

            bmp = new WriteableBitmap(BitmapWidth, BitmapHeight, 96, 96, PixelFormats.Gray8, null);
            var whitescreen = new byte[BitmapWidth * BitmapHeight];

            for (int i = 0; i < whitescreen.Length; i++)
            {
                whitescreen[i] = 0xff;
            }
            bmp.WritePixels(new Int32Rect(0, 0, BitmapWidth, BitmapHeight), whitescreen, BitmapWidth, 0);
            Display.Source = bmp;
            RenderOptions.SetBitmapScalingMode(Display, BitmapScalingMode.NearestNeighbor);

            FPSDisplayEnable.Checked   += (x, y) => FPS.Visibility = Visibility.Visible;
            FPSDisplayEnable.Unchecked += (x, y) => FPS.Visibility = Visibility.Collapsed;

            XboxController.UpdateFrequency = 5;
            XboxController.StartPolling();

            var Controller1 = new XboxControllerWithInterruptHandler(XboxController.RetrieveController(0));
            var Controller2 = new XboxControllerWithInterruptHandler(XboxController.RetrieveController(1));
            var Controller3 = new XboxControllerWithInterruptHandler(XboxController.RetrieveController(2));
            var Controller4 = new XboxControllerWithInterruptHandler(XboxController.RetrieveController(3));

            Dictionary <Key, JoypadKey> mappedKeys = new()
            {
                { Key.X, JoypadKey.A },
                { Key.LeftShift, JoypadKey.Select },
Esempio n. 2
0
 static Manager()
 {
     controller = new InputController("Teslagrad.tas");
     xbox       = XboxController.RetrieveController(0);
     XboxController.UpdateFrequency = 30;
     XboxController.StartPolling();
 }
Esempio n. 3
0
        public void Start()
        {
            Task.Run(async() =>
            {
                while (true)
                {
                    try
                    {
                        var foregroundProcess = ProcessesHelper.GetForegroundProcess();
                        if (foregroundProcess == null)
                        {
                            continue;
                        }

                        if (_xboxController.IsLeftShoulderPressed &&
                            _xboxController.LeftTrigger > 0 &&
                            _xboxController.IsRightShoulderPressed &&
                            _xboxController.RightTrigger > 0 &&
                            _xboxController.IsAPressed)
                        {
                            foreach (var gameProcess in _gameProcesses)
                            {
                                if (foregroundProcess.ProcessName == gameProcess)
                                {
                                    Console.WriteLine($"========================================");
                                    Console.WriteLine($"Foreground process : {foregroundProcess.ProcessName}");
                                    ProcessesHelper.Stop(gameProcess);
                                    Console.WriteLine($"{gameProcess} killed");
                                    await Task.Delay(1000);

                                    var oldDisplay = _displayService.GetCurrent();
                                    var newDisplay = _displayService.GetHigherDisplay();

                                    if (oldDisplay.Width < newDisplay.Width)
                                    {
                                        Console.WriteLine($"old display : {oldDisplay.Width} x {oldDisplay.Height}");
                                        _displayService.SetCurrent(newDisplay);
                                        Console.WriteLine($"new display : {newDisplay.Width} x {newDisplay.Height}");
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }

                    await Task.Delay(500);
                }
            });

            Task.Run(() =>
            {
                XboxController.StartPolling();
            });
        }
Esempio n. 4
0
        private void SetupKeyHandlers()
        {
            //register for keyboard events
            KeyDown += MainWindow_KeyDown;

            //register for xbox controller events
            handHeldController = XboxController.RetrieveController(0);
            handHeldController.StateChanged += handHeldController_StateChanged;
            XboxController.StartPolling();
        }
Esempio n. 5
0
 public XInputInterface()
 {
     Log.WriteLine("XInput interface starting up");
     XboxController.StartPolling();
     _active           = true;
     _controllerThread = new Thread(ControllerScan)
     {
         IsBackground = true
     };
     _controllerThread.Start();
 }
        public MainWindow()
        {
            InitializeComponent();
            DataContext         = this;
            _selectedController = XboxController.RetrieveController(0);
            _selectedController.StateChanged += _selectedController_StateChanged;
            XboxController.StartPolling();
            ArduinoTimer          = new System.Timers.Timer();
            ArduinoTimer.Interval = Config.DataSendDelay;
            ArduinoTimer.Elapsed += ArduinoTimer_Elapsed;
            ArduinoTimer.Start();

            System.Timers.Timer DebugTimer = new System.Timers.Timer();
            DebugTimer.Interval = 200;
            DebugTimer.Elapsed += DebugTimer_Elapsed;
            DebugTimer.Start();

            SetupSweepers();
        }
Esempio n. 7
0
        internal void InitializeController()
        {
            XboxController.StopPolling();

            try
            {
                _controller = XboxController.RetrieveController(_currid);
                _controller.StateChanged += _selectedController_StateChanged;
                XboxController.StartPolling();

                _message = "Connected to controller #" + _currid;
            }
            catch
            {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Cannot find controller with ID #" + _currid);
                _controller = null;

                _message = "Cannot find controller with ID #" + _currid;
            }
        }
Esempio n. 8
0
 public static void Start()
 {
     if (_watcherThread != null)
     {
         return;
     }
     Logger.Write("Starting controller manager");
     _watcherThread = new Thread(ControllerWatcher)
     {
         IsBackground = true
     };
     _watcherThread.Start();
     if (Settings.Default.EnableXbox)
     {
         XboxController.StartPolling();
     }
     if (Settings.Default.EnableDS4)
     {
         DS4Devices.findControllers();
     }
 }
Esempio n. 9
0
 // Token: 0x06000026 RID: 38 RVA: 0x0000219D File Offset: 0x0000039D
 static Manager()
 {
     XboxController.UpdateFrequency = 30;
     XboxController.StartPolling();
 }
Esempio n. 10
0
 public void Stop()
 {
     XboxController.StartPolling();
     _lowPassFilterTimer.Stop();
 }
Esempio n. 11
0
 private void StartPolling()
 {
     _controller.StateChanged += StateChanged;
     XboxController.StartPolling();
 }