@@ -64,22 +64,39 @@ ProcessResult ChordComposer::ProcessFunctionKey(const KeyEvent& key_event) {
64
64
return kNoop ;
65
65
}
66
66
67
+ // Note: QWERTY layout only.
68
+ static const char map_to_base_layer[] = {
69
+ " 1'3457'908=,-./"
70
+ " 0123456789;;,=./"
71
+ " 2abcdefghijklmno"
72
+ " pqrstuvwxyz[\\ ]6-"
73
+ " `abcdefghijklmno"
74
+ " pqrstuvwxyz[\\ ]`"
75
+ };
76
+
77
+ inline static int get_base_layer_key_code (const KeyEvent& key_event) {
78
+ int ch = key_event.keycode ();
79
+ bool is_shift = key_event.shift ();
80
+ return (is_shift && ch >= 0x20 && ch <= 0x7e )
81
+ ? map_to_base_layer[ch - 0x20 ] : ch;
82
+ }
83
+
67
84
ProcessResult ChordComposer::ProcessChordingKey (const KeyEvent& key_event) {
68
85
bool chording = !chord_.empty ();
69
- if (key_event.shift () || key_event. ctrl () || key_event.alt ()) {
86
+ if (key_event.ctrl () || key_event.alt ()) {
70
87
raw_sequence_.clear ();
71
88
ClearChord ();
72
89
return chording ? kAccepted : kNoop ;
73
90
}
74
- bool is_key_up = key_event.release ();
75
- int ch = key_event.keycode ();
91
+ int ch = get_base_layer_key_code (key_event);
76
92
// non chording key
77
93
if (std::find (chording_keys_.begin (),
78
94
chording_keys_.end (),
79
95
KeyEvent{ch, 0 }) == chording_keys_.end ()) {
80
96
return chording ? kAccepted : kNoop ;
81
97
}
82
98
// chording key
99
+ bool is_key_up = key_event.release ();
83
100
if (is_key_up) {
84
101
if (pressed_.erase (ch) != 0 && pressed_.empty ()) {
85
102
FinishChord ();
@@ -95,6 +112,9 @@ ProcessResult ChordComposer::ProcessChordingKey(const KeyEvent& key_event) {
95
112
}
96
113
97
114
ProcessResult ChordComposer::ProcessKeyEvent (const KeyEvent& key_event) {
115
+ if (engine_->context ()->get_option (" ascii_mode" )) {
116
+ return kNoop ;
117
+ }
98
118
if (pass_thru_) {
99
119
return ProcessFunctionKey (key_event);
100
120
}
0 commit comments