void KeyControl() { if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) { if (Input.GetKeyDown(KeyCode.Alpha3)) { lexicon.ChangePhrase(-3); } } if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { if (Input.GetKeyDown(KeyCode.RightArrow)) { server.Send("TouchScreen Keyboard Width", "+"); } if (Input.GetKeyDown(KeyCode.LeftArrow)) { server.Send("TouchScreen Keyboard Width", "-"); } if (Input.GetKeyDown(KeyCode.D)) { debugOn ^= true; info.Log("Debug", debugOn.ToString()); lexicon.SetDebugDisplay(debugOn); } if (Input.GetKeyDown(KeyCode.M)) { parameter.ChangeMode(); } if (Input.GetKeyDown(KeyCode.L)) { parameter.ChangeLocationFormula(); } if (Input.GetKeyDown(KeyCode.N)) { lexicon.ChangePhrase(); } if (Input.GetKeyDown(KeyCode.C)) { lexicon.ChangeCandidatesChoose(true); } if (Input.GetKeyDown(KeyCode.R)) { server.Send("Change Ratio", ""); server.Send("Get Keyboard Size", ""); } if (Input.GetKeyDown(KeyCode.T)) { parameter.ChangeRatio(); lexicon.CalcKeyLayout(); lexicon.CalcLexicon(); } if (Input.GetKeyDown(KeyCode.Alpha1)) { HideDisplay(); info.Clear(); if (Parameter.userStudy == Parameter.UserStudy.Basic) { Parameter.userStudy = Parameter.UserStudy.Study1_Train; lexicon.ChangePhrase(); textManager.HighLight(-100); info.Log("Phrase", "Warmup"); return; } Parameter.userStudy = Parameter.UserStudy.Study1; lexicon.ChangePhrase(phraseID); SendPhraseMessage(); textManager.HighLight(-100); info.Log("Phrase", (phraseID + 1).ToString() + "/40"); server.Send("Get Keyboard Size", ""); } if (Input.GetKeyDown(KeyCode.Alpha2)) { HideDisplay(); Parameter.userStudy = Parameter.UserStudy.Study2; lexicon.SetPhraseList(Parameter.userStudy); lexicon.ChangePhrase(phraseID); SendPhraseMessage(); info.Clear(); info.Log("Mode", Parameter.mode.ToString()); blockID = blockID % 4 + 1; info.Log("Block", blockID.ToString() + "/4"); info.Log("Phrase", (phraseID % 10 + 1).ToString() + "/10"); } } if (Input.GetKeyDown(KeyCode.UpArrow)) { if (Input.GetKey(KeyCode.E)) { parameter.ChangeEndOffset(0.1f); } if (Input.GetKey(KeyCode.R)) { parameter.ChangeRadius(0.1f); } if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { server.Send("TouchScreen Keyboard Height", "+"); } if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { server.Send("TouchScreen Keyboard Size", "+"); server.Send("Get Keyboard Size", ""); } } if (Input.GetKeyDown(KeyCode.DownArrow)) { if (Input.GetKey(KeyCode.E)) { parameter.ChangeEndOffset(-0.1f); } if (Input.GetKey(KeyCode.R)) { parameter.ChangeRadius(-0.1f); } if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { server.Send("TouchScreen Keyboard Height", "-"); } if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { server.Send("TouchScreen Keyboard Size", "-"); server.Send("Get Keyboard Size", ""); } } if (Input.GetKeyDown(KeyCode.Space)) { switch (Parameter.userStudy) { case Parameter.UserStudy.Basic: lexicon.ChangePhrase(); break; case Parameter.UserStudy.Study1_Train: lexicon.ChangePhrase(); textManager.HighLight(-100); break; case Parameter.UserStudy.Study1: if (!textManager.InputNumberCorrect() && !(Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))) { return; } server.Send("Study1 End Phrase", Parameter.mode.ToString()); phraseID++; if (phraseID % 10 == 0) { Parameter.userStudy = Parameter.UserStudy.Study1_Train; lexicon.ChangePhrase(); textManager.HighLight(-100); info.Log("Phrase", "<color=red>Rest</color>"); return; } lexicon.ChangePhrase(phraseID); SendPhraseMessage(); textManager.HighLight(-100); info.Log("Phrase", (phraseID + 1).ToString() + "/40"); break; case Parameter.UserStudy.Study2: if (!textManager.InputNumberCorrect() && !(Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift))) { return; } FinishStudy2Phrase(); break; } } if (Input.GetKeyDown(KeyCode.Backspace)) { if (Parameter.userStudy == Parameter.UserStudy.Study1 || Parameter.userStudy == Parameter.UserStudy.Study2) { server.Send("Backspace", ""); } if (Parameter.userStudy == Parameter.UserStudy.Study1 || Parameter.userStudy == Parameter.UserStudy.Study1_Train) { textManager.HighLight(-100); } if (Parameter.userStudy == Parameter.UserStudy.Study2 || Parameter.userStudy == Parameter.UserStudy.Basic) { lexicon.Clear(); } } }
public void End(float x, float y) { inGesture = false; //Adjust Coor if (Parameter.mode == Parameter.Mode.FixStart || (Lexicon.useRadialMenu && chooseCandidate)) { x = x - beginPoint.x + StartPointRelative.x; y = y - beginPoint.y + StartPointRelative.y; } if (Parameter.mode == Parameter.Mode.FixStart) { cursor.GetComponent <TrailRendererHelper>().Reset(); cursor.transform.localPosition = new Vector3(StartPointRelative.x * Parameter.keyboardWidth, StartPointRelative.y * Parameter.keyboardHeight, -0.2f); } SetAreaDisplay(x, y, false); if (!Lexicon.useRadialMenu && chooseCandidate) { int choose = CandicateListChoose(x, y); if (choose == 0 && listExpanded) { ExpandList(false); server.Send("Cancel", ""); return; } string word = lexicon.Accept(ref choose); if (Parameter.userStudy == Parameter.UserStudy.Study2) { server.Send("Accept", choose.ToString() + " " + word); } ExpandList(false, true); if (choose > 0) { chooseCandidate = false; return; } } if (Vector2.Distance(new Vector2(x, y), stroke[stroke.Count - 1]) > eps) { stroke.Add(new Vector2(x, y)); } if (Parameter.userStudy == Parameter.UserStudy.Study1 || Parameter.userStudy == Parameter.UserStudy.Study1_Train) { textManager.HighLight(+1); return; } if (chooseCandidate) { if (Lexicon.useRadialMenu) { int choose = RadialMenuChoose(x, y); if (choose == 5) { CancelRadialChoose(); } else if (choose >= 0) { string word = lexicon.Accept(ref choose); if (Parameter.userStudy == Parameter.UserStudy.Study2) { server.Send("Accept", choose.ToString() + " " + word); } chooseCandidate = false; lexicon.SetRadialMenuDisplay(false); } else { server.Send("NextCandidatePanel", ""); lexicon.NextCandidatePanel(); } return; } } if ((x <= -0.54f && length - (-0.5f - x) <= 1.0f) || x <= -0.74f) { if (Parameter.userStudy == Parameter.UserStudy.Study2) { server.Send("Delete", "LeftSwipe"); } lexicon.Delete(); chooseCandidate = false; return; } if ((x >= 0.54f && length - (x - 0.5f) <= 1.0f) || x >= 0.74f) { chooseCandidate = false; if (Parameter.userStudy == Parameter.UserStudy.Basic) { if (!chooseCandidate && textManager.InputNumberCorrect() && textManager.GetWords()[0] != "Thanks") { lexicon.ChangePhrase(); } } else if (Parameter.userStudy == Parameter.UserStudy.Study2) { if (!chooseCandidate && textManager.InputNumberCorrect()) { pcControl.FinishStudy2Phrase(); } } return; } if (Lexicon.isCut) { int l = 0, r = stroke.Count - 1; while (OutKeyboard(stroke[l]) && l < r) { ++l; } while (OutKeyboard(stroke[r]) && l < r) { --r; } if (l < r) { stroke.RemoveRange(r + 1, stroke.Count - r - 1); stroke.RemoveRange(0, l); } } for (int i = 0; i < stroke.Count; ++i) { stroke[i] = new Vector2(stroke[i].x * Parameter.keyboardWidth, stroke[i].y * Parameter.keyboardHeight); } Lexicon.Candidate[] candidates = lexicon.Recognize(stroke.ToArray()); chooseCandidate = true; if (Lexicon.useRadialMenu) { cursor.transform.localPosition = new Vector3(StartPointRelative.x * Parameter.keyboardWidth, StartPointRelative.y * Parameter.keyboardHeight, -0.2f); cursor.GetComponent <TrailRendererHelper>().Reset(); lexicon.SetRadialMenuDisplay(true); } lexicon.SetCandidates(candidates); string msg = ""; for (int i = 0; i < candidates.Length; ++i) { if (i < candidates.Length - 1) { msg += candidates[i].word + ","; } else { msg += candidates[i].word; } } server.Send("Candidates", msg); }