Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This is what I got:
- package(body(Qweyboard.Emulation is))
- Return_Combo(: Key_Sets.Set)
- Backspace_Combo(: Key_Sets.Set)
- task(body(Timer_Task(is)))
- Next_Deadline(: RT.Time)
- loop
- Softboard.Get_Deadline (Next_Deadline)
- while Next_Deadline;:
- Softboard.Timeout
- end_loop
- protected(body(Softboard(is)))
- def Configure(Settings: Any):
- Current_Timeout(= Settings.Timeout)
- def Handle(Event: Any):
- Log.Chat ("[Qweyboard] Handling key event")
- (Deadline(= RT.Clock) + RT.Milliseconds (500))
- if Event.Key = SUSP:
- Last_Output(= (Variant => Nothing))
- Commit
- else
- if Event.Key_Event_Variant is:
- if Key_Press(=>):
- Pressed.Include (Event.Key)
- if Key_Release(=>):
- Pressed.Exclude (Event.Key)
- declare
- Special_Used(: Boolean = False)
- if Released.Is_Empty and Pressed.Is_Empty:
- if Event.Key = NOSP:
- Last_Output(= (Syllable, To_Unbounded(" "), False))
- Output_Backend.Output.Enter (From_Unbounded (Last_Output.Text), Last_Output.Continues_Word)
- Special_Used(= True)
- elif Event.Key = RO:
- Last_Output(= (Syllable, To_Unbounded("."), True))
- Output_Backend.Output.Enter (From_Unbounded (Last_Output.Text), Last_Output.Continues_Word)
- Special_Used(= True)
- elif Event.Key = RJ:
- Last_Output(= (Syllable, To_Unbounded(("), "), True))
- Output_Backend.Output.Enter (From_Unbounded (Last_Output.Text), Last_Output.Continues_Word)
- Special_Used(= True)
- end_if
- end_if
- if not(Special_Used):
- Released.Include (Event.Key)
- end_if
- def Log_Board(Pressed: Any, Released: Any):
- pass
- if RT.Clock < Deadline(is):
- # C-style for loop - converted to while
- while True:
- pass
- Time(= Deadline)
- end_loop
- def Timeout():
- if Deadline < RT.Clock:
- Log.Chat ("[Qweyboard] Deadline passed, committing")
- Commit
- def Commit():
- Result(: Unbounded_Wide_Wide_String)
- use(type(Key_Sets.Set))
- Result(= Languages.User_Language.Decode (Released))
- def Translate(Result: Any, Character_Maps.Lower_Case_Map: Any):
- if Released(= Return_Combo):
- Log.Warning ("[Qweyboard] Return press not implemented")
- else_if(Released(= Backspace_Combo))
- Log.Chat ("[Qweyboard] Received backspace combination CR-RC; erasing")
- end_if
- (else_if(Length(Result)) > 0)
- Output_Backend.Output.Enter (From_Unbounded (Result), Released.Contains (NOSP))
- end_if
- Released.Clear
- def Erase():
- Pressed.Clear
- Released.Clear
- if Last_Output.Variant is:
- if Syllable(=>):
- if Last_Output.Continues_Word:
- Last_Output(= (Erase, Length(Last_Output.Text)))
- Output_Backend.Output.Erase (Last_Output.Amount)
- else:
- Last_Output.Continues_Word = True
- Output_Backend.Output.Erase (1)
- end_if
- if others(=>):
- Last_Output(= (Erase, 1))
- Output_Backend.Output.Erase (1)
- def Log_Board(Pressed: Any):
- Log.Info ("[Qweyboard] Pressed: [", Suffix = > ' ')
- # C-style for loop - converted to while
- while True:
- pass
- Log.Info (W (Softkey'Image (Key)), Suffix = > ' ')
- end_loop
- Log.Info ("]", Suffix = > ' ')
- Log.Info ("Released: [", Suffix = > ' ')
- # C-style for loop - converted to while
- while True:
- pass
- Log.Info (W (Softkey'Image (Key)), Suffix = > ' ')
- end_loop
- Log.Info ("]")
- Return_Combo.Insert (LZ)
- Return_Combo.Insert (RZ)
- Backspace_Combo.Insert (LC)
- Backspace_Combo.Insert (LR)
- Backspace_Combo.Insert (RR)
- Backspace_Combo.Insert (RC)
Advertisement
Add Comment
Please, Sign In to add comment