State Manager - accessibilitysoftwarehub/OpenSourceWindowsGazeControl GitHub Wiki
The State Manager is the central control of the application.
First UpdateState()
is called, this method will only switch states, no actual actions will be called.
The current state is saved under SystemFlags.currentstate
, the UpdateState()
methods checks what state the program is in and acts accordingly.
If the state is:
SystemState.Wait
It will check if SystemFlags.actionButtonSelected
is true, or SystemFlags.shortcutKeyPressed
is true.
If SystemFlags.actionButtonSelected
is true, it will change the current state to SystemState.ActionButtonSelected
.
If SystemFlags.shortCutKeyPressed
is true, it will change the current state to SystemState.Zooming
.
SystemState.ActionButtonSelected
If SystemFlags.hasGaze
is true, it will change the current state to SystemState.Zooming
.
If SystemFlags.timeOut
is true, it will call EnterWaitState()
, which changes the current state to SystemFlags.Wait
.
SystemState.Zooming
If the current action is ActionToBePerformed.Scroll
is will instantly apply the scroll action and change the current state to SystemState.ApplyAction
.
Otherwise it will change the current state to SystemState.ZoomWait
to await a fixation.
SystemState.ZoomWait
This state waits for a fixation, when a fixation is found SystemFlags.hasGaze
is true and the state will change to SystemState.ApplyAction
.
If there is no fixation and SystemFlags.timeOut
is true, it will call EnterWaitState()
, which changes the current state to SystemFlags.Wait
.
SystemState.ScrollWait
This is the state the program is in when scrolling, if !SystemFlags.scrolling
is not true, it will enter the wait state
SystemState.ApplyAction
This is the state that will actually do an action, it will set the appropriate flags and then enter the wait state.
Next, Action()
is called. This does the action required by the current state.
This will check the current state, if the state is:
SystemState.Wait
The application will make sure the scroll control is off and all buttons and not lit.
SystemState.ActionButtonSelected
This will start the fixation detection and show the crosshair on the screen where the user is looking
SystemState.Zooming
This will enable the magnification window and draw the crosshair on it.
SystemState.ZoomWait
This will update the crosshair location and make sure the fixation detection is running
SystemState.ApplyAction
This is where the actions are done, it will check what the current SystemFlags.actionToBePerformed
is and do the appropriate action.
Other methods used:
CreateMagnifier()
This returns a new magnifier that will be used for fine-grained selection, currently the default is ZoomMagnifierCentered
, which puts the magnifier in the middle of the screen.
RefreshZoom()
This creates a new magnifier, used when turning off magnifier to make sure it is no longer visible.
EnterWaitState()
Utility method for settings the appropriate flags when changing into the SystemState.Wait
state.