protected override void OnLoad(EventArgs e)
        {
            Rectangle screenRect = Screen.GetWorkingArea(this);
            Left = screenRect.Left + (screenRect.Width - Width) / 2;
            Top = screenRect.Top + (screenRect.Height - Height) / 2;

            DialogResult = DialogResult.None;

            _aggregator = new InputAggregator();
            _aggregator.AddDriver(new RawInputDriver(this));

            _aggregator.ReportNextInput(_predicate, (i) =>
            {
                _inputID = i.ID;
                DialogResult = DialogResult.OK;
                Close();
            });

            base.OnLoad(e);
        }
Exemple #2
0
        public CoreDriver(UIWindow uiWindow, Configuration config)
        {
            IsDisposed = false;

            try
            {
                _config = config;

                _inputAggregator = new InputAggregator();
                _buttonStates = SnesJoypadButtons.None;

                _workerThread = new WorkerThread();

                _workerThread.DoWork(() =>
                {
                    _uiWindow = uiWindow;

                    _snes = new Snes();
                    _snes.VideoUpdated += Snes_VideoUpdated;
                    _snes.AudioUpdated += Snes_AudioUpdated;
                    _snes.SetControllerPortDevice(1, SnesDevice.Joypad);

                    _inputAggregator.InputReceived += InputAggregator_InputReceived;

                    _isAudioSynced = true;
                    _isVideoSynced = false;

                    _isRunning = false;

                    _stopwatch = new Stopwatch();
                    _stopwatch.Start();
                    _frameCount = 0;
                });
                _workerThread.WaitFor();
            }
            catch
            {
                Dispose();
                throw;
            }
        }