summaryrefslogtreecommitdiff
path: root/inputmethods/kjumpx/keyboard.cpp
authordrw <drw>2005-06-15 22:54:50 (UTC)
committer drw <drw>2005-06-15 22:54:50 (UTC)
commit7ff2e7bd4620a574f3ff22a951a5904310cfd920 (patch) (unidiff)
tree6d8ffd28aadf00901b3ab560464794aded3efc76 /inputmethods/kjumpx/keyboard.cpp
parente0205bac48b9d23af9feb48004c24fcf7a5e8200 (diff)
downloadopie-7ff2e7bd4620a574f3ff22a951a5904310cfd920.zip
opie-7ff2e7bd4620a574f3ff22a951a5904310cfd920.tar.gz
opie-7ff2e7bd4620a574f3ff22a951a5904310cfd920.tar.bz2
Resource -> OResource
Diffstat (limited to 'inputmethods/kjumpx/keyboard.cpp') (more/less context) (show whitespace changes)
-rw-r--r--inputmethods/kjumpx/keyboard.cpp60
1 files changed, 30 insertions, 30 deletions
diff --git a/inputmethods/kjumpx/keyboard.cpp b/inputmethods/kjumpx/keyboard.cpp
index dc44805..4e99f40 100644
--- a/inputmethods/kjumpx/keyboard.cpp
+++ b/inputmethods/kjumpx/keyboard.cpp
@@ -1,270 +1,270 @@
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 <opie2/oresource.h>
15 15
16//#include <iostream.h> 16//#include <iostream.h>
17 17
18 18
19static const int autorepeatDelaytime = 500; // ms 19static const int autorepeatDelaytime = 500; // ms
20static const int autorepeatRate = 20; // chars per second 20static const int autorepeatRate = 20; // chars per second
21 21
22static const int mod1x1 = 0; 22static const int mod1x1 = 0;
23static const int mod1x2 = 23; 23static const int mod1x2 = 23;
24static const int mod1w = mod1x2 - mod1x1; 24static const int mod1w = mod1x2 - mod1x1;
25 25
26static const int letterx1 = 27; 26static const int letterx1 = 27;
27static const int letterx2 = 129; 27static const int letterx2 = 129;
28static const int letterw = 17; 28static const int letterw = 17;
29static const int letterh = 14; 29static const int letterh = 14;
30 30
31static const int num1x1 = 130; 31static const int num1x1 = 130;
32static const int num1x2 = 137; 32static const int num1x2 = 137;
33static const int num1w = num1x2 - num1x1; 33static const int num1w = num1x2 - num1x1;
34 34
35static const int specialx1 = 138; 35static const int specialx1 = 138;
36static const int specialx2 = 170; 36static const int specialx2 = 170;
37static const int specialw = 16; 37static const int specialw = 16;
38 38
39static const int num2x1 = 171; 39static const int num2x1 = 171;
40static const int num2x2 = 178; 40static const int num2x2 = 178;
41static const int num2w = num2x2 - num2x1; 41static const int num2w = num2x2 - num2x1;
42 42
43static const int mod2x1 = 179; 43static const int mod2x1 = 179;
44static const int mod2x2 = 203; 44static const int mod2x2 = 203;
45static const int mod2w = mod2x2 - mod2x1; 45static const int mod2w = mod2x2 - mod2x1;
46 46
47static const int cursorx1 = 207; 47static const int cursorx1 = 207;
48static const int cursorw = 16; 48static const int cursorw = 16;
49 49
50static const int myParenID = -10; 50static const int myParenID = -10;
51 51
52 52
53typedef struct mapElement 53typedef struct mapElement
54{ 54{
55 int qcode; 55 int qcode;
56 ushort unicode; 56 ushort unicode;
57}; 57};
58 58
59static const mapElement mod1Map[] = { 59static 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
67static const uchar *const letterMap[] = { 67static 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
75static const ushort kletterMap[][6] = { 75static 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
83static const uchar *const letterMapShift[] = { 83static 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
91static const ushort kletterMapShift[][6] = { 91static 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, 0x1104, 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
99static const uchar *const num1Map = (const uchar *const)"12345"; 99static const uchar *const num1Map = (const uchar *const)"12345";
100 100
101static const uchar *const specialMap[] = { 101static 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
109static const uchar *const specialMapShift[] = { 109static 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
117static const uchar *const specialMapParen[] = { 117static 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
125static const uchar *const num2Map = (const uchar *const)"67890"; 125static const uchar *const num2Map = (const uchar *const)"67890";
126 126
127static const mapElement mod2Map[] = { 127static 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
135static const int cursorMap[][2] = { 135static 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
143using namespace KJumpX; 143using namespace KJumpX;
144 144
145Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) : 145Keyboard::Keyboard(QWidget* parent, const char* name, WFlags f) :
146 QFrame(parent, name, f), 146 QFrame(parent, name, f),
147 shift(0), paren(0), ctrl(0), alt(0), lang(1), lastKey(0), 147 shift(0), paren(0), ctrl(0), alt(0), lang(1), lastKey(0),
148 pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0), 148 pressedKeyUnicode(0), pressedKeyQcode(0), pressedMod(0),
149 isnoncont(false), 149 isnoncont(false),
150 slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0), 150 slideKeyUnicodeH(0), slideKeyQcodeH(0), slideKeyUnicodeV(0), slideKeyQcodeV(0),
151 enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL), 151 enableMouseTracking(false), slidePix(NULL), slidePixH(NULL), slidePixV(NULL),
152 releasedPix(NULL), pressedPix(NULL) 152 releasedPix(NULL), pressedPix(NULL)
153{ 153{
154 //setPalette(QPalette(QColor(240,240,230))); // Beige! 154 //setPalette(QPalette(QColor(240,240,230))); // Beige!
155 155
156 releasedPlain = releasedShift = releasedParen = Resource::loadPixmap("kjumpx/released"); 156 releasedPlain = releasedShift = releasedParen = Opie::Core::OResource::loadPixmap("kjumpx/released");
157 pressedPlain = pressedShift = pressedParen = Resource::loadPixmap("kjumpx/pressed"); 157 pressedPlain = pressedShift = pressedParen = Opie::Core::OResource::loadPixmap("kjumpx/pressed");
158 pressedDigit = Resource::loadPixmap("kjumpx/pressed"); 158 pressedDigit = Opie::Core::OResource::loadPixmap("kjumpx/pressed");
159 159
160 QPixmap tmp; 160 QPixmap tmp;
161 161
162 tmp = Resource::loadPixmap("kjumpx/releasedShift"); 162 tmp = Opie::Core::OResource::loadPixmap("kjumpx/releasedShift");
163 bitBlt(&releasedShift, letterx1, 0, &tmp); 163 bitBlt(&releasedShift, letterx1, 0, &tmp);
164 164
165 tmp = Resource::loadPixmap("kjumpx/releasedParen"); 165 tmp = Opie::Core::OResource::loadPixmap("kjumpx/releasedParen");
166 bitBlt(&releasedParen, specialx1, 0, &tmp); 166 bitBlt(&releasedParen, specialx1, 0, &tmp);
167 167
168 tmp = Resource::loadPixmap("kjumpx/pressedShift"); 168 tmp = Opie::Core::OResource::loadPixmap("kjumpx/pressedShift");
169 bitBlt(&pressedShift, letterx1, 0, &tmp); 169 bitBlt(&pressedShift, letterx1, 0, &tmp);
170 170
171 tmp = Resource::loadPixmap("kjumpx/pressedParen"); 171 tmp = Opie::Core::OResource::loadPixmap("kjumpx/pressedParen");
172 bitBlt(&pressedParen, specialx1, 0, &tmp); 172 bitBlt(&pressedParen, specialx1, 0, &tmp);
173 173
174 tmp = Resource::loadPixmap("kjumpx/pressedDigit"); 174 tmp = Opie::Core::OResource::loadPixmap("kjumpx/pressedDigit");
175 bitBlt(&pressedDigit, specialx1, 0, &tmp); 175 bitBlt(&pressedDigit, specialx1, 0, &tmp);
176 176
177 offscreen = QPixmap( releasedPlain ); 177 offscreen = QPixmap( releasedPlain );
178 178
179 releasedPix = &releasedPlain; 179 releasedPix = &releasedPlain;
180 pressedPix = &pressedPlain; 180 pressedPix = &pressedPlain;
181 slidePix = &pressedPlain; 181 slidePix = &pressedPlain;
182 182
183 delayTimer = new QTimer(this); 183 delayTimer = new QTimer(this);
184 rateTimer = new QTimer(this); 184 rateTimer = new QTimer(this);
185 connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) ); 185 connect( delayTimer, SIGNAL( timeout() ), this, SLOT( delayTimerDone() ) );
186 connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) ); 186 connect( rateTimer, SIGNAL( timeout() ), this, SLOT( rateTimerDone() ) );
187} 187}
188 188
189void Keyboard::resizeEvent(QResizeEvent*) 189void Keyboard::resizeEvent(QResizeEvent*)
190{ 190{
191 //cout << "resizeEvent()" << endl; 191 //cout << "resizeEvent()" << endl;
192} 192}
193 193
194void Keyboard::paintEvent(QPaintEvent*) 194void Keyboard::paintEvent(QPaintEvent*)
195{ 195{
196 bitBlt(this, 0, 0, &offscreen); 196 bitBlt(this, 0, 0, &offscreen);
197} 197}
198 198
199void Keyboard::mousePressEvent(QMouseEvent *e) 199void Keyboard::mousePressEvent(QMouseEvent *e)
200{ 200{
201 pressedx = -1; 201 pressedx = -1;
202 pressedKeyUnicode = pressedKeyQcode = pressedMod = 0; 202 pressedKeyUnicode = pressedKeyQcode = pressedMod = 0;
203 203
204 int x = e->x(); 204 int x = e->x();
205 int y = e->y(); 205 int y = e->y();
206 206
207 int row = (y - 1) / letterh; 207 int row = (y - 1) / letterh;
208 208
209 if ( x <= mod1x2 ) // mod1 209 if ( x <= mod1x2 ) // mod1
210 { 210 {
211 pressedx = mod1x1; 211 pressedx = mod1x1;
212 pressedy = row * letterh; 212 pressedy = row * letterh;
213 pressedw = mod1w + 1; 213 pressedw = mod1w + 1;
214 pressedh = letterh + 1; 214 pressedh = letterh + 1;
215 if ( row == 2 ) // return 215 if ( row == 2 ) // return
216 { 216 {
217 pressed2x = mod2x1; 217 pressed2x = mod2x1;
218 pressed2y = 2 * letterh; 218 pressed2y = 2 * letterh;
219 pressed2w = mod2w + 1; 219 pressed2w = mod2w + 1;
220 pressed2h = letterh + 1; 220 pressed2h = letterh + 1;
221 isnoncont = true; 221 isnoncont = true;
222 } 222 }
223 else if ( row == 3 ) // alt 223 else if ( row == 3 ) // alt
224 alt = 1; 224 alt = 1;
225 else if ( row == 4 ) // ctrl 225 else if ( row == 4 ) // ctrl
226 ctrl = 1; 226 ctrl = 1;
227 pressedKeyUnicode = mod1Map[row].unicode; 227 pressedKeyUnicode = mod1Map[row].unicode;
228 pressedKeyQcode = mod1Map[row].qcode; 228 pressedKeyQcode = mod1Map[row].qcode;
229 } 229 }
230 else if ( x >= letterx1 && x <= letterx2 ) // letter 230 else if ( x >= letterx1 && x <= letterx2 ) // letter
231 { 231 {
232 int column = (x - letterx1 - 1) / letterw; 232 int column = (x - letterx1 - 1) / letterw;
233 QChar temp; 233 QChar temp;
234 if (lang == 0) // english 234 if (lang == 0) // english
235 if ( shift ) 235 if ( shift )
236 temp = QChar( letterMapShift[row][column] ); 236 temp = QChar( letterMapShift[row][column] );
237 else 237 else
238 temp = QChar( letterMap[row][column] ); 238 temp = QChar( letterMap[row][column] );
239 else if (lang == 1) // korean 239 else if (lang == 1) // korean
240 if ( shift ) 240 if ( shift )
241 temp = parseKoreanInput( kletterMapShift[row][column] ); 241 temp = parseKoreanInput( kletterMapShift[row][column] );
242 else 242 else
243 temp = parseKoreanInput( kletterMap[row][column] ); 243 temp = parseKoreanInput( kletterMap[row][column] );
244 244
245 if ( temp == ' ' ) // space 245 if ( temp == ' ' ) // space
246 { 246 {
247 if ( column < 3 ) 247 if ( column < 3 )
248 { 248 {
249 pressedx = letterx1; 249 pressedx = letterx1;
250 pressed2x = letterx1 + letterw * 4; 250 pressed2x = letterx1 + letterw * 4;
251 } 251 }
252 else 252 else
253 { 253 {
254 pressedx = letterx1 + letterw * 4; 254 pressedx = letterx1 + letterw * 4;
255 pressed2x = letterx1; 255 pressed2x = letterx1;
256 } 256 }
257 pressedy = pressed2y = row * letterh; 257 pressedy = pressed2y = row * letterh;
258 pressedw = pressed2w = letterw * 2 + 1; 258 pressedw = pressed2w = letterw * 2 + 1;
259 pressedh = pressed2h = letterh + 1; 259 pressedh = pressed2h = letterh + 1;
260 isnoncont = true; 260 isnoncont = true;
261 } 261 }
262 else 262 else
263 { 263 {
264 pressedx = letterx1 + column * letterw; 264 pressedx = letterx1 + column * letterw;
265 pressedy = row * letterh; 265 pressedy = row * letterh;
266 pressedw = letterw + 1; 266 pressedw = letterw + 1;
267 pressedh = letterh + 1; 267 pressedh = letterh + 1;
268 } 268 }
269 pressedKeyUnicode = temp.unicode(); 269 pressedKeyUnicode = temp.unicode();
270 pressedKeyQcode = slideKeyQcodeH = slideKeyQcodeV = temp.upper().unicode(); 270 pressedKeyQcode = slideKeyQcodeH = slideKeyQcodeV = temp.upper().unicode();
@@ -471,281 +471,281 @@ void Keyboard::mouseReleaseEvent(QMouseEvent*)
471 { 471 {
472 paren = 0; 472 paren = 0;
473 releasedPix = &releasedPlain; 473 releasedPix = &releasedPlain;
474 pressedPix = &pressedPlain; 474 pressedPix = &pressedPlain;
475 bitBlt( &offscreen, 0, 0, releasedPix ); 475 bitBlt( &offscreen, 0, 0, releasedPix );
476 } 476 }
477 477
478 if ( alt && pressedKeyQcode != Qt::Key_Alt ) 478 if ( alt && pressedKeyQcode != Qt::Key_Alt )
479 alt = 0; 479 alt = 0;
480 if ( ctrl && pressedKeyQcode != Qt::Key_Control ) 480 if ( ctrl && pressedKeyQcode != Qt::Key_Control )
481 ctrl = 0; 481 ctrl = 0;
482 482
483 bitBlt( &offscreen, pressedx, pressedy, 483 bitBlt( &offscreen, pressedx, pressedy,
484 releasedPix, pressedx, pressedy, pressedw, pressedh ); 484 releasedPix, pressedx, pressedy, pressedw, pressedh );
485 485
486 if ( isnoncont ) 486 if ( isnoncont )
487 { 487 {
488 isnoncont = false; 488 isnoncont = false;
489 bitBlt( &offscreen, pressed2x, pressed2y, 489 bitBlt( &offscreen, pressed2x, pressed2y,
490 releasedPix, pressed2x, pressed2y, pressed2w, pressed2h ); 490 releasedPix, pressed2x, pressed2y, pressed2w, pressed2h );
491 } 491 }
492 492
493 repaint( false ); 493 repaint( false );
494} 494}
495 495
496void Keyboard::mouseMoveEvent(QMouseEvent *e) 496void Keyboard::mouseMoveEvent(QMouseEvent *e)
497{ 497{
498 if ( !enableMouseTracking ) 498 if ( !enableMouseTracking )
499 return; 499 return;
500 500
501 if ( e->x() < pressedx || e->x() >= pressedx + pressedw ) 501 if ( e->x() < pressedx || e->x() >= pressedx + pressedw )
502 { 502 {
503 pressedKeyUnicode = slideKeyUnicodeH; 503 pressedKeyUnicode = slideKeyUnicodeH;
504 pressedKeyQcode = slideKeyQcodeH; 504 pressedKeyQcode = slideKeyQcodeH;
505 slidePix = slidePixH; 505 slidePix = slidePixH;
506 } 506 }
507 else if ( e->y() < pressedy || e->y() >= pressedy + pressedh ) 507 else if ( e->y() < pressedy || e->y() >= pressedy + pressedh )
508 { 508 {
509 pressedKeyUnicode = slideKeyUnicodeV; 509 pressedKeyUnicode = slideKeyUnicodeV;
510 pressedKeyQcode = slideKeyQcodeV; 510 pressedKeyQcode = slideKeyQcodeV;
511 slidePix = slidePixV; 511 slidePix = slidePixV;
512 } 512 }
513 else 513 else
514 return; 514 return;
515 515
516 enableMouseTracking = false; 516 enableMouseTracking = false;
517 517
518 delayTimer->stop(); 518 delayTimer->stop();
519 rateTimer->stop(); 519 rateTimer->stop();
520 520
521 bitBlt( &offscreen, pressedx, pressedy, 521 bitBlt( &offscreen, pressedx, pressedy,
522 slidePix, pressedx, pressedy, pressedw, pressedh ); 522 slidePix, pressedx, pressedy, pressedw, pressedh );
523 523
524 emit key( 8, Qt::Key_Backspace, pressedMod, true, false ); 524 emit key( 8, Qt::Key_Backspace, pressedMod, true, false );
525 emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false ); 525 emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, false );
526 delayTimer->start( autorepeatDelaytime, true ); 526 delayTimer->start( autorepeatDelaytime, true );
527 527
528 repaint( false ); 528 repaint( false );
529} 529}
530 530
531void Keyboard::delayTimerDone() 531void Keyboard::delayTimerDone()
532{ 532{
533 emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true ); 533 emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true );
534 rateTimer->start( 1000/autorepeatRate, false ); 534 rateTimer->start( 1000/autorepeatRate, false );
535} 535}
536 536
537void Keyboard::rateTimerDone() 537void Keyboard::rateTimerDone()
538{ 538{
539 emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true ); 539 emit key( pressedKeyUnicode, pressedKeyQcode, pressedMod, true, true );
540} 540}
541 541
542QSize Keyboard::sizeHint() const 542QSize Keyboard::sizeHint() const
543{ 543{
544 return offscreen.size(); 544 return offscreen.size();
545} 545}
546 546
547void Keyboard::resetState() 547void Keyboard::resetState()
548{ 548{
549 //cout << "resetState()" << endl; 549 //cout << "resetState()" << endl;
550} 550}
551 551
552/* 552/*
553 * 553 *
554 * TODO 554 * TODO
555 * one major problem with this implementation is that you can't move the 555 * one major problem with this implementation is that you can't move the
556 * cursor after inputing korean chars, otherwise it will eat up and replace 556 * cursor after inputing korean chars, otherwise it will eat up and replace
557 * the char before the cursor you move to. fix that 557 * the char before the cursor you move to. fix that
558 * 558 *
559 * make a kor/eng swaping key 559 * make a kor/eng swaping key
560 * 560 *
561 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 561 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
562 * 562 *
563 * how korean input works 563 * how korean input works
564 * 564 *
565 * all following chars means unicode char value and are in hex 565 * all following chars means unicode char value and are in hex
566 * 566 *
567 * ÃÊÀ½ = schar (start char) 567 * �= = schar (start char)
568 * ÁßÀ½ = mchar (middle char) 568 * �= = mchar (middle char)
569 * ³¡À½ = echar (end char) 569 * = = echar (end char)
570 * 570 *
571 * there are 19 schars. unicode position is at 1100 - 1112 571 * there are 19 schars. unicode position is at 1100 - 1112
572 * there are 21 mchars. unicode position is at 1161 - 1175 572 * there are 21 mchars. unicode position is at 1161 - 1175
573 * there are 27 echars. unicode position is at 11a8 - 11c2 573 * there are 27 echars. unicode position is at 11a8 - 11c2
574 * 574 *
575 * the map with everything combined is at ac00 - d7a3 575 * the map with everything combined is at ac00 - d7a3
576 * 576 *
577 * to find a combination of schar + mchar in the map, lookup 577 * to find a combination of schar + mchar in the map, lookup
578 * ((schar - 0x1100) * 587) + ((mchar - 0x1161) * 27) + (echar - 0x11a8) + 0xac00) 578 * ((schar - 0x1100) * 587) + ((mchar - 0x1161) * 27) + (echar - 0x11a8) + 0xac00)
579 * 579 *
580 */ 580 */
581 581
582QChar Keyboard::parseKoreanInput (ushort c) { 582QChar Keyboard::parseKoreanInput (ushort c) {
583 583
584 static ushort schar, mchar, echar; 584 static ushort schar, mchar, echar;
585 585
586 if ((lastKey < 0x1100 || 0x11c2 < lastKey) && (lastKey < 0xac00 || 0xd7a3 < lastKey) 586 if ((lastKey < 0x1100 || 0x11c2 < lastKey) && (lastKey < 0xac00 || 0xd7a3 < lastKey)
587 && !(lastKey == 0 && (shift || paren || ctrl || alt))) { 587 && !(lastKey == 0 && (shift || paren || ctrl || alt))) {
588 588
589 //printf ("reset...\n"); 589 //printf ("reset...\n");
590 schar = 0, mchar = 0, echar = 0; 590 schar = 0, mchar = 0, echar = 0;
591 } 591 }
592 592
593 //printf ("in %x %x %x %x %x\n", schar, mchar, echar, c, lastKey); 593 //printf ("in %x %x %x %x %x\n", schar, mchar, echar, c, lastKey);
594 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input 594 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
595 595
596 if (schar == 0 || (schar != 0 && mchar == 0)) { 596 if (schar == 0 || (schar != 0 && mchar == 0)) {
597 schar = c; mchar = 0; echar = 0; 597 schar = c; mchar = 0; echar = 0;
598 return QChar(c); 598 return QChar(c);
599 } 599 }
600 else if (mchar != 0) { 600 else if (mchar != 0) {
601 601
602 if (echar == 0) { 602 if (echar == 0) {
603 603
604 if (!(echar = constoe(c))) { 604 if (!(echar = constoe(c))) {
605 605
606 schar = c; mchar = 0; echar = 0; 606 schar = c; mchar = 0; echar = 0;
607 return QChar(c); 607 return QChar(c);
608 } 608 }
609 609
610 } 610 }
611 else { // must figure out what the echar is 611 else { // must figure out what the echar is
612 612
613 if (echar == 0x11a8) { // ¤¡ 613 if (echar == 0x11a8) { //
614 614
615 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ 615 if (c == 0x1100) echar = 0x11a9; // +
616 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ 616 else if (c == 0x1109) echar = 0x11aa; // +
617 else { 617 else {
618 schar = c; mchar = 0; echar = 0; 618 schar = c; mchar = 0; echar = 0;
619 return QChar(c); 619 return QChar(c);
620 } 620 }
621 621
622 } else if (echar == 0x11ab) { // ¤¤ 622 } else if (echar == 0x11ab) { //
623 623
624 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ 624 if (c == 0x110c) echar = 0x11ac; // +
625 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ 625 else if (c == 0x1112) echar = 0x11ad; // +
626 else { 626 else {
627 schar = c; mchar = 0; echar = 0; 627 schar = c; mchar = 0; echar = 0;
628 return QChar(c); 628 return QChar(c);
629 } 629 }
630 630
631 } else if (echar == 0x11af) { // ¤© 631 } else if (echar == 0x11af) { //
632 632
633 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ 633 if (c == 0x1100) echar = 0x11b0; // +
634 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± 634 else if (c == 0x1106) echar = 0x11b1; // +
635 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² 635 else if (c == 0x1107) echar = 0x11b2; // +
636 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ 636 else if (c == 0x1109) echar = 0x11b3; // +
637 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ 637 else if (c == 0x1110) echar = 0x11b4; // +
638 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ 638 else if (c == 0x1111) echar = 0x11b5; // +
639 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ 639 else if (c == 0x1112) echar = 0x11b6; // +
640 else { 640 else {
641 schar = c; mchar = 0; echar = 0; 641 schar = c; mchar = 0; echar = 0;
642 return QChar(c); 642 return QChar(c);
643 } 643 }
644 644
645 } else if (echar == 0x11b8) { // ¤² 645 } else if (echar == 0x11b8) { //
646 646
647 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ 647 if (c == 0x1109) echar = 0x11b9; // +
648 else { 648 else {
649 schar = c; mchar = 0; echar = 0; 649 schar = c; mchar = 0; echar = 0;
650 return QChar(c); 650 return QChar(c);
651 } 651 }
652 652
653 } else if (echar == 0x11ba) { // ¤µ 653 } else if (echar == 0x11ba) { //
654 654
655 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ 655 if (c == 0x1109) echar = 0x11bb; // +
656 else { 656 else {
657 schar = c; mchar = 0; echar = 0; 657 schar = c; mchar = 0; echar = 0;
658 return QChar(c); 658 return QChar(c);
659 } 659 }
660 660
661 } else { // if any other char, cannot combine chars 661 } else { // if any other char, cannot combine chars
662 662
663 schar = c; mchar = 0; echar = 0; 663 schar = c; mchar = 0; echar = 0;
664 return QChar(c); 664 return QChar(c);
665 } 665 }
666 666
667 lastKey = echar; 667 lastKey = echar;
668 } 668 }
669 } 669 }
670 670
671 } 671 }
672 else if (0x1161 <= c && c <= 0x1175) { // mchar was input 672 else if (0x1161 <= c && c <= 0x1175) { // mchar was input
673 673
674 if (schar != 0 && mchar == 0) { mchar = c; } 674 if (schar != 0 && mchar == 0) { mchar = c; }
675 675
676 else if (schar != 0 && mchar != 0 && echar == 0) { 676 else if (schar != 0 && mchar != 0 && echar == 0) {
677 677
678 switch (mchar) { 678 switch (mchar) {
679 case 0x1169: 679 case 0x1169:
680 if (c == 0x1161) mchar = 0x116a; 680 if (c == 0x1161) mchar = 0x116a;
681 else if (c == 0x1162) mchar = 0x116b; 681 else if (c == 0x1162) mchar = 0x116b;
682 else if (c == 0x1175) mchar = 0x116c; 682 else if (c == 0x1175) mchar = 0x116c;
683 else { 683 else {
684 schar = 0; mchar = 0; echar = 0; 684 schar = 0; mchar = 0; echar = 0;
685 return QChar(c); 685 return QChar(c);
686 } 686 }
687 break; 687 break;
688 case 0x116e: 688 case 0x116e:
689 if (c == 0x1165) mchar = 0x116f; 689 if (c == 0x1165) mchar = 0x116f;
690 else if (c == 0x1166) mchar = 0x1170; 690 else if (c == 0x1166) mchar = 0x1170;
691 else if (c == 0x1175) mchar = 0x1171; 691 else if (c == 0x1175) mchar = 0x1171;
692 else { 692 else {
693 schar = 0; mchar = 0; echar = 0; 693 schar = 0; mchar = 0; echar = 0;
694 return QChar(c); 694 return QChar(c);
695 } 695 }
696 break; 696 break;
697 case 0x1173: 697 case 0x1173:
698 if (c == 0x1175) mchar = 0x1174; 698 if (c == 0x1175) mchar = 0x1174;
699 else { 699 else {
700 schar = 0; mchar = 0; echar = 0; 700 schar = 0; mchar = 0; echar = 0;
701 return QChar(c); 701 return QChar(c);
702 } 702 }
703 break; 703 break;
704 default: 704 default:
705 schar = 0; mchar = 0; echar = 0; 705 schar = 0; mchar = 0; echar = 0;
706 return QChar(c); 706 return QChar(c);
707 } 707 }
708 } 708 }
709 else if (schar != 0 && mchar != 0 && echar != 0) { 709 else if (schar != 0 && mchar != 0 && echar != 0) {
710 710
711 emit key( 8, Qt::Key_Backspace, 0, true, false ); 711 emit key( 8, Qt::Key_Backspace, 0, true, false );
712 712
713 ushort prev = 0; 713 ushort prev = 0;
714 switch (echar) { 714 switch (echar) {
715 /* 715 /*
716 case 0x11a9: 716 case 0x11a9:
717 prev = combineKoreanChars(schar, mchar, 0x11a8); 717 prev = combineKoreanChars(schar, mchar, 0x11a8);
718 schar = 0x1100; 718 schar = 0x1100;
719 break; 719 break;
720 */ 720 */
721 case 0x11aa: 721 case 0x11aa:
722 prev = combineKoreanChars(schar, mchar, 0x11a8); 722 prev = combineKoreanChars(schar, mchar, 0x11a8);
723 schar = 0x1109; 723 schar = 0x1109;
724 break; 724 break;
725 case 0x11ac: 725 case 0x11ac:
726 prev = combineKoreanChars(schar, mchar, 0x11ab); 726 prev = combineKoreanChars(schar, mchar, 0x11ab);
727 schar = 0x110c; 727 schar = 0x110c;
728 break; 728 break;
729 case 0x11ad: 729 case 0x11ad:
730 prev = combineKoreanChars(schar, mchar, 0x11ab); 730 prev = combineKoreanChars(schar, mchar, 0x11ab);
731 schar = 0x1112; 731 schar = 0x1112;
732 break; 732 break;
733 case 0x11b0: 733 case 0x11b0:
734 prev = combineKoreanChars(schar, mchar, 0x11af); 734 prev = combineKoreanChars(schar, mchar, 0x11af);
735 schar = 0x1100; 735 schar = 0x1100;
736 break; 736 break;
737 case 0x11b1: 737 case 0x11b1:
738 prev = combineKoreanChars(schar, mchar, 0x11af); 738 prev = combineKoreanChars(schar, mchar, 0x11af);
739 schar = 0x1106; 739 schar = 0x1106;
740 break; 740 break;
741 case 0x11b2: 741 case 0x11b2:
742 prev = combineKoreanChars(schar, mchar, 0x11af); 742 prev = combineKoreanChars(schar, mchar, 0x11af);
743 schar = 0x1107; 743 schar = 0x1107;
744 break; 744 break;
745 case 0x11b3: 745 case 0x11b3:
746 prev = combineKoreanChars(schar, mchar, 0x11af); 746 prev = combineKoreanChars(schar, mchar, 0x11af);
747 schar = 0x1109; 747 schar = 0x1109;
748 break; 748 break;
749 case 0x11b4: 749 case 0x11b4:
750 prev = combineKoreanChars(schar, mchar, 0x11af); 750 prev = combineKoreanChars(schar, mchar, 0x11af);
751 schar = 0x1110; 751 schar = 0x1110;