private void StartScan() { KillScan(); PhysicalSwitch.AssignSwitch(0, ctrSwitch0.Type, ctrSwitch0.Parameter); if (rdoTwo.Checked) { PhysicalSwitch.AssignSwitch(1, ctrSwitch1.Type, ctrSwitch1.Parameter); } else { PhysicalSwitch.AssignSwitch(1, PhysicalSwitch.Types.Null, 0); } m_Engine = Engine.Create((Engine.Methods)cmbMethods.SelectedValue); // note must be created before Logical bit to get switch count, but Initialised after the switches are available pnlTest.Engine = m_Engine; if (rdoTwo.Checked) { Logical.CreateSwitches(Logical.Number.Two, m_Engine); } else if (m_Engine.NumberSwitchInputs == 2) { Logical.CreateSwitches(Logical.Number.ShortLong, m_Engine); } else { Logical.CreateSwitches(Logical.Number.One, m_Engine); } m_Engine.Initialise(); ctrDiagram.Construct(m_Engine); PhysicalSwitch.MasterSwitch = PhysicalSwitch.MasterModes.On; m_Engine.StartScanning(); }
private void AddParam(int param) { if (Type <= PhysicalSwitch.Types.Null) { return; } m_DisplayedParams.Add(param); cmbSwitch.Items.Add(PhysicalSwitch.GetParamDescription(Type, param)); }
public void Form1_Load(object sender, EventArgs e) { PhysicalSwitch.Initialise(); FillEngines(); m_Loaded = true; ctrSwitch0.Type = PhysicalSwitch.Types.Keyboard; ctrSwitch0.Parameter = (int)Keys.Space; ctrSwitch1.Type = PhysicalSwitch.Types.Keyboard; ctrSwitch1.Parameter = (int)Keys.Enter; cmbMethods.SelectedIndex = 1; }
public override void Initialise() { // unlike most engines this will also create switches PhysicalSwitch.AssignSwitch(0, PhysicalSwitch.Types.Pointer, (int)m_Method); if (m_Method == Methods.DwellAveragePointer) { Logical.CreateSwitches(Logical.Number.PassThrough, this); (PhysicalSwitch.Switch(0) as PointerDwellAverageSwitch).Engine = this; } else { Logical.CreateSwitches(m_Dwell ? Logical.Number.DwellOnly : Logical.Number.One, this); } base.Initialise(); // must be AFTER switches assigned }
/// <summary>Can safely be called when not scanning. Stops the scan engine and unhighlights all items</summary> public void StopScan() { KeySend.Instance.ReleaseAll(); PhysicalSwitch.MasterSwitch = PhysicalSwitch.MasterModes.Off; PhysicalSwitch.RemoveHotKey(Keys.R | Keys.Control, true); m_Blade?.SaveData(true); m_CurrentMove?.End(false); m_CurrentMove = null; EnsureCharacterHandlerRemoved(); StopCustomRepeat(); // does nowt if none StopContinuous(m_Continuous); // ditto SetEngine(null); PointerSwitch.View = null; IterateScriptable(i => SetItemState(i, ButtonShape.States.Normal)); Globals.Root.CurrentDocumentChanged -= DocumentChanged; }
public cfgSwitching() { PhysicalSwitch.Initialise(); // will be ignored if already done. Required for detect mechanism to work InitializeComponent(); Strings.Translate(this); TimingLabels = new[] { lblAcceptance, lblPostActivation, lblLongPress, lblScanTime, lblFirstRepeat, lblSubsequentRepeat, lblDwellSelect, lblCriticalReverse }; TimingControls = new[] { ctrTimingAcceptance, ctrTimingPostActivation, ctrTimingLongPress, ctrTimingScanTime, ctrTimingFirstRepeat, ctrTimingSubsequentRepeat, ctrTimingDwellTime, ctrTimingCriticalReverse }; foreach (Label lbl in TimingLabels) { Engine.Timings timing = (Engine.Timings)Convert.ToInt32(lbl.Tag); lbl.Text = Strings.Item("Switch_Timing_" + timing); } foreach (ctrEditTiming ctr in TimingControls) { ctr.UserChangedValue += ctrTiming_UserChangedValue; } }
private void frmRun_FormClosing(object sender, FormClosingEventArgs e) { // not called when reverting to user mode as the form is just hidden // rather only called if the user explicitly closes it - which must quit (the editor form will still exist hidden) //Debug.WriteLine(Switches.Switching.PhysicalSwitch.Switch(0).Type); if (e.CloseReason == CloseReason.UserClosing && (PhysicalSwitch.Switch(0)?.Type ?? PhysicalSwitch.Types.Null) == PhysicalSwitch.Types.Pointer) { this.TopMost = false; // if true the question won't be visible! var response = GUIUtilities.QuestionBox("[SAW_Run_CloseConfirm]", MessageBoxButtons.YesNo); this.TopMost = true; if (response != DialogResult.Yes) { e.Cancel = true; return; } } MainView.StopScan(); if (!Globals.Root.Closing) { Globals.Root.CloseApplication(); } }
public void StartScan() { // only called when run mode initially starts ResetBlade(); try { PointerSwitch.View = this; SetEngine(Switches.Engine.PrepareSwitchingFromConfig()); m_MouseInput = (m_Engine is PointerEngine); m_Engine.StartScanning(); PhysicalSwitch.AddHotKey(Keys.R | Keys.Control, () => { Globals.Root.ShowEditScreen(m_Document); }); Globals.Root.CurrentDocumentChanged += DocumentChanged; StartScanOnDocument(); } catch (Exception) when(!Globals.Root.IsDebug) { // if scan fails to start it could be in an inconsistent state if some parts of the above ran StopScan(); throw; } }
public void Construct(Engine engine) { // Builds the diagram based on the global lists in the switch classes Debug.Assert(engine.Initialised); Clear(); for (int index = 0; index <= 8; index++) // upper limit is arbitrary { PhysicalSwitch objSwitch = PhysicalSwitch.Switch(index); if (objSwitch != null) { AddItem(new PhysicalDisplay(index)); } } for (int index = 0; index <= 8; index++) // upper limit is arbitrary { Logical objSwitch = Logical.Switch(index); if (objSwitch != null) { AddItem(new LogicalDisplay(objSwitch, this)); } } AddItem(new EngineDisplay(engine, this)); Invalidate(); }
/// <summary>Creates the necessary switching objects from the config settings, and returns the engine object</summary> public static Engine PrepareSwitchingFromConfig() { int numberSwitches = Globals.Root.CurrentConfig.ReadInteger(Config.Number_Switches, 1); // only needed indirectly; the engine often is enough info, but a 2 switch engine can use 1 with long presses PhysicalSwitch.Initialise(); // will be ignored if already done var engine = Create((Methods)Globals.Root.CurrentConfig.ReadInteger(Config.Switch_Engine, (int)DefaultMethodForSwitches(numberSwitches))); PhysicalSwitch.ClearSwitches(); if (engine.NumberSwitchInputs >= 1) { PhysicalSwitch.AssignSwitchFromConfig(0); } if (engine.NumberSwitchInputs >= 2) { PhysicalSwitch.AssignSwitchFromConfig(1); } if (numberSwitches > 0) // for 0, mouse switch will do what is needed on initialise { if (numberSwitches == 2) { Logical.CreateSwitches(Logical.Number.Two, engine); } else if (engine.NumberSwitchInputs == 2) { Logical.CreateSwitches(Logical.Number.ShortLong, engine); } else { Logical.CreateSwitches(Logical.Number.One, engine); } } engine.Initialise(); return(engine); }
public PhysicalDisplay(int index) : base(PhysicalSwitch.Switch(index)) { m_Switch = PhysicalSwitch.Switch(index); }
public void Form1_FormClosing(object sender, FormClosingEventArgs e) { PhysicalSwitch.ClearSwitches(); m_Engine.Dispose(); }