-rw-r--r-- | inputmethods/kjumpx/keyboard.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/inputmethods/kjumpx/keyboard.cpp b/inputmethods/kjumpx/keyboard.cpp index 52a8bf4..3af6a78 100644 --- a/inputmethods/kjumpx/keyboard.cpp +++ b/inputmethods/kjumpx/keyboard.cpp | |||
@@ -1,479 +1,479 @@ | |||
1 | /**************************************************************************************94x78** | 1 | /**************************************************************************************94x78** |
2 | ** | 2 | ** |
3 | ** This file may be distributed and/or modified under the terms of the | 3 | ** This file may be distributed and/or modified under the terms of the |
4 | ** GNU General Public License version 2 as published by the Free Software | 4 | ** GNU General Public License version 2 as published by the Free Software |
5 | ** Foundation and appearing in the file LICENSE.GPL included in the | 5 | ** Foundation and appearing in the file LICENSE.GPL included in the |
6 | ** packaging of this file. | 6 | ** packaging of this file. |
7 | ** | 7 | ** |
8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 8 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 9 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
10 | ** | 10 | ** |
11 | *********************************************************************************************/ | 11 | *********************************************************************************************/ |
12 | #include "keyboard.h" | 12 | #include "keyboard.h" |
13 | 13 | ||
14 | #include <qpe/resource.h> | 14 | #include <qpe/resource.h> |
15 | 15 | ||
16 | //#include <iostream.h> | 16 | //#include <iostream.h> |
17 | 17 | ||
18 | 18 | ||
19 | static const int autorepeatDelaytime = 500; // ms | 19 | static const int autorepeatDelaytime = 500; // ms |
20 | static const int autorepeatRate = 20; // chars per second | 20 | static const int autorepeatRate = 20; // chars per second |
21 | 21 | ||
22 | static const int mod1x1 = 0; | 22 | static const int mod1x1 = 0; |
23 | static const int mod1x2 = 23; | 23 | static const int mod1x2 = 23; |
24 | static const int mod1w = mod1x2 - mod1x1; | 24 | static const int mod1w = mod1x2 - mod1x1; |
25 | 25 | ||
26 | static const int letterx1 = 27; | 26 | static const int letterx1 = 27; |
27 | static const int letterx2 = 129; | 27 | static const int letterx2 = 129; |
28 | static const int letterw = 17; | 28 | static const int letterw = 17; |
29 | static const int letterh = 14; | 29 | static const int letterh = 14; |
30 | 30 | ||
31 | static const int num1x1 = 130; | 31 | static const int num1x1 = 130; |
32 | static const int num1x2 = 137; | 32 | static const int num1x2 = 137; |
33 | static const int num1w = num1x2 - num1x1; | 33 | static const int num1w = num1x2 - num1x1; |
34 | 34 | ||
35 | static const int specialx1 = 138; | 35 | static const int specialx1 = 138; |
36 | static const int specialx2 = 170; | 36 | static const int specialx2 = 170; |
37 | static const int specialw = 16; | 37 | static const int specialw = 16; |
38 | 38 | ||
39 | static const int num2x1 = 171; | 39 | static const int num2x1 = 171; |
40 | static const int num2x2 = 178; | 40 | static const int num2x2 = 178; |
41 | static const int num2w = num2x2 - num2x1; | 41 | static const int num2w = num2x2 - num2x1; |
42 | 42 | ||
43 | static const int mod2x1 = 179; | 43 | static const int mod2x1 = 179; |
44 | static const int mod2x2 = 203; | 44 | static const int mod2x2 = 203; |
45 | static const int mod2w = mod2x2 - mod2x1; | 45 | static const int mod2w = mod2x2 - mod2x1; |
46 | 46 | ||
47 | static const int cursorx1 = 207; | 47 | static const int cursorx1 = 207; |
48 | static const int cursorw = 16; | 48 | static const int cursorw = 16; |
49 | 49 | ||
50 | static const int myParenID = -10; | 50 | static const int myParenID = -10; |
51 | 51 | ||
52 | 52 | ||
53 | typedef struct mapElement | 53 | typedef struct mapElement |
54 | { | 54 | { |
55 | int qcode; | 55 | int qcode; |
56 | ushort unicode; | 56 | ushort unicode; |
57 | }; | 57 | }; |
58 | 58 | ||
59 | static const mapElement mod1Map[] = { | 59 | static const mapElement mod1Map[] = { |
60 | { Qt::Key_Escape, 27 }, | 60 | { Qt::Key_Escape, 27 }, |
61 | { Qt::Key_Tab, 9 }, | 61 | { Qt::Key_Tab, 9 }, |
62 | { Qt::Key_Return, 13 }, | 62 | { Qt::Key_Return, 13 }, |
63 | { Qt::Key_Alt, 0 }, | 63 | { Qt::Key_Alt, 0 }, |
64 | { Qt::Key_Control, 0 }, | 64 | { Qt::Key_Control, 0 }, |
65 | }; | 65 | }; |
66 | 66 | ||
67 | static const uchar *const letterMap[] = { | 67 | static const uchar *const letterMap[] = { |
68 | (const uchar *const)"zvchwk", | 68 | (const uchar *const)"zvchwk", |
69 | (const uchar *const)"fitaly", | 69 | (const uchar *const)"fitaly", |
70 | (const uchar *const)" ne ", | 70 | (const uchar *const)" ne ", |
71 | (const uchar *const)"gdorsb", | 71 | (const uchar *const)"gdorsb", |
72 | (const uchar *const)"qjumpx", | 72 | (const uchar *const)"qjumpx", |
73 | }; | 73 | }; |
74 | 74 | ||
75 | static const ushort kletterMap[][6] = { | 75 | static const ushort kletterMap[][6] = { |
76 | { 0x110c, 0x1112, 0x1109, 0x116d, 0x1167, 0x1163 }, | 76 | { 0x110c, 0x1112, 0x1109, 0x116d, 0x1167, 0x1163 }, |
77 | { 0x110f, 0x1105, 0x1100, 0x1161, 0x1175, 0x1162 }, | 77 | { 0x110f, 0x1105, 0x1100, 0x1161, 0x1175, 0x1162 }, |
78 | { ' ', ' ', 0x110b, 0x1165, ' ', ' ' }, | 78 | { ' ', ' ', 0x110b, 0x1165, ' ', ' ' }, |
79 | { 0x1110, 0x1103, 0x1102, 0x1169, 0x1173, 0x1166 }, | 79 | { 0x1110, 0x1103, 0x1102, 0x1169, 0x1173, 0x1166 }, |
80 | { 0x110e, 0x1107, 0x1106, 0x1111, 0x116e, 0x1172 }, | 80 | { 0x110e, 0x1107, 0x1106, 0x1111, 0x116e, 0x1172 }, |
81 | }; | 81 | }; |
82 | 82 | ||
83 | static const uchar *const letterMapShift[] = { | 83 | static const uchar *const letterMapShift[] = { |
84 | (const uchar *const)"ZVCHWK", | 84 | (const uchar *const)"ZVCHWK", |
85 | (const uchar *const)"FITALY", | 85 | (const uchar *const)"FITALY", |
86 | (const uchar *const)" NE ", | 86 | (const uchar *const)" NE ", |
87 | (const uchar *const)"GDORSB", | 87 | (const uchar *const)"GDORSB", |
88 | (const uchar *const)"QJUMPX", | 88 | (const uchar *const)"QJUMPX", |
89 | }; | 89 | }; |
90 | 90 | ||
91 | static const ushort kletterMapShift[][6] = { | 91 | static const ushort kletterMapShift[][6] = { |
92 | { 0x110d, 0x1112, 0x110a, 0x116d, 0x1167, 0x1163 }, | 92 | { 0x110d, 0x1112, 0x110a, 0x116d, 0x1167, 0x1163 }, |
93 | { 0x110f, 0x1105, 0x1101, 0x1161, 0x1175, 0x1164 }, | 93 | { 0x110f, 0x1105, 0x1101, 0x1161, 0x1175, 0x1164 }, |
94 | { ' ', ' ', 0x110b, 0x1165, ' ', ' ' }, | 94 | { ' ', ' ', 0x110b, 0x1165, ' ', ' ' }, |
95 | { 0x1110, 0x1103, 0x1102, 0x1169, 0x1173, 0x1168 }, | 95 | { 0x1110, 0x1104, 0x1102, 0x1169, 0x1173, 0x1168 }, |
96 | { 0x110e, 0x1108, 0x1106, 0x1111, 0x116e, 0x1172 }, | 96 | { 0x110e, 0x1108, 0x1106, 0x1111, 0x116e, 0x1172 }, |
97 | }; | 97 | }; |
98 | 98 | ||
99 | static const uchar *const num1Map = (const uchar *const)"12345"; | 99 | static const uchar *const num1Map = (const uchar *const)"12345"; |
100 | 100 | ||
101 | static const uchar *const specialMap[] = { | 101 | static const uchar *const specialMap[] = { |
102 | (const uchar *const)"-+", | 102 | (const uchar *const)"-+", |
103 | (const uchar *const)"*!", | 103 | (const uchar *const)"*!", |
104 | (const uchar *const)",'", | 104 | (const uchar *const)",'", |
105 | (const uchar *const)".%", | 105 | (const uchar *const)".%", |
106 | (const uchar *const)"/$", | 106 | (const uchar *const)"/$", |
107 | }; | 107 | }; |
108 | 108 | ||
109 | static const uchar *const specialMapShift[] = { | 109 | static const uchar *const specialMapShift[] = { |
110 | (const uchar *const)"_=", | 110 | (const uchar *const)"_=", |
111 | (const uchar *const)"#?", | 111 | (const uchar *const)"#?", |
112 | (const uchar *const)";\"", | 112 | (const uchar *const)";\"", |
113 | (const uchar *const)":|", | 113 | (const uchar *const)":|", |
114 | (const uchar *const)"\\&", | 114 | (const uchar *const)"\\&", |
115 | }; | 115 | }; |
116 | 116 | ||
117 | static const uchar *const specialMapParen[] = { | 117 | static const uchar *const specialMapParen[] = { |
118 | (const uchar *const)"()", | 118 | (const uchar *const)"()", |
119 | (const uchar *const)"[]", | 119 | (const uchar *const)"[]", |
120 | (const uchar *const)"{}", | 120 | (const uchar *const)"{}", |
121 | (const uchar *const)"<>", | 121 | (const uchar *const)"<>", |
122 | (const uchar *const)"@~", | 122 | (const uchar *const)"@~", |
123 | }; | 123 | }; |
124 | 124 | ||
125 | static const uchar *const num2Map = (const uchar *const)"67890"; | 125 | static const uchar *const num2Map = (const uchar *const)"67890"; |
126 | 126 | ||
127 | static const mapElement mod2Map[] = { | 127 | static const mapElement mod2Map[] = { |
128 | { Qt::Key_Backspace, 8 }, | 128 | { Qt::Key_Backspace, 8 }, |
129 | { Qt::Key_Delete, 0 }, | 129 | { Qt::Key_Delete, 0 }, |
130 | { Qt::Key_Return, 13 }, | 130 | { Qt::Key_Return, 13 }, |
131 | { Qt::Key_Shift, 0 }, | 131 | { Qt::Key_Shift, 0 }, |
132 | { myParenID, 0 }, | 132 | { myParenID, 0 }, |
133 | }; | 133 | }; |
134 | 134 | ||
135 | static const int cursorMap[][2] = { | 135 | static const int cursorMap[][2] = { |
136 | { Qt::Key_Home, Qt::Key_PageUp }, | 136 | { Qt::Key_Home, Qt::Key_PageUp }, |
137 | { Qt::Key_End, Qt::Key_PageDown }, | 137 | { Qt::Key_End, Qt::Key_PageDown }, |
138 | { Qt::Key_Up, Qt::Key_Up }, | 138 | { Qt::Key_Up, Qt::Key_Up }, |
139 | { Qt::Key_Left, Qt::Key_Right }, | 139 | { Qt::Key_Left, Qt::Key_Right }, |
140 | { Qt::Key_Down, Qt::Key_Down }, | 140 | { Qt::Key_Down, Qt::Key_Down }, |
141 | }; | 141 | }; |
142 | 142 | ||
143 | 143 | ||
144 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : | 144 | Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : |
145 | QFrame(parent, name, f), | 145 | QFrame(parent, name, f), |
146 | shift(0), paren(0), ctrl(0), alt(0), lang(1), lastKey(0), | 146 | shift(0), paren(0), ctrl(0), alt(0), lang(1), lastKey(0), |
147 | pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), | 147 | pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), |
148 | isnoncont(false), | 148 | isnoncont(false), |
149 | slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), | 149 | slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), |
150 | enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), | 150 | enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), |
151 | releasedPix(NULL), pressedPix(NULL) | 151 | releasedPix(NULL), pressedPix(NULL) |
152 | { | 152 | { |
153 | //setPalette(QPalette(QColor(240,240,230))); // Beige! | 153 | //setPalette(QPalette(QColor(240,240,230))); // Beige! |
154 | 154 | ||
155 | releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("kjumpx/released"); | 155 | releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("kjumpx/released"); |
156 | pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("kjumpx/pressed"); | 156 | pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("kjumpx/pressed"); |
157 | pressedDigit = Resource::loadPixmap("kjumpx/pressed"); | 157 | pressedDigit = Resource::loadPixmap("kjumpx/pressed"); |
158 | 158 | ||
159 | QPixmap tmp; | 159 | QPixmap tmp; |
160 | 160 | ||
161 | tmp = Resource::loadPixmap("kjumpx/releasedShift"); | 161 | tmp = Resource::loadPixmap("kjumpx/releasedShift"); |
162 | bitBlt(&releasedShift, letterx1, 0, &tmp); | 162 | bitBlt(&releasedShift, letterx1, 0, &tmp); |
163 | 163 | ||
164 | tmp = Resource::loadPixmap("kjumpx/releasedParen"); | 164 | tmp = Resource::loadPixmap("kjumpx/releasedParen"); |
165 | bitBlt(&releasedParen, specialx1, 0, &tmp); | 165 | bitBlt(&releasedParen, specialx1, 0, &tmp); |
166 | 166 | ||
167 | tmp = Resource::loadPixmap("kjumpx/pressedShift"); | 167 | tmp = Resource::loadPixmap("kjumpx/pressedShift"); |
168 | bitBlt(&pressedShift, letterx1, 0, &tmp); | 168 | bitBlt(&pressedShift, letterx1, 0, &tmp); |
169 | 169 | ||
170 | tmp = Resource::loadPixmap("kjumpx/pressedParen"); | 170 | tmp = Resource::loadPixmap("kjumpx/pressedParen"); |
171 | bitBlt(&pressedParen, specialx1, 0, &tmp); | 171 | bitBlt(&pressedParen, specialx1, 0, &tmp); |
172 | 172 | ||
173 | tmp = Resource::loadPixmap("kjumpx/pressedDigit"); | 173 | tmp = Resource::loadPixmap("kjumpx/pressedDigit"); |
174 | bitBlt(&pressedDigit, specialx1, 0, &tmp); | 174 | bitBlt(&pressedDigit, specialx1, 0, &tmp); |
175 | 175 | ||
176 | offscreen = QPixmap( releasedPlain ); | 176 | offscreen = QPixmap( releasedPlain ); |
177 | 177 | ||
178 | releasedPix = &releasedPlain; | 178 | releasedPix = &releasedPlain; |
179 | pressedPix = &pressedPlain; | 179 | pressedPix = &pressedPlain; |
180 | slidePix = &pressedPlain; | 180 | slidePix = &pressedPlain; |
181 | 181 | ||
182 | delayTimer = new QTimer(this); | 182 | delayTimer = new QTimer(this); |
183 | rateTimer = new QTimer(this); | 183 | rateTimer = new QTimer(this); |
184 | connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); | 184 | connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); |
185 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); | 185 | connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Keyboard::resizeEvent(QResizeEvent*) | 188 | void Keyboard::resizeEvent(QResizeEvent*) |
189 | { | 189 | { |
190 | //cout << "resizeEvent()" << endl; | 190 | //cout << "resizeEvent()" << endl; |
191 | } | 191 | } |
192 | 192 | ||
193 | void Keyboard::paintEvent(QPaintEvent*) | 193 | void Keyboard::paintEvent(QPaintEvent*) |
194 | { | 194 | { |
195 | bitBlt(this, 0, 0, &offscreen); | 195 | bitBlt(this, 0, 0, &offscreen); |
196 | } | 196 | } |
197 | 197 | ||
198 | void Keyboard::mousePressEvent(QMouseEvent *e) | 198 | void Keyboard::mousePressEvent(QMouseEvent *e) |
199 | { | 199 | { |
200 | pressedx = -1; | 200 | pressedx = -1; |
201 | pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; | 201 | pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; |
202 | 202 | ||
203 | int x = e->x(); | 203 | int x = e->x(); |
204 | int y = e->y(); | 204 | int y = e->y(); |
205 | 205 | ||
206 | int row = (y - 1) / letterh; | 206 | int row = (y - 1) / letterh; |
207 | 207 | ||
208 | if ( x <= mod1x2 ) // mod1 | 208 | if ( x <= mod1x2 ) // mod1 |
209 | { | 209 | { |
210 | pressedx = mod1x1; | 210 | pressedx = mod1x1; |
211 | pressedy = row * letterh; | 211 | pressedy = row * letterh; |
212 | pressedw = mod1w + 1; | 212 | pressedw = mod1w + 1; |
213 | pressedh = letterh + 1; | 213 | pressedh = letterh + 1; |
214 | if ( row == 2 ) // return | 214 | if ( row == 2 ) // return |
215 | { | 215 | { |
216 | pressed2x = mod2x1; | 216 | pressed2x = mod2x1; |
217 | pressed2y = 2 * letterh; | 217 | pressed2y = 2 * letterh; |
218 | pressed2w = mod2w + 1; | 218 | pressed2w = mod2w + 1; |
219 | pressed2h = letterh + 1; | 219 | pressed2h = letterh + 1; |
220 | isnoncont = true; | 220 | isnoncont = true; |
221 | } | 221 | } |
222 | else if ( row == 3 ) // alt | 222 | else if ( row == 3 ) // alt |
223 | alt = 1; | 223 | alt = 1; |
224 | else if ( row == 4 ) // ctrl | 224 | else if ( row == 4 ) // ctrl |
225 | ctrl = 1; | 225 | ctrl = 1; |
226 | pressedKeyUnicode = mod1Map[row].unicode; | 226 | pressedKeyUnicode = mod1Map[row].unicode; |
227 | pressedKeyQcode = mod1Map[row].qcode; | 227 | pressedKeyQcode = mod1Map[row].qcode; |
228 | } | 228 | } |
229 | else if ( x >= letterx1 && x <= letterx2 ) // letter | 229 | else if ( x >= letterx1 && x <= letterx2 ) // letter |
230 | { | 230 | { |
231 | int column = (x - letterx1 - 1) / letterw; | 231 | int column = (x - letterx1 - 1) / letterw; |
232 | QChar temp; | 232 | QChar temp; |
233 | if (lang == 0) // english | 233 | if (lang == 0) // english |
234 | if ( shift ) | 234 | if ( shift ) |
235 | temp = QChar( letterMapShift[row][column] ); | 235 | temp = QChar( letterMapShift[row][column] ); |
236 | else | 236 | else |
237 | temp = QChar( letterMap[row][column] ); | 237 | temp = QChar( letterMap[row][column] ); |
238 | else if (lang == 1) // korean | 238 | else if (lang == 1) // korean |
239 | if ( shift ) | 239 | if ( shift ) |
240 | temp = parseKoreanInput( kletterMapShift[row][column] ); | 240 | temp = parseKoreanInput( kletterMapShift[row][column] ); |
241 | else | 241 | else |
242 | temp = parseKoreanInput( kletterMap[row][column] ); | 242 | temp = parseKoreanInput( kletterMap[row][column] ); |
243 | 243 | ||
244 | if ( temp == ' ' ) // space | 244 | if ( temp == ' ' ) // space |
245 | { | 245 | { |
246 | if ( column < 3 ) | 246 | if ( column < 3 ) |
247 | { | 247 | { |
248 | pressedx = letterx1; | 248 | pressedx = letterx1; |
249 | pressed2x = letterx1 + letterw * 4; | 249 | pressed2x = letterx1 + letterw * 4; |
250 | } | 250 | } |
251 | else | 251 | else |
252 | { | 252 | { |
253 | pressedx = letterx1 + letterw * 4; | 253 | pressedx = letterx1 + letterw * 4; |
254 | pressed2x = letterx1; | 254 | pressed2x = letterx1; |
255 | } | 255 | } |
256 | pressedy = pressed2y = row * letterh; | 256 | pressedy = pressed2y = row * letterh; |
257 | pressedw = pressed2w = letterw * 2 + 1; | 257 | pressedw = pressed2w = letterw * 2 + 1; |
258 | pressedh = pressed2h = letterh + 1; | 258 | pressedh = pressed2h = letterh + 1; |
259 | isnoncont = true; | 259 | isnoncont = true; |
260 | } | 260 | } |
261 | else | 261 | else |
262 | { | 262 | { |
263 | pressedx = letterx1 + column * letterw; | 263 | pressedx = letterx1 + column * letterw; |
264 | pressedy = row * letterh; | 264 | pressedy = row * letterh; |
265 | pressedw = letterw + 1; | 265 | pressedw = letterw + 1; |
266 | pressedh = letterh + 1; | 266 | pressedh = letterh + 1; |
267 | } | 267 | } |
268 | pressedKeyUnicode = temp.unicode(); | 268 | pressedKeyUnicode = temp.unicode(); |
269 | pressedKeyQcode = slideKeyQcodeH = slideKeyQcodeV = temp.upper().unicode(); | 269 | pressedKeyQcode = slideKeyQcodeH = slideKeyQcodeV = temp.upper().unicode(); |
270 | if ( temp == ' ' ) | 270 | if ( temp == ' ' ) |
271 | { | 271 | { |
272 | slideKeyUnicodeH = slideKeyUnicodeV = 8; | 272 | slideKeyUnicodeH = slideKeyUnicodeV = 8; |
273 | slideKeyQcodeH = slideKeyQcodeV = Qt::Key_Backspace; | 273 | slideKeyQcodeH = slideKeyQcodeV = Qt::Key_Backspace; |
274 | } | 274 | } |
275 | else if ( temp == temp.lower() ) | 275 | else if ( temp == temp.lower() ) |
276 | { | 276 | { |
277 | slideKeyUnicodeH = slideKeyUnicodeV = temp.upper().unicode(); | 277 | slideKeyUnicodeH = slideKeyUnicodeV = temp.upper().unicode(); |
278 | slidePixH = slidePixV = &pressedShift; | 278 | slidePixH = slidePixV = &pressedShift; |
279 | } | 279 | } |
280 | else | 280 | else |
281 | { | 281 | { |
282 | slideKeyUnicodeH = slideKeyUnicodeV = temp.lower().unicode(); | 282 | slideKeyUnicodeH = slideKeyUnicodeV = temp.lower().unicode(); |
283 | slidePixH = slidePixV = &pressedPlain; | 283 | slidePixH = slidePixV = &pressedPlain; |
284 | } | 284 | } |
285 | enableMouseTracking = true; | 285 | enableMouseTracking = true; |
286 | } | 286 | } |
287 | else if ( x >= num1x1 && x <= num1x2 ) // num1 | 287 | else if ( x >= num1x1 && x <= num1x2 ) // num1 |
288 | { | 288 | { |
289 | pressedx = num1x1; | 289 | pressedx = num1x1; |
290 | pressedy = row * letterh; | 290 | pressedy = row * letterh; |
291 | pressedw = num1w + 1; | 291 | pressedw = num1w + 1; |
292 | pressedh = letterh + 1; | 292 | pressedh = letterh + 1; |
293 | QChar temp = QChar( num1Map[row] ); | 293 | QChar temp = QChar( num1Map[row] ); |
294 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); | 294 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); |
295 | } | 295 | } |
296 | else if ( x >= specialx1 && x <= specialx2 ) // special | 296 | else if ( x >= specialx1 && x <= specialx2 ) // special |
297 | { | 297 | { |
298 | int column = (x - specialx1 - 1) / specialw; | 298 | int column = (x - specialx1 - 1) / specialw; |
299 | pressedx = specialx1 + column * specialw; | 299 | pressedx = specialx1 + column * specialw; |
300 | pressedy = row * letterh; | 300 | pressedy = row * letterh; |
301 | pressedw = specialw + 1; | 301 | pressedw = specialw + 1; |
302 | pressedh = letterh + 1; | 302 | pressedh = letterh + 1; |
303 | QChar temp; | 303 | QChar temp; |
304 | if ( shift ) | 304 | if ( shift ) |
305 | temp = QChar( specialMapShift[row][column] ); | 305 | temp = QChar( specialMapShift[row][column] ); |
306 | else if ( paren ) | 306 | else if ( paren ) |
307 | temp = QChar( specialMapParen[row][column] ); | 307 | temp = QChar( specialMapParen[row][column] ); |
308 | else | 308 | else |
309 | temp = QChar( specialMap[row][column] ); | 309 | temp = QChar( specialMap[row][column] ); |
310 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); | 310 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); |
311 | slideKeyUnicodeH = slideKeyQcodeH = slideKeyUnicodeV = slideKeyQcodeV = | 311 | slideKeyUnicodeH = slideKeyQcodeH = slideKeyUnicodeV = slideKeyQcodeV = |
312 | QChar('0').unicode() + ( 5 * column + row + 1 ) % 10; | 312 | QChar('0').unicode() + ( 5 * column + row + 1 ) % 10; |
313 | slidePixH = slidePixV = &pressedDigit; | 313 | slidePixH = slidePixV = &pressedDigit; |
314 | if ( shift ) | 314 | if ( shift ) |
315 | { | 315 | { |
316 | slideKeyUnicodeV = slideKeyQcodeV = | 316 | slideKeyUnicodeV = slideKeyQcodeV = |
317 | QChar( specialMap[row][column] ).unicode(); | 317 | QChar( specialMap[row][column] ).unicode(); |
318 | slidePixV = &pressedPlain; | 318 | slidePixV = &pressedPlain; |
319 | } | 319 | } |
320 | else if ( !(shift || paren) ) | 320 | else if ( !(shift || paren) ) |
321 | { | 321 | { |
322 | slideKeyUnicodeV = slideKeyQcodeV = | 322 | slideKeyUnicodeV = slideKeyQcodeV = |
323 | QChar( specialMapShift[row][column] ).unicode(); | 323 | QChar( specialMapShift[row][column] ).unicode(); |
324 | slidePixV = &pressedShift; | 324 | slidePixV = &pressedShift; |
325 | } | 325 | } |
326 | enableMouseTracking = true; | 326 | enableMouseTracking = true; |
327 | } | 327 | } |
328 | else if ( x >= num2x1 && x <= num2x2 ) // num2 | 328 | else if ( x >= num2x1 && x <= num2x2 ) // num2 |
329 | { | 329 | { |
330 | pressedx = num2x1; | 330 | pressedx = num2x1; |
331 | pressedy = row * letterh; | 331 | pressedy = row * letterh; |
332 | pressedw = num2w + 1; | 332 | pressedw = num2w + 1; |
333 | pressedh = letterh + 1; | 333 | pressedh = letterh + 1; |
334 | QChar temp = QChar( num2Map[row] ); | 334 | QChar temp = QChar( num2Map[row] ); |
335 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); | 335 | pressedKeyUnicode = pressedKeyQcode = temp.unicode(); |
336 | } | 336 | } |
337 | else if ( x >= mod2x1 && x <= mod2x2 ) // mod2 | 337 | else if ( x >= mod2x1 && x <= mod2x2 ) // mod2 |
338 | { | 338 | { |
339 | pressedx = mod2x1; | 339 | pressedx = mod2x1; |
340 | pressedy = row * letterh; | 340 | pressedy = row * letterh; |
341 | pressedw = mod2w + 1; | 341 | pressedw = mod2w + 1; |
342 | pressedh = letterh + 1; | 342 | pressedh = letterh + 1; |
343 | if ( row == 2 ) // return | 343 | if ( row == 2 ) // return |
344 | { | 344 | { |
345 | pressed2x = mod1x1; | 345 | pressed2x = mod1x1; |
346 | pressed2y = 2 * letterh; | 346 | pressed2y = 2 * letterh; |
347 | pressed2w = mod2w + 1; | 347 | pressed2w = mod2w + 1; |
348 | pressed2h = letterh + 1; | 348 | pressed2h = letterh + 1; |
349 | isnoncont = true; | 349 | isnoncont = true; |
350 | } | 350 | } |
351 | pressedKeyUnicode = mod2Map[row].unicode; | 351 | pressedKeyUnicode = mod2Map[row].unicode; |
352 | pressedKeyQcode = mod2Map[row].qcode; | 352 | pressedKeyQcode = mod2Map[row].qcode; |
353 | 353 | ||
354 | if ( row == 3 ) // shift | 354 | if ( row == 3 ) // shift |
355 | { | 355 | { |
356 | paren = 0; | 356 | paren = 0; |
357 | switch ( shift ) | 357 | switch ( shift ) |
358 | { | 358 | { |
359 | case 0: | 359 | case 0: |
360 | { | 360 | { |
361 | shift = 1; | 361 | shift = 1; |
362 | releasedPix = &releasedShift; | 362 | releasedPix = &releasedShift; |
363 | pressedPix = &pressedShift; | 363 | pressedPix = &pressedShift; |
364 | bitBlt( &offscreen, 0, 0, releasedPix ); | 364 | bitBlt( &offscreen, 0, 0, releasedPix ); |
365 | break; | 365 | break; |
366 | } | 366 | } |
367 | case 1: | 367 | case 1: |
368 | { | 368 | { |
369 | shift = 2; | 369 | shift = 2; |
370 | break; | 370 | break; |
371 | } | 371 | } |
372 | case 2: | 372 | case 2: |
373 | { | 373 | { |
374 | shift = 0; | 374 | shift = 0; |
375 | releasedPix = &releasedPlain; | 375 | releasedPix = &releasedPlain; |
376 | pressedPix = &pressedPlain; | 376 | pressedPix = &pressedPlain; |
377 | bitBlt( &offscreen, 0, 0, releasedPix ); | 377 | bitBlt( &offscreen, 0, 0, releasedPix ); |
378 | break; | 378 | break; |
379 | } | 379 | } |
380 | } | 380 | } |
381 | } | 381 | } |
382 | else if ( row == 4 ) // parenthesis | 382 | else if ( row == 4 ) // parenthesis |
383 | { | 383 | { |
384 | shift = 0; | 384 | shift = 0; |
385 | switch ( paren ) | 385 | switch ( paren ) |
386 | { | 386 | { |
387 | case 0: | 387 | case 0: |
388 | { | 388 | { |
389 | paren = 1; | 389 | paren = 1; |
390 | releasedPix = &releasedParen; | 390 | releasedPix = &releasedParen; |
391 | pressedPix = &pressedParen; | 391 | pressedPix = &pressedParen; |
392 | bitBlt( &offscreen, 0, 0, releasedPix ); | 392 | bitBlt( &offscreen, 0, 0, releasedPix ); |
393 | break; | 393 | break; |
394 | } | 394 | } |
395 | case 1: | 395 | case 1: |
396 | { | 396 | { |
397 | paren = 2; | 397 | paren = 2; |
398 | break; | 398 | break; |
399 | } | 399 | } |
400 | case 2: | 400 | case 2: |
401 | { | 401 | { |
402 | paren = 0; | 402 | paren = 0; |
403 | releasedPix = &releasedPlain; | 403 | releasedPix = &releasedPlain; |
404 | pressedPix = &pressedPlain; | 404 | pressedPix = &pressedPlain; |
405 | bitBlt( &offscreen, 0, 0, releasedPix ); | 405 | bitBlt( &offscreen, 0, 0, releasedPix ); |
406 | break; | 406 | break; |
407 | } | 407 | } |
408 | } | 408 | } |
409 | } | 409 | } |
410 | } | 410 | } |
411 | else if ( x >= cursorx1 ) // cursor | 411 | else if ( x >= cursorx1 ) // cursor |
412 | { | 412 | { |
413 | int column = (x - cursorx1 - 1) / cursorw; | 413 | int column = (x - cursorx1 - 1) / cursorw; |
414 | if ( row == 2 || row == 4 ) | 414 | if ( row == 2 || row == 4 ) |
415 | pressedx = cursorx1 + cursorw / 2; | 415 | pressedx = cursorx1 + cursorw / 2; |
416 | else | 416 | else |
417 | pressedx = cursorx1 + column * cursorw; | 417 | pressedx = cursorx1 + column * cursorw; |
418 | pressedy = row * letterh; | 418 | pressedy = row * letterh; |
419 | pressedw = cursorw + 1; | 419 | pressedw = cursorw + 1; |
420 | pressedh = letterh + 1; | 420 | pressedh = letterh + 1; |
421 | pressedKeyQcode = cursorMap[row][column]; | 421 | pressedKeyQcode = cursorMap[row][column]; |
422 | } | 422 | } |
423 | 423 | ||
424 | pressedMod = ( shift ? Qt::ShiftButton : 0 ) | | 424 | pressedMod = ( shift ? Qt::ShiftButton : 0 ) | |
425 | ( ctrl ? Qt::ControlButton : 0 ) | | 425 | ( ctrl ? Qt::ControlButton : 0 ) | |
426 | ( alt ? Qt::AltButton : 0 ); | 426 | ( alt ? Qt::AltButton : 0 ); |
427 | 427 | ||
428 | lastKey = pressedKeyUnicode; | 428 | lastKey = pressedKeyUnicode; |
429 | 429 | ||
430 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); | 430 | emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); |
431 | delayTimer->start( autorepeatDelaytime, true ); | 431 | delayTimer->start( autorepeatDelaytime, true ); |
432 | 432 | ||
433 | if ( pressedx == -1 ) | 433 | if ( pressedx == -1 ) |
434 | return; | 434 | return; |
435 | 435 | ||
436 | bitBlt( &offscreen, pressedx, pressedy, | 436 | bitBlt( &offscreen, pressedx, pressedy, |
437 | pressedPix, pressedx, pressedy, pressedw, pressedh ); | 437 | pressedPix, pressedx, pressedy, pressedw, pressedh ); |
438 | if ( isnoncont ) | 438 | if ( isnoncont ) |
439 | bitBlt( &offscreen, pressed2x, pressed2y, | 439 | bitBlt( &offscreen, pressed2x, pressed2y, |
440 | pressedPix, pressed2x, pressed2y, pressed2w, pressed2h ); | 440 | pressedPix, pressed2x, pressed2y, pressed2w, pressed2h ); |
441 | 441 | ||
442 | repaint( false ); | 442 | repaint( false ); |
443 | } | 443 | } |
444 | 444 | ||
445 | void Keyboard::mouseReleaseEvent(QMouseEvent*) | 445 | void Keyboard::mouseReleaseEvent(QMouseEvent*) |
446 | { | 446 | { |
447 | //cout << pressedx << " " << pressedy << " " << pressedw << " " << pressedh << endl; | 447 | //cout << pressedx << " " << pressedy << " " << pressedw << " " << pressedh << endl; |
448 | 448 | ||
449 | delayTimer->stop(); | 449 | delayTimer->stop(); |
450 | rateTimer->stop(); | 450 | rateTimer->stop(); |
451 | enableMouseTracking = false; | 451 | enableMouseTracking = false; |
452 | 452 | ||
453 | if ( pressedx == -1 ) | 453 | if ( pressedx == -1 ) |
454 | return; | 454 | return; |
455 | 455 | ||
456 | if ( shift == 2 && pressedKeyQcode == Qt::Key_Shift ) | 456 | if ( shift == 2 && pressedKeyQcode == Qt::Key_Shift ) |
457 | return; | 457 | return; |
458 | if ( paren == 2 && pressedKeyQcode == myParenID ) | 458 | if ( paren == 2 && pressedKeyQcode == myParenID ) |
459 | return; | 459 | return; |
460 | 460 | ||
461 | if ( shift == 1 && pressedKeyQcode != Qt::Key_Shift ) | 461 | if ( shift == 1 && pressedKeyQcode != Qt::Key_Shift ) |
462 | { | 462 | { |
463 | shift = 0; | 463 | shift = 0; |
464 | releasedPix = &releasedPlain; | 464 | releasedPix = &releasedPlain; |
465 | pressedPix = &pressedPlain; | 465 | pressedPix = &pressedPlain; |
466 | bitBlt( &offscreen, 0, 0, releasedPix ); | 466 | bitBlt( &offscreen, 0, 0, releasedPix ); |
467 | } | 467 | } |
468 | 468 | ||
469 | if ( paren == 1 && pressedKeyQcode != myParenID ) | 469 | if ( paren == 1 && pressedKeyQcode != myParenID ) |
470 | { | 470 | { |
471 | paren = 0; | 471 | paren = 0; |
472 | releasedPix = &releasedPlain; | 472 | releasedPix = &releasedPlain; |
473 | pressedPix = &pressedPlain; | 473 | pressedPix = &pressedPlain; |
474 | bitBlt( &offscreen, 0, 0, releasedPix ); | 474 | bitBlt( &offscreen, 0, 0, releasedPix ); |
475 | } | 475 | } |
476 | 476 | ||
477 | if ( alt && pressedKeyQcode != Qt::Key_Alt ) | 477 | if ( alt && pressedKeyQcode != Qt::Key_Alt ) |
478 | alt = 0; | 478 | alt = 0; |
479 | if ( ctrl && pressedKeyQcode != Qt::Key_Control ) | 479 | if ( ctrl && pressedKeyQcode != Qt::Key_Control ) |