Ejemplo n.º 1
0
        private IInputService CreateInputService(
            IKeyStateService keyStateService,
            IDictionaryService dictionaryService,
            IAudioService audioService,
            ICalibrationService calibrationService,
            ICapturingStateManager capturingStateManager,
            List <INotifyErrors> errorNotifyingServices)
        {
            Log.Info("Creating InputService.");

            //Instantiate point source
            IPointSource pointSource;

            switch (Settings.Default.PointsSource)
            {
            case PointsSources.GazeTracker:
                pointSource = new GazeTrackerSource(
                    Settings.Default.PointTtl,
                    Settings.Default.GazeTrackerUdpPort,
                    new Regex(Settings.Default.GazeTrackerUdpRegex));
                break;

            case PointsSources.TheEyeTribe:
                var theEyeTribePointService = new TheEyeTribePointService();
                errorNotifyingServices.Add(theEyeTribePointService);
                pointSource = new PointServiceSource(
                    Settings.Default.PointTtl,
                    theEyeTribePointService);
                break;

            case PointsSources.TobiiEyeX:
            case PointsSources.TobiiRex:
            case PointsSources.TobiiPcEyeGo:
                var tobiiEyeXPointService       = new TobiiEyeXPointService();
                var tobiiEyeXCalibrationService = calibrationService as TobiiEyeXCalibrationService;
                if (tobiiEyeXCalibrationService != null)
                {
                    tobiiEyeXCalibrationService.EyeXHost = tobiiEyeXPointService.EyeXHost;
                }
                errorNotifyingServices.Add(tobiiEyeXPointService);
                pointSource = new PointServiceSource(
                    Settings.Default.PointTtl,
                    tobiiEyeXPointService);
                break;

            case PointsSources.MousePosition:
                pointSource = new MousePositionSource(
                    Settings.Default.PointTtl);
                break;

            default:
                throw new ArgumentException("'PointsSource' settings is missing or not recognised! Please correct and restart OptiKey.");
            }

            //Instantiate key trigger source
            ITriggerSource keySelectionTriggerSource;

            switch (Settings.Default.KeySelectionTriggerSource)
            {
            case TriggerSources.Fixations:
                keySelectionTriggerSource = new KeyFixationSource(
                    Settings.Default.KeySelectionTriggerFixationLockOnTime,
                    Settings.Default.KeySelectionTriggerFixationResumeRequiresLockOn,
                    Settings.Default.KeySelectionTriggerFixationCompleteTime,
                    Settings.Default.KeySelectionTriggerIncompleteFixationTtl,
                    pointSource.Sequence);
                break;

            case TriggerSources.KeyboardKeyDownsUps:
                keySelectionTriggerSource = new KeyboardKeyDownUpSource(
                    Settings.Default.KeySelectionTriggerKeyboardKeyDownUpKey,
                    pointSource.Sequence);
                break;

            case TriggerSources.MouseButtonDownUps:
                keySelectionTriggerSource = new MouseButtonDownUpSource(
                    Settings.Default.KeySelectionTriggerMouseDownUpButton,
                    pointSource.Sequence);
                break;

            default:
                throw new ArgumentException(
                          "'KeySelectionTriggerSource' setting is missing or not recognised! Please correct and restart OptiKey.");
            }

            //Instantiate point trigger source
            ITriggerSource pointSelectionTriggerSource;

            switch (Settings.Default.PointSelectionTriggerSource)
            {
            case TriggerSources.Fixations:
                pointSelectionTriggerSource = new PointFixationSource(
                    Settings.Default.PointSelectionTriggerFixationLockOnTime,
                    Settings.Default.PointSelectionTriggerFixationCompleteTime,
                    Settings.Default.PointSelectionTriggerLockOnRadiusInPixels,
                    Settings.Default.PointSelectionTriggerFixationRadiusInPixels,
                    pointSource.Sequence);
                break;

            case TriggerSources.KeyboardKeyDownsUps:
                pointSelectionTriggerSource = new KeyboardKeyDownUpSource(
                    Settings.Default.PointSelectionTriggerKeyboardKeyDownUpKey,
                    pointSource.Sequence);
                break;

            case TriggerSources.MouseButtonDownUps:
                pointSelectionTriggerSource = new MouseButtonDownUpSource(
                    Settings.Default.PointSelectionTriggerMouseDownUpButton,
                    pointSource.Sequence);
                break;

            default:
                throw new ArgumentException(
                          "'PointSelectionTriggerSource' setting is missing or not recognised! "
                          + "Please correct and restart OptiKey.");
            }

            var inputService = new InputService(keyStateService, dictionaryService, audioService, capturingStateManager,
                                                pointSource, keySelectionTriggerSource, pointSelectionTriggerSource);

            inputService.RequestSuspend(); //Pause it initially
            return(inputService);
        }
Ejemplo n.º 2
0
        private static IInputService CreateInputService()
        {
            Log.Info("Creating InputService.");

            //Instantiate point source
            IPointSource pointSource;

            switch (Settings.Default.PointsSource)
            {
            case PointsSources.GazeTracker:
                pointSource = new GazeTrackerSource(
                    Settings.Default.PointTtl,
                    Settings.Default.GazeTrackerUdpPort,
                    new Regex(GazeTrackerUdpRegex));
                break;

            case PointsSources.MousePosition:
                pointSource = new MousePositionSource(
                    Settings.Default.PointTtl);
                break;

            case PointsSources.TheEyeTribe:
                var theEyeTribePointService = new TheEyeTribePointService();
                pointSource = new PointServiceSource(
                    Settings.Default.PointTtl,
                    theEyeTribePointService);
                break;

            case PointsSources.TobiiEyeX:
            case PointsSources.TobiiRex:
            case PointsSources.TobiiPcEyeGo:
                var tobiiEyeXPointService = new TobiiEyeXPointService();
                pointSource = new PointServiceSource(
                    Settings.Default.PointTtl,
                    tobiiEyeXPointService);
                break;

            case PointsSources.VisualInteractionMyGaze:
                var myGazePointService = new MyGazePointService();
                pointSource = new PointServiceSource(
                    Settings.Default.PointTtl,
                    myGazePointService);
                break;

            default:
                throw new ArgumentException("'PointsSource' settings is missing or not recognised! Please correct and restart OptiKids.");
            }

            //Instantiate key trigger source
            ITriggerSource keySelectionTriggerSource;

            switch (Settings.Default.KeySelectionTriggerSource)
            {
            case TriggerSources.Fixations:
                keySelectionTriggerSource = new KeyFixationSource(
                    Settings.Default.KeySelectionTriggerFixationLockOnTime,
                    Settings.Default.KeySelectionTriggerFixationResumeRequiresLockOn,
                    Settings.Default.KeySelectionTriggerFixationCompleteTime,
                    Settings.Default.KeySelectionTriggerIncompleteFixationTtl,
                    pointSource.Sequence);
                break;

            case TriggerSources.KeyboardKeyDownsUps:
                keySelectionTriggerSource = new KeyboardKeyDownUpSource(
                    Settings.Default.KeySelectionTriggerKeyboardKeyDownUpKey,
                    pointSource.Sequence);
                break;

            case TriggerSources.MouseButtonDownUps:
                keySelectionTriggerSource = new MouseButtonDownUpSource(
                    Settings.Default.KeySelectionTriggerMouseDownUpButton,
                    pointSource.Sequence);
                break;

            default:
                throw new ArgumentException(
                          "'KeySelectionTriggerSource' setting is missing or not recognised! Please correct and restart OptiKids.");
            }

            var inputService = new InputService(pointSource, keySelectionTriggerSource);

            inputService.RequestSuspend(); //Pause it initially
            return(inputService);
        }