Exemplo n.º 1
0
        public Gta5EyeTracking()
        {
            Debug.Log("Begin Initialize");

            //Disposing
            _shutDownRequestedEvent = new ManualResetEvent(false);

            //Settings
            _settingsStorage = new SettingsStorage();
            _settings        = _settingsStorage.LoadSettings();

            //Statistics
            var version       = Assembly.GetExecutingAssembly().GetName().Version;
            var versionString = version.Major + "." + version.Minor + "." + version.Build;

            _googleAnalyticsApi = new GoogleAnalyticsApi("UA-68420530-1", _settings.UserGuid, "GTA V Eye Tracking Mod", "gta5eyetracking", versionString);

            //Gaze
            _tobiiTracker = new EyeTrackingHost();

            //Menu
            _menuPool     = new MenuPool();
            _settingsMenu = new SettingsMenu(_menuPool, _settings);

            _introScreen = new IntroScreen(_menuPool, _settings);

            //Debug
            _debugGazeVisualization = new DefaultCrosshair(Color.FromArgb(220, 255, 0, 0), Color.FromArgb(220, 0, 255, 255));
            _debugOutput            = new DebugOutput();

            //Hids
            _mouseEmulation      = new MouseEmulation();
            _controllerEmulation = new ControllerEmulation();

            //Features
            _gameState       = new GameState(_controllerEmulation, _menuPool);
            _animationHelper = new AnimationHelper();
            _aiming          = new Aiming(_settings, _animationHelper, _gameState);
            _extendedView    = new ExtendedView(_settings, _gameState, _aiming, _debugOutput);
            _radialMenu      = new RadialMenu(_controllerEmulation);

            //Window
            _foregroundWindowWatcher = new ForegroundWindowWatcher();
            _foregroundWindowWatcher.ForegroundWindowChanged += ForegroundWindowWatcherOnForegroundWindowChanged;
            _isWindowForeground = _foregroundWindowWatcher.IsWindowForeground();

            //General
            _gazeProjector     = new GazeProjector(_settings);
            _controlsProcessor = new ControlsProcessor(_settings, _controllerEmulation, _aiming, _extendedView, _radialMenu, _settingsMenu, _gameState, _debugOutput);

            KeyDown += OnKeyDown;
            Tick    += OnTick;
            Aborted += OnAborted;
            AppDomain.CurrentDomain.ProcessExit  += AppDomainOnProcessExit;
            AppDomain.CurrentDomain.DomainUnload += AppDomainOnProcessExit;
            Debug.Log("End Initialize");
        }
Exemplo n.º 2
0
        public Gta5EyeTracking()
        {
            _aspectRatio = 1;
            _host        = new EyeXHost();
            _host.Start();
            _lightlyFilteredGazePointDataProvider       = _host.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered);
            _lightlyFilteredGazePointDataProvider.Next += NewGazePoint;

            _menuPool = new MenuPool();

            LoadSettings();
            _settingsMenu = new SettingsMenu(_menuPool, _settings);
            _settingsMenu.DeadzoneMenu.OnItemSelect += (m, item, indx) =>
            {
                if (indx == 0)
                {
                    _isDrawingDeadzone = true;
                }
                else
                {
                    _settings.Deadzones.RemoveAt(indx - 1);
                    _settingsMenu.DeadzoneMenu.RemoveItemAt(indx);
                    _settingsMenu.DeadzoneMenu.RefreshIndex();
                }
            };

            _gazeVisualization = new GazeVisualization();
            _debugOutput       = new DebugOutput();

            _aiming = new Aiming(_settings);

            _mouseEmulation      = new MouseEmulation();
            _controllerEmulation = new ControllerEmulation();
            _controllerEmulation.OnModifyState += OnModifyControllerState;
            _freelook = new Freelook(_controllerEmulation, _mouseEmulation, _settings);
            _pedestrianInteraction = new PedestrianInteraction();
            _radialMenu            = new RadialMenu(_controllerEmulation);

            _gazeStopwatch = new Stopwatch();
            _gazeStopwatch.Restart();

            _tickStopwatch = new Stopwatch();

            _foregroundWindowWatcher = new ForegroundWindowWatcher();
            _foregroundWindowWatcher.ForegroundWindowChanged += ForegroundWindowWatcherOnForegroundWindowChanged;
            _isWindowForeground = _foregroundWindowWatcher.IsWindowForeground();

            View.MenuTransitions = true;

            KeyDown += OnKeyDown;

            Tick += OnTick;
        }
Exemplo n.º 3
0
        public Freelook(ControllerEmulation controllerEmulation,
                        MouseEmulation mouseEmulation,
                        Settings settings
                        )
        {
            _controllerEmulation = controllerEmulation;
            _mouseEmulation      = mouseEmulation;
            _settings            = settings;

            _freelookVelocityJoystick     = 2;
            _freelookVelocityPixelsPerSec = 1500;
        }
Exemplo n.º 4
0
        public Freelook(ControllerEmulation controllerEmulation,
                        MouseEmulation mouseEmulation,
                        Settings settings
                        )
        {
            _controllerEmulation = controllerEmulation;
            _mouseEmulation      = mouseEmulation;
            _settings            = settings;

            _freelookVelocityJoystick     = 2;
            _freelookVelocityPixelsPerSec = 5000;
            _freelookVelocityCam          = 6;
            CreateFirstPersonDrivingCamera();
        }
Exemplo n.º 5
0
 public ControlsProcessor(Settings settings,
                          ControllerEmulation controllerEmulation,
                          Aiming aiming,
                          Freelook freelook,
                          RadialMenu radialMenu,
                          SettingsMenu settingsMenu,
                          MenuPool menuPool,
                          DebugOutput debugOutput)
 {
     _settings            = settings;
     _controllerEmulation = controllerEmulation;
     _aiming       = aiming;
     _freelook     = freelook;
     _radialMenu   = radialMenu;
     _settingsMenu = settingsMenu;
     _menuPool     = menuPool;
     _debugOutput  = debugOutput;
     _controllerEmulation.OnModifyState += OnModifyControllerState;
 }
        public ControlsProcessor(Settings settings,
                                 ControllerEmulation controllerEmulation,
                                 Aiming aiming,
                                 ExtendedView extendedView,
                                 RadialMenu radialMenu,
                                 SettingsMenu settingsMenu,
                                 GameState gameState,
                                 DebugOutput debugOutput)
        {
            _settings            = settings;
            _controllerEmulation = controllerEmulation;
            _aiming       = aiming;
            _extendedView = extendedView;
            _radialMenu   = radialMenu;
            _settingsMenu = settingsMenu;
            _gameState    = gameState;

            _debugOutput = debugOutput;
            _controllerEmulation.OnModifyState += OnModifyControllerState;
        }
Exemplo n.º 7
0
 public GameState(ControllerEmulation controllerEmulation, MenuPool menuPool)
 {
     _controllerEmulation = controllerEmulation;
     _menuPool            = menuPool;
 }
Exemplo n.º 8
0
        private void ShutDown()
        {
            Debug.Log("Begin ShutDown");
            _shutDownRequestFlag = true;
            KeyDown -= OnKeyDown;
            Tick    -= OnTick;
            Aborted -= OnAborted;
            AppDomain.CurrentDomain.ProcessExit -= AppDomainOnProcessExit;

            _shutDownRequestedEvent.WaitOne(100);
            _settingsStorage.SaveSettings(_settings);

            //General
            RecordGameSessionEnded();

            if (_controlsProcessor != null)
            {
                _controlsProcessor.Dispose();
                _controlsProcessor = null;
            }

            //Window
            if (_foregroundWindowWatcher != null)
            {
                _foregroundWindowWatcher.Dispose();
                _foregroundWindowWatcher = null;
            }

            //Menu
            if (_settingsMenu != null)
            {
                _settingsMenu = null;
            }

            //Features
            if (_aiming != null)
            {
                _aiming.Dispose();
                _aiming = null;
            }

            if (_extendedView != null)
            {
                _extendedView.Dispose();
                _extendedView = null;
            }

            //Hids
            if (_controllerEmulation != null)
            {
                _controllerEmulation.Enabled = false;
                _controllerEmulation.RemoveHooks();
                _controllerEmulation = null;
            }

            if (_tobiiTracker != null)
            {
                _tobiiTracker.Dispose();
                _tobiiTracker = null;
            }
            Debug.Log("End ShutDown");
        }
Exemplo n.º 9
0
 public RadialMenu(ControllerEmulation controllerEmulation)
 {
     _controllerEmulation          = controllerEmulation;
     _lastRadialMenuRegion         = -1;
     _newRadialMenuRegionStopwatch = new Stopwatch();
 }
Exemplo n.º 10
0
        public Gta5EyeTracking()
        {
            Util.Log("Begin Initialize");

            //Disposing
            _shutDownRequestedEvent = new ManualResetEvent(false);

            //Settings
            _settingsStorage = new SettingsStorage();
            _settings        = _settingsStorage.LoadSettings();

            //Statistics
            var version       = Assembly.GetExecutingAssembly().GetName().Version;
            var versionString = version.Major + "." + version.Minor + "." + version.Build;

            _googleAnalyticsApi = new GoogleAnalyticsApi("UA-68420530-1", _settings.UserGuid, "GTA V Eye Tracking Mod", "gta5eyetracking", versionString);

            //Gaze
            _aspectRatio = 1;
            _host        = new EyeXHost();
            _host.Start();
            _lightlyFilteredGazePointDataProvider       = _host.CreateGazePointDataStream(GazePointDataMode.LightlyFiltered);
            _lightlyFilteredGazePointDataProvider.Next += NewGazePoint;
            _lastGazeTime = DateTime.UtcNow;

            //Menu
            _menuPool       = new MenuPool();
            _settingsMenu   = new SettingsMenu(_menuPool, _settings);
            _deadzoneEditor = new DeadzoneEditor(_settings, _settingsMenu);
            _settingsMenu.ShutDownRequested += SettingsMenuOnShutDownRequested;

            _introScreen = new IntroScreen(_menuPool, _settings);
            _introScreen.ShutDownRequested += SettingsMenuOnShutDownRequested;

            //Debug
            _debugGazeVisualization = new DotCrosshair(Color.FromArgb(220, 255, 0, 0), Color.FromArgb(220, 0, 255, 255));
            _debugOutput            = new DebugOutput();

            //Hids
            _mouseEmulation      = new MouseEmulation();
            _controllerEmulation = new ControllerEmulation();

            //Features
            _animationHelper       = new AnimationHelper();
            _aiming                = new Aiming(_settings, _animationHelper);
            _freelook              = new Freelook(_controllerEmulation, _mouseEmulation, _settings);
            _radialMenu            = new RadialMenu(_controllerEmulation);
            _pedestrianInteraction = new PedestrianInteraction(_settings);

            //Window
            _foregroundWindowWatcher = new ForegroundWindowWatcher();
            _foregroundWindowWatcher.ForegroundWindowChanged += ForegroundWindowWatcherOnForegroundWindowChanged;
            _isWindowForeground = _foregroundWindowWatcher.IsWindowForeground();

            //General
            _gazeProjector     = new GazeProjector(_settings);
            _controlsProcessor = new ControlsProcessor(_settings, _controllerEmulation, _aiming, _freelook, _radialMenu, _settingsMenu, _menuPool, _debugOutput);

            KeyDown += OnKeyDown;
            Tick    += OnTick;

            Util.Log("End Initialize");
        }
Exemplo n.º 11
0
        private void ShutDown()
        {
            _shutDownRequestFlag = true;
            KeyDown -= OnKeyDown;
            Tick    -= OnTick;

            _shutDownRequestedEvent.WaitOne(100);
            Util.Log("Begin ShutDown");
            _settingsStorage.SaveSettings(_settings);

            //General
            RecordGameSessionEnded();

            if (_controlsProcessor != null)
            {
                _controlsProcessor.Dispose();
                _controlsProcessor = null;
            }

            //Window
            if (_foregroundWindowWatcher != null)
            {
                _foregroundWindowWatcher.Dispose();
                _foregroundWindowWatcher = null;
            }

            //Menu
            if (_settingsMenu != null)
            {
                _settingsMenu.ShutDownRequested -= SettingsMenuOnShutDownRequested;
                _settingsMenu = null;
            }

            //Gaze
            if (_lightlyFilteredGazePointDataProvider != null)
            {
                _lightlyFilteredGazePointDataProvider.Next -= NewGazePoint;
                _lightlyFilteredGazePointDataProvider.Dispose();
                _lightlyFilteredGazePointDataProvider = null;
            }

            if (_host != null)
            {
                _host.Dispose();
                _host = null;
            }

            //Features
            if (_aiming != null)
            {
                _aiming.Dispose();
                _aiming = null;
            }

            if (_freelook != null)
            {
                _freelook.Dispose();
                _freelook = null;
            }

            //Hids
            if (_controllerEmulation != null)
            {
                _controllerEmulation.Enabled = false;
                _controllerEmulation.RemoveHooks();
                _controllerEmulation = null;
            }
            Util.Log("End ShutDown");
        }