Beispiel #1
0
        //This method is run when the scrollStepTime raises an elapsed event. The method checks if the latest gaze coordinate from the user is out side the
        // deadZoneRect, if the coordinates are outside this zone the value is then passed to the calculate scroll speed method which returns and integer value of how
        // many mouse wheel clicks to scroll.
        private void scroll(object O, ElapsedEventArgs e)
        {
            int xScrollValue = 0;
            int yScrollValue = 0;

            //check if users gaze on X axis is greater the right bound deadZoneRect
            if (currentGazeLocationX > deadZoneRect.RightBound)
            {
                //Calculate how much to scroll
                xScrollValue = calculateScrollSpeed(currentGazeLocationX, deadZoneRect.RightBound, ValueNeverChange.SCREEN_SIZE.Width, ScrollScalarValue, false);
            }
            //check if users gaze on X axis is less than left bound of deadZoneRect
            if (currentGazeLocationX < deadZoneRect.LeftBound)
            {
                xScrollValue = calculateScrollSpeed(currentGazeLocationX, 0, deadZoneRect.LeftBound, ScrollScalarValue, true);
            }

            if (currentGazeLocationY > deadZoneRect.BottomBound)
            {
                yScrollValue = calculateScrollSpeed(currentGazeLocationY, deadZoneRect.BottomBound, ValueNeverChange.SCREEN_SIZE.Height, ScrollScalarValue, false);
            }
            if (currentGazeLocationY < deadZoneRect.TopBound)
            {
                yScrollValue = calculateScrollSpeed(currentGazeLocationY, 0, deadZoneRect.TopBound, ScrollScalarValue, true);
            }

            //only scroll is the value is greater than 0
            if (Math.Abs(xScrollValue) > 0 || Math.Abs(yScrollValue) > 0)
            {                                                         //pass amount to scroll in respective direction
                VirtualMouse.Scroll(yScrollValue, xScrollValue * -1); // xScrollValue * -1 is used to correct scroll direction on x axis
            }
        }
Beispiel #2
0
        //The action state is responsible for completing each action that must take place during each state
        public void Action()
        {
            switch (SystemFlags.currentState)
            {
            case SystemState.Wait:
                scrollWorker.stopScroll();
                if (SystemFlags.hasSelectedButtonColourBeenReset == false)
                {
                    toolbar.resetButtonsColor();
                    SystemFlags.hasSelectedButtonColourBeenReset = true;
                }
                break;

            case SystemState.ActionButtonSelected:
                scrollWorker.stopScroll();
                if (!SystemFlags.fixationRunning)
                {
                    fixationWorker.StartDetectingFixation();
                    SystemFlags.fixationRunning = true;
                }
                if (Program.readSettings.selectionFeedback)     //don't show the crosshair if selection feedback is off
                {
                    zoomer.Start();
                    zoomer.Show();
                    zoomer.CrossHairPos = fixationWorker.getXY();
                }
                break;

            case SystemState.Zooming:
                scrollWorker.stopScroll();
                fixationWorker.IsZoomerFixation(true);
                if (SystemFlags.shortCutKeyPressed)    //if a user defined click key is pressed
                {
                    fixationPoint = shortCutKeyWorker.GetXY();
                    SystemFlags.shortCutKeyPressed = false;
                }
                else
                {
                    fixationPoint = fixationWorker.getXY();    //get the location the user looked
                }
                magnifier.Timer.Enabled = true;
                // magnifier.UpdatePosition(fixationPoint);
                // Give the magnifier the point on screen to magnify
                magnifier.FixationPoint = fixationPoint;
                Point p1 = Utils.DividePoint(magnifier.Offset, magnifier.MagnifierDivAmount());
                Point p2 = Utils.DividePoint(magnifier.SecondaryOffset, magnifier.MagnifierDivAmount());

                Point o = Utils.SubtractPoints(p1, p2);

                zoomer.Offset = o;                        // This initiate's the timer for drawing of the user feedback image
                zoomer.Start();
                zoomer.Show();
                zoomer.CrossHairPos = magnifier.GetLookPosition();

                //disable neccesary flags
                SystemFlags.hasGaze         = false;
                SystemFlags.fixationRunning = false;
                break;

            case SystemState.ZoomWait:    //waiting for user to fixate
                if (!SystemFlags.fixationRunning)
                {
                    fixationWorker.StartDetectingFixation();
                    SystemFlags.fixationRunning = true;
                }
                zoomer.CrossHairPos = magnifier.GetLookPosition();
                //SetZoomerOffset();
                break;

            case SystemState.ApplyAction:     //the fixation on the zoom lens has been detected
                fixationPoint = fixationWorker.getXY();

                //SetZoomerOffset();

                fixationPoint.X += zoomer.Offset.X;
                fixationPoint.Y += zoomer.Offset.Y;

                fixationPoint = magnifier.GetLookPosition();
                zoomer.ResetZoomLens();    //hide the lens
                                           //  MessageBox.Show(magnifier.SecondaryOffset.X + " " + magnifier.SecondaryOffset.Y);
                                           //Set the magnification factor back to initial value
                                           // This is done so that a "dynamic zoom in" feature can be
                                           // implemented in the future
                magnifier.ResetZoomValue();
                magnifier.Stop();


                //execute the appropriate action
                if (SystemFlags.actionToBePerformed == ActionToBePerformed.LeftClick)
                {
                    VirtualMouse.LeftMouseClick(fixationPoint.X, fixationPoint.Y);
                }
                else if (SystemFlags.actionToBePerformed == ActionToBePerformed.RightClick)
                {
                    VirtualMouse.RightMouseClick(fixationPoint.X, fixationPoint.Y);
                }
                else if (SystemFlags.actionToBePerformed == ActionToBePerformed.DoubleClick)
                {
                    VirtualMouse.LeftDoubleClick(fixationPoint.X, fixationPoint.Y);
                }
                else if (SystemFlags.actionToBePerformed == ActionToBePerformed.Scroll)
                {
                    SystemFlags.currentState = SystemState.ScrollWait;
                    SystemFlags.scrolling    = true;
                    VirtualMouse.SetCursorPos(fixationPoint.X, fixationPoint.Y);
                    scrollWorker.StartScroll();
                }
                else if (SystemFlags.actionToBePerformed == ActionToBePerformed.MicInput)
                {
                    if (Program.readSettings.micInput != Constants.KEY_FUNCTION_UNASSIGNED_MESSAGE)
                    {
                        if (!micIsOn)
                        {
                            VirtualMouse.LeftMouseClick(fixationPoint.X, fixationPoint.Y);
                            SendKeys.Send(Program.readSettings.micInput);
                            SystemFlags.hasSelectedButtonColourBeenReset = true;
                            micIsOn = true;
                        }
                        else
                        {
                            SendKeys.Send(Program.readSettings.micInputOff);
                            SystemFlags.hasSelectedButtonColourBeenReset = false;
                            micIsOn = false;
                        }
                    }
                }
                fixationWorker = new FixationDetection();
                break;
            }
        }
Beispiel #3
0
        //The action state is responsible for completing each action that must take place during each state
        public void Action()
        {
            switch (SystemFlags.currentState)
            {
            case SystemState.Wait:
                if (SystemFlags.hasSelectedButtonColourBeenReset == false)
                {
                    toolbar.resetButtonsColor();
                    SystemFlags.hasSelectedButtonColourBeenReset = true;
                }
                break;

            case SystemState.ActionButtonSelected:
                scrollWorker.stopScroll();
                if (!SystemFlags.fixationRunning)
                {
                    fixationWorker.StartDetectingFixation();
                    SystemFlags.fixationRunning = true;
                }
                break;

            case SystemState.Zooming:
                if (SystemFlags.shortCutKeyPressed)    //if a user defined click key is pressed
                {
                    fixationPoint = shortCutKeyWorker.GetXY();
                    SystemFlags.shortCutKeyPressed = false;
                }
                else
                {
                    fixationPoint = fixationWorker.getXY();    //get the location the user looked
                }
                //zoomLens setup
                zoomer.determineDesktopLocation(fixationPoint);
                //checking if the user looked in a corner
                corner = zoomer.checkCorners(fixationPoint);
                //Checking if a user looked near an edge
                edge       = zoomer.checkEdge();
                cornerBool = false;
                edgeBool   = false;
                if (corner != Corner.NoCorner)                //if the user looked in a corner
                {
                    zoomer.setZoomLensPositionCorner(corner); //set the lens into the corner
                    cornerBool = true;
                }
                else if (edge != Edge.NoEdge)                            //if there is no corner and the user looked near the edge of the screen
                {
                    zoomer.setZoomLensPositionEdge(edge, fixationPoint); //set lens to edge
                    edgeBool = true;
                }

                zoomer.TakeScreenShot();              //This is taking the screenshot that will be zoomed in on
                zoomer.CreateZoomLens(fixationPoint); //create a zoom lens at this location
                //disable neccesary flags
                SystemFlags.gaze            = false;
                SystemFlags.fixationRunning = false;
                break;

            case SystemState.ZoomWait:    //waiting for user to fixate
                if (!SystemFlags.fixationRunning)
                {
                    fixationWorker.StartDetectingFixation();
                    SystemFlags.fixationRunning = true;
                }
                break;

            case SystemState.ApplyAction:     //the fixation on the zoom lens has been detected

                fixationPoint = fixationWorker.getXY();
                zoomer.ResetZoomLens();                                   //hide the lens
                fixationPoint = zoomer.TranslateGazePoint(fixationPoint); //translate the form coordinates to the desktop

                //Checking if the user has zoomed in on an edge or a corner and offsetting the zoomed in click calculations to account for the
                //different location of the screenshot
                //e.g when a corner is selected the program zooms into the corner instead of the middle of the zoomlens, this means that for the final point to be accurate
                //there must be an offset to account for the different zoom direction.
                if (cornerBool)
                {
                    fixationPoint = zoomer.cornerOffset(corner, fixationPoint);
                }
                else if (edgeBool)
                {
                    fixationPoint = zoomer.edgeOffset(edge, fixationPoint);
                }
                if (fixationPoint.X == -1)    //check if it's out of bounds
                {
                    EnterWaitState();
                }
                else
                {
                    //execute the appropriate action
                    if (SystemFlags.actionToBePerformed == ActionToBePerformed.LeftClick)
                    {
                        VirtualMouse.LeftMouseClick(fixationPoint.X, fixationPoint.Y);
                    }
                    else if (SystemFlags.actionToBePerformed == ActionToBePerformed.RightClick)
                    {
                        VirtualMouse.RightMouseClick(fixationPoint.X, fixationPoint.Y);
                    }
                    else if (SystemFlags.actionToBePerformed == ActionToBePerformed.DoubleClick)
                    {
                        VirtualMouse.LeftDoubleClick(fixationPoint.X, fixationPoint.Y);
                    }
                    else if (SystemFlags.actionToBePerformed == ActionToBePerformed.Scroll)
                    {
                        SystemFlags.currentState = SystemState.ScrollWait;
                        SystemFlags.scrolling    = true;
                        VirtualMouse.SetCursorPos(fixationPoint.X, fixationPoint.Y);
                        scrollWorker.StartScroll();
                    }
                }
                break;
            }
        }