summaryrefslogtreecommitdiff
authorhash <hash>2002-08-22 06:47:27 (UTC)
committer hash <hash>2002-08-22 06:47:27 (UTC)
commit4ed706f6a327e06403e1def058b7290dcde3e634 (patch) (unidiff)
treeb31268a6673791d4163712d83592750345a1c672
parentee8b169221775d527fdf76947503e870dfef63aa (diff)
downloadopie-4ed706f6a327e06403e1def058b7290dcde3e634.zip
opie-4ed706f6a327e06403e1def058b7290dcde3e634.tar.gz
opie-4ed706f6a327e06403e1def058b7290dcde3e634.tar.bz2
comments behind shift and meta key map definitions wasnt working...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--inputmethods/multikey/keyboard.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/inputmethods/multikey/keyboard.cpp b/inputmethods/multikey/keyboard.cpp
index 74c99c7..1c17172 100644
--- a/inputmethods/multikey/keyboard.cpp
+++ b/inputmethods/multikey/keyboard.cpp
@@ -24,1234 +24,1237 @@
24#include <qpe/global.h> 24#include <qpe/global.h>
25#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
26 26
27#include <qwindowsystem_qws.h> 27#include <qwindowsystem_qws.h>
28#include <qpainter.h> 28#include <qpainter.h>
29#include <qfontmetrics.h> 29#include <qfontmetrics.h>
30#include <qtimer.h> 30#include <qtimer.h>
31#include <qpe/qpeapplication.h> 31#include <qpe/qpeapplication.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <ctype.h> 33#include <ctype.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qstringlist.h> 36#include <qstringlist.h>
37#include <iostream.h> 37#include <iostream.h>
38 38
39#include <sys/utsname.h> 39#include <sys/utsname.h>
40 40
41 41
42/* Keyboard::Keyboard {{{1 */ 42/* Keyboard::Keyboard {{{1 */
43Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) : 43Keyboard::Keyboard(QWidget* parent, const char* _name, WFlags f) :
44 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0), 44 QFrame(parent, _name, f), shift(0), lock(0), ctrl(0), alt(0), meta(0),
45 useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1), 45 useLargeKeys(TRUE), usePicks(0), useRepeat(0), pressedKeyRow(-1), pressedKeyCol(-1),
46 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0), 46 unicode(-1), qkeycode(0), modifiers(0), schar(0), mchar(0), echar(0),
47 configdlg(0) 47 configdlg(0)
48 48
49{ 49{
50 50
51 // get the default font 51 // get the default font
52 Config *config = new Config( "qpe" ); 52 Config *config = new Config( "qpe" );
53 config->setGroup( "Appearance" ); 53 config->setGroup( "Appearance" );
54 QString familyStr = config->readEntry( "FontFamily", "fixed" ); 54 QString familyStr = config->readEntry( "FontFamily", "fixed" );
55 delete config; 55 delete config;
56 56
57 config = new Config("multikey"); 57 config = new Config("multikey");
58 config->setGroup ("general"); 58 config->setGroup ("general");
59 usePicks = config->readBoolEntry ("usePickboard", "0"); // default closed 59 usePicks = config->readBoolEntry ("usePickboard", "0"); // default closed
60 useRepeat = config->readBoolEntry ("useRepeat", "1"); 60 useRepeat = config->readBoolEntry ("useRepeat", "1");
61 delete config; 61 delete config;
62 62
63 63
64 setFont( QFont( familyStr, 10 ) ); 64 setFont( QFont( familyStr, 10 ) );
65 65
66 picks = new KeyboardPicks( this ); 66 picks = new KeyboardPicks( this );
67 picks->setFont( QFont( familyStr, 10 ) ); 67 picks->setFont( QFont( familyStr, 10 ) );
68 picks->initialise(); 68 picks->initialise();
69 if (usePicks) { 69 if (usePicks) {
70 70
71 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 71 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
72 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 72 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
73 73
74 } else picks->hide(); 74 } else picks->hide();
75 75
76 loadKeyboardColors(); 76 loadKeyboardColors();
77 77
78 keys = new Keys(); 78 keys = new Keys();
79 79
80 repeatTimer = new QTimer( this ); 80 repeatTimer = new QTimer( this );
81 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) ); 81 connect( repeatTimer, SIGNAL(timeout()), this, SLOT(repeat()) );
82 82
83} 83}
84 84
85Keyboard::~Keyboard() { 85Keyboard::~Keyboard() {
86 86
87 if ( configdlg ) { 87 if ( configdlg ) {
88 delete (ConfigDlg *) configdlg; 88 delete (ConfigDlg *) configdlg;
89 configdlg = 0; 89 configdlg = 0;
90 } 90 }
91 91
92} 92}
93 93
94/* Keyboard::resizeEvent {{{1 */ 94/* Keyboard::resizeEvent {{{1 */
95void Keyboard::resizeEvent(QResizeEvent*) 95void Keyboard::resizeEvent(QResizeEvent*)
96{ 96{
97 int ph = picks->sizeHint().height(); 97 int ph = picks->sizeHint().height();
98 picks->setGeometry( 0, 0, width(), ph ); 98 picks->setGeometry( 0, 0, width(), ph );
99 keyHeight = (height()-(usePicks ? ph : 0))/5; 99 keyHeight = (height()-(usePicks ? ph : 0))/5;
100 100
101 int nk; // number of keys? 101 int nk; // number of keys?
102 if ( useLargeKeys ) { 102 if ( useLargeKeys ) {
103 nk = 15; 103 nk = 15;
104 } else { 104 } else {
105 nk = 19; 105 nk = 19;
106 } 106 }
107 defaultKeyWidth = (width()/nk)/2; 107 defaultKeyWidth = (width()/nk)/2;
108 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces? 108 xoffs = (width()-defaultKeyWidth*nk)/2; // empty key spaces?
109 109
110} 110}
111 111
112/* KeyboardPicks::initialize {{{1 */ 112/* KeyboardPicks::initialize {{{1 */
113void KeyboardPicks::initialise() 113void KeyboardPicks::initialise()
114{ 114{
115 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); 115 setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed));
116 mode = 0; 116 mode = 0;
117 dc = new KeyboardConfig(this); 117 dc = new KeyboardConfig(this);
118 configs.append(dc); 118 configs.append(dc);
119} 119}
120 120
121/* KeyboardPicks::sizeHint {{{1 */ 121/* KeyboardPicks::sizeHint {{{1 */
122QSize KeyboardPicks::sizeHint() const 122QSize KeyboardPicks::sizeHint() const
123{ 123{
124 return QSize(240,fontMetrics().lineSpacing()); 124 return QSize(240,fontMetrics().lineSpacing());
125} 125}
126 126
127 127
128/* KeyboardConfig::generateText {{{1 */ 128/* KeyboardConfig::generateText {{{1 */
129void KeyboardConfig::generateText(const QString &s) 129void KeyboardConfig::generateText(const QString &s)
130{ 130{
131#if defined(Q_WS_QWS) || defined(_WS_QWS_) 131#if defined(Q_WS_QWS) || defined(_WS_QWS_)
132 for (int i=0; i<(int)backspaces; i++) { 132 for (int i=0; i<(int)backspaces; i++) {
133 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false ); 133 parent->emitKey( 0, Qt::Key_Backspace, 0, true, false );
134 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false ); 134 parent->emitKey( 0, Qt::Key_Backspace, 0, false, false );
135 } 135 }
136 for (int i=0; i<(int)s.length(); i++) { 136 for (int i=0; i<(int)s.length(); i++) {
137 parent->emitKey( s[i].unicode(), 0, 0, true, false ); 137 parent->emitKey( s[i].unicode(), 0, 0, true, false );
138 parent->emitKey( s[i].unicode(), 0, 0, false, false ); 138 parent->emitKey( s[i].unicode(), 0, 0, false, false );
139 } 139 }
140 parent->emitKey( 0, Qt::Key_Space, 0, true, false ); 140 parent->emitKey( 0, Qt::Key_Space, 0, true, false );
141 parent->emitKey( 0, Qt::Key_Space, 0, false, false ); 141 parent->emitKey( 0, Qt::Key_Space, 0, false, false );
142 backspaces = 0; 142 backspaces = 0;
143#endif 143#endif
144} 144}
145 145
146 146
147 147
148 148
149/* Keyboard::paintEvent {{{1 */ 149/* Keyboard::paintEvent {{{1 */
150void Keyboard::paintEvent(QPaintEvent* e) 150void Keyboard::paintEvent(QPaintEvent* e)
151{ 151{
152 QPainter painter(this); 152 QPainter painter(this);
153 painter.setClipRect(e->rect()); 153 painter.setClipRect(e->rect());
154 drawKeyboard( painter ); 154 drawKeyboard( painter );
155 picks->dc->draw( &painter ); 155 picks->dc->draw( &painter );
156} 156}
157 157
158 158
159/* Keyboard::drawKeyboard {{{1 */ 159/* Keyboard::drawKeyboard {{{1 */
160 160
161void Keyboard::drawKeyboard(QPainter &p, int row, int col) 161void Keyboard::drawKeyboard(QPainter &p, int row, int col)
162{ 162{
163 163
164 164
165 if (row != -1 && col != -1) { //just redraw one key 165 if (row != -1 && col != -1) { //just redraw one key
166 166
167 int x = 0; 167 int x = 0;
168 for (int i = 0; i < col; i++) { 168 for (int i = 0; i < col; i++) {
169 169
170 x += keys->width(row, i) * defaultKeyWidth; 170 x += keys->width(row, i) * defaultKeyWidth;
171 } 171 }
172 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 172 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
173 173
174 int keyWidth = keys->width(row, col); 174 int keyWidth = keys->width(row, col);
175 175
176 p.fillRect(x + 1, y + 1, 176 p.fillRect(x + 1, y + 1,
177 keyWidth * defaultKeyWidth - 1, keyHeight - 1, 177 keyWidth * defaultKeyWidth - 1, keyHeight - 1,
178 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor); 178 pressed || keys->pressed(row, col) ? keycolor_pressed : keycolor);
179 179
180 QPixmap *pix = keys->pix(row,col); 180 QPixmap *pix = keys->pix(row,col);
181 181
182 ushort c = keys->uni(row, col); 182 ushort c = keys->uni(row, col);
183 183
184 p.setPen(textcolor); 184 p.setPen(textcolor);
185 if (!pix) { 185 if (!pix) {
186 if (shift || lock) 186 if (shift || lock)
187 c = keys->shift(c); 187 c = keys->shift(c);
188 if (meta) { 188 if (meta) {
189 189
190 c = keys->meta(c); 190 c = keys->meta(c);
191 } 191 }
192 p.drawText(x, y, 192 p.drawText(x, y,
193 defaultKeyWidth * keyWidth + 3, keyHeight, 193 defaultKeyWidth * keyWidth + 3, keyHeight,
194 AlignCenter, (QChar)c); 194 AlignCenter, (QChar)c);
195 } 195 }
196 else 196 else
197 // center the image in the middle of the key 197 // center the image in the middle of the key
198 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2, 198 p.drawPixmap( x + (defaultKeyWidth * keyWidth - pix->width())/2,
199 y + (keyHeight - pix->height())/2 + 1, 199 y + (keyHeight - pix->height())/2 + 1,
200 *pix ); 200 *pix );
201 201
202 // this fixes the problem that the very right end of the board's vertical line 202 // this fixes the problem that the very right end of the board's vertical line
203 // gets painted over, because it's one pixel shorter than all other keys 203 // gets painted over, because it's one pixel shorter than all other keys
204 p.setPen(keycolor_lines); 204 p.setPen(keycolor_lines);
205 p.drawLine(width() - 1, 0, width() - 1, height()); 205 p.drawLine(width() - 1, 0, width() - 1, height());
206 206
207 } else { 207 } else {
208 208
209 209
210 p.fillRect(0, 0, width(), height(), keycolor); 210 p.fillRect(0, 0, width(), height(), keycolor);
211 211
212 for (row = 1; row <= 5; row++) { 212 for (row = 1; row <= 5; row++) {
213 213
214 int x = 0; 214 int x = 0;
215 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0); 215 int y = (row - 1) * keyHeight + (usePicks ? picks->height() : 0);
216 216
217 p.setPen(keycolor_lines); 217 p.setPen(keycolor_lines);
218 p.drawLine(x, y, x + width(), y); 218 p.drawLine(x, y, x + width(), y);
219 219
220 for (int col = 0; col < keys->numKeys(row); col++) { 220 for (int col = 0; col < keys->numKeys(row); col++) {
221 221
222 QPixmap *pix = keys->pix(row, col); 222 QPixmap *pix = keys->pix(row, col);
223 int keyWidth = keys->width(row, col); 223 int keyWidth = keys->width(row, col);
224 224
225 225
226 int keyWidthPix = defaultKeyWidth * keyWidth; 226 int keyWidthPix = defaultKeyWidth * keyWidth;
227 227
228 if (keys->pressed(row, col)) 228 if (keys->pressed(row, col))
229 p.fillRect(x+1, y+1, keyWidthPix - 1, 229 p.fillRect(x+1, y+1, keyWidthPix - 1,
230 keyHeight - 1, keycolor_pressed); 230 keyHeight - 1, keycolor_pressed);
231 231
232 ushort c = keys->uni(row, col); 232 ushort c = keys->uni(row, col);
233 233
234 if (!pix) { 234 if (!pix) {
235 if ((shift || lock) && keys->shift(c)) 235 if ((shift || lock) && keys->shift(c))
236 c = keys->shift(c); 236 c = keys->shift(c);
237 else if (meta && keys->meta(c)) 237 else if (meta && keys->meta(c))
238 c = keys->meta(c); 238 c = keys->meta(c);
239 239
240 p.drawText(x, y, 240 p.drawText(x, y,
241 defaultKeyWidth * keyWidth + 3, keyHeight, 241 defaultKeyWidth * keyWidth + 3, keyHeight,
242 AlignCenter, (QChar)c); 242 AlignCenter, (QChar)c);
243 } 243 }
244 else { 244 else {
245 // center the image in the middle of the key 245 // center the image in the middle of the key
246 p.drawPixmap( x + (keyWidthPix - pix->width())/2, 246 p.drawPixmap( x + (keyWidthPix - pix->width())/2,
247 y + (keyHeight - pix->height())/2 + 1, 247 y + (keyHeight - pix->height())/2 + 1,
248 QPixmap(*pix) ); 248 QPixmap(*pix) );
249 } 249 }
250 250
251 p.setPen(keycolor_lines); 251 p.setPen(keycolor_lines);
252 p.drawLine(x, y, x, y + keyHeight); 252 p.drawLine(x, y, x, y + keyHeight);
253 253
254 x += keyWidthPix; 254 x += keyWidthPix;
255 } 255 }
256 256
257 257
258 } 258 }
259 p.drawLine(0, height() - 1, width(), height() - 1); 259 p.drawLine(0, height() - 1, width(), height() - 1);
260 p.drawLine(width() - 1, 0, width() - 1, height()); 260 p.drawLine(width() - 1, 0, width() - 1, height());
261 } 261 }
262 262
263} 263}
264 264
265 265
266/* Keyboard::mousePressEvent {{{1 */ 266/* Keyboard::mousePressEvent {{{1 */
267void Keyboard::mousePressEvent(QMouseEvent *e) 267void Keyboard::mousePressEvent(QMouseEvent *e)
268{ 268{
269 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1; 269 int row = (e->y() - (usePicks ? picks->height() : 0)) / keyHeight + 1;
270 if (row > 5) row = 5; 270 if (row > 5) row = 5;
271 271
272 // figure out the column 272 // figure out the column
273 int col = 0; 273 int col = 0;
274 for (int w = 0; e->x() >= w; col++) 274 for (int w = 0; e->x() >= w; col++)
275 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys 275 if (col < keys->numKeys(row)) // it segfaults if it trys to read past numKeys
276 w += keys->width(row,col) * defaultKeyWidth; 276 w += keys->width(row,col) * defaultKeyWidth;
277 else break; 277 else break;
278 278
279 if (col <= 0) return; 279 if (col <= 0) return;
280 280
281 col --; // rewind one... 281 col --; // rewind one...
282 282
283 qkeycode = keys->qcode(row, col); 283 qkeycode = keys->qcode(row, col);
284 unicode = keys->uni(row, col); 284 unicode = keys->uni(row, col);
285 285
286 // might need to repaint if two or more of the same keys. 286 // might need to repaint if two or more of the same keys.
287 // should be faster if just paint one key even though multiple keys exist. 287 // should be faster if just paint one key even though multiple keys exist.
288 bool need_repaint = FALSE; 288 bool need_repaint = FALSE;
289 289
290 if (unicode == 0) { // either Qt char, or nothing 290 if (unicode == 0) { // either Qt char, or nothing
291 291
292 if (qkeycode == Qt::Key_F1) { // toggle the pickboard 292 if (qkeycode == Qt::Key_F1) { // toggle the pickboard
293 293
294 if ( configdlg ) { 294 if ( configdlg ) {
295 delete (ConfigDlg *) configdlg; 295 delete (ConfigDlg *) configdlg;
296 configdlg = 0; 296 configdlg = 0;
297 } 297 }
298 else { 298 else {
299 configdlg = new ConfigDlg (); 299 configdlg = new ConfigDlg ();
300 connect(configdlg, SIGNAL(setMapToDefault()), 300 connect(configdlg, SIGNAL(setMapToDefault()),
301 this, SLOT(setMapToDefault())); 301 this, SLOT(setMapToDefault()));
302 connect(configdlg, SIGNAL(setMapToFile(QString)), 302 connect(configdlg, SIGNAL(setMapToFile(QString)),
303 this, SLOT(setMapToFile(QString))); 303 this, SLOT(setMapToFile(QString)));
304 connect(configdlg, SIGNAL(pickboardToggled(bool)), 304 connect(configdlg, SIGNAL(pickboardToggled(bool)),
305 this, SLOT(togglePickboard(bool))); 305 this, SLOT(togglePickboard(bool)));
306 connect(configdlg, SIGNAL(repeatToggled(bool)), 306 connect(configdlg, SIGNAL(repeatToggled(bool)),
307 this, SLOT(toggleRepeat(bool))); 307 this, SLOT(toggleRepeat(bool)));
308 connect(configdlg, SIGNAL(reloadKeyboard()), 308 connect(configdlg, SIGNAL(reloadKeyboard()),
309 this, SLOT(reloadKeyboard())); 309 this, SLOT(reloadKeyboard()));
310 configdlg->showMaximized(); 310 configdlg->showMaximized();
311 configdlg->show(); 311 configdlg->show();
312 configdlg->raise(); 312 configdlg->raise();
313 } 313 }
314 314
315 } else if (qkeycode == Qt::Key_Control) { 315 } else if (qkeycode == Qt::Key_Control) {
316 316
317 if (ctrl) { 317 if (ctrl) {
318 318
319 *ctrl = 0; 319 *ctrl = 0;
320 ctrl = 0; 320 ctrl = 0;
321 321
322 } else { 322 } else {
323 323
324 ctrl = keys->pressedPtr(row, col); 324 ctrl = keys->pressedPtr(row, col);
325 need_repaint = TRUE; 325 need_repaint = TRUE;
326 *ctrl = !keys->pressed(row, col); 326 *ctrl = !keys->pressed(row, col);
327 327
328 } 328 }
329 329
330 } else if (qkeycode == Qt::Key_Alt) { 330 } else if (qkeycode == Qt::Key_Alt) {
331 331
332 if (alt) { 332 if (alt) {
333 *alt = 0; 333 *alt = 0;
334 alt = 0; 334 alt = 0;
335 335
336 } else { 336 } else {
337 337
338 alt = keys->pressedPtr(row, col); 338 alt = keys->pressedPtr(row, col);
339 need_repaint = TRUE; 339 need_repaint = TRUE;
340 *alt = !keys->pressed(row, col); 340 *alt = !keys->pressed(row, col);
341 } 341 }
342 342
343 } else if (qkeycode == Qt::Key_Shift) { 343 } else if (qkeycode == Qt::Key_Shift) {
344 need_repaint = TRUE; 344 need_repaint = TRUE;
345 345
346 if (shift) { 346 if (shift) {
347 *shift = 0; 347 *shift = 0;
348 shift = 0; 348 shift = 0;
349 } 349 }
350 else { 350 else {
351 shift = keys->pressedPtr(row, col); 351 shift = keys->pressedPtr(row, col);
352 *shift = 1; 352 *shift = 1;
353 if (lock) { 353 if (lock) {
354 *lock = 0; 354 *lock = 0;
355 lock = 0; 355 lock = 0;
356 } 356 }
357 } 357 }
358 if (meta) { 358 if (meta) {
359 359
360 *meta = 0; 360 *meta = 0;
361 meta = 0; 361 meta = 0;
362 } 362 }
363 363
364 } else if (qkeycode == Qt::Key_CapsLock) { 364 } else if (qkeycode == Qt::Key_CapsLock) {
365 need_repaint = TRUE; 365 need_repaint = TRUE;
366 366
367 if (lock) { 367 if (lock) {
368 *lock = 0; 368 *lock = 0;
369 lock = 0; 369 lock = 0;
370 } 370 }
371 else { 371 else {
372 lock = keys->pressedPtr(row, col);; 372 lock = keys->pressedPtr(row, col);;
373 *lock = 1; 373 *lock = 1;
374 if (shift) { 374 if (shift) {
375 *shift = 0; 375 *shift = 0;
376 shift = 0; 376 shift = 0;
377 } 377 }
378 } 378 }
379 if (meta) { 379 if (meta) {
380 380
381 *meta = 0; 381 *meta = 0;
382 meta = 0; 382 meta = 0;
383 } 383 }
384 384
385 } else if (qkeycode == Qt::Key_Meta) { 385 } else if (qkeycode == Qt::Key_Meta) {
386 need_repaint = TRUE; 386 need_repaint = TRUE;
387 387
388 if (meta) { 388 if (meta) {
389 *meta = 0; 389 *meta = 0;
390 meta = 0; 390 meta = 0;
391 391
392 } else { 392 } else {
393 393
394 meta = keys->pressedPtr(row, col); 394 meta = keys->pressedPtr(row, col);
395 need_repaint = TRUE; 395 need_repaint = TRUE;
396 *meta = !keys->pressed(row, col); 396 *meta = !keys->pressed(row, col);
397 } 397 }
398 398
399 if (shift) { 399 if (shift) {
400 400
401 *shift = 0; 401 *shift = 0;
402 shift = 0; 402 shift = 0;
403 403
404 } 404 }
405 if (lock) { 405 if (lock) {
406 406
407 *lock = 0; 407 *lock = 0;
408 lock = 0; 408 lock = 0;
409 409
410 } 410 }
411 411
412 // dont need to emit this key... acts same as alt 412 // dont need to emit this key... acts same as alt
413 qkeycode = 0; 413 qkeycode = 0;
414 } 414 }
415 415
416 } 416 }
417 else { // normal char 417 else { // normal char
418 if ((shift || lock) && keys->shift(unicode)) { 418 if ((shift || lock) && keys->shift(unicode)) {
419 unicode = keys->shift(unicode); 419 unicode = keys->shift(unicode);
420 } 420 }
421 if (meta && keys->meta(unicode)) { 421 if (meta && keys->meta(unicode)) {
422 unicode = keys->meta(unicode); 422 unicode = keys->meta(unicode);
423 } 423 }
424 } 424 }
425 425
426 // korean parsing 426 // korean parsing
427 if (keys->lang == "ko") { 427 if (keys->lang == "ko") {
428 428
429 unicode = parseKoreanInput(unicode); 429 unicode = parseKoreanInput(unicode);
430 } 430 }
431 431
432 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0); 432 modifiers = (ctrl ? Qt::ControlButton : 0) | (alt ? Qt::AltButton : 0);
433 433
434 if ('A' <= unicode && unicode <= 'z' && modifiers) { 434 if ('A' <= unicode && unicode <= 'z' && modifiers) {
435 435
436 qkeycode = QChar(unicode).upper(); 436 qkeycode = QChar(unicode).upper();
437 unicode = qkeycode - '@'; 437 unicode = qkeycode - '@';
438 } 438 }
439 439
440 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false); 440 QWSServer::sendKeyEvent(unicode, qkeycode, modifiers, true, false);
441 441
442 // pickboard stuff 442 // pickboard stuff
443 if (usePicks) { 443 if (usePicks) {
444 444
445 KeyboardConfig *dc = picks->dc; 445 KeyboardConfig *dc = picks->dc;
446 446
447 if (dc) { 447 if (dc) {
448 if (qkeycode == Qt::Key_Backspace) { 448 if (qkeycode == Qt::Key_Backspace) {
449 dc->input.remove(dc->input.last()); // remove last input 449 dc->input.remove(dc->input.last()); // remove last input
450 dc->decBackspaces(); 450 dc->decBackspaces();
451 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) { 451 } else if ( qkeycode == Qt::Key_Return || QChar(unicode).isPunct() || QChar(unicode).isSpace() || unicode == 0) {
452 dc->input.clear(); 452 dc->input.clear();
453 dc->resetBackspaces(); 453 dc->resetBackspaces();
454 } else { 454 } else {
455 dc->add(QString(QChar(unicode))); 455 dc->add(QString(QChar(unicode)));
456 dc->incBackspaces(); 456 dc->incBackspaces();
457 } 457 }
458 } 458 }
459 picks->repaint(); 459 picks->repaint();
460 } 460 }
461 461
462 462
463 // painting 463 // painting
464 pressed = TRUE; 464 pressed = TRUE;
465 465
466 pressedKeyRow = row; 466 pressedKeyRow = row;
467 pressedKeyCol = col; 467 pressedKeyCol = col;
468 468
469 if (need_repaint) repaint(FALSE); 469 if (need_repaint) repaint(FALSE);
470 else { // just paint the one key pressed 470 else { // just paint the one key pressed
471 471
472 472
473 473
474 QPainter p(this); 474 QPainter p(this);
475 drawKeyboard(p, row, col); 475 drawKeyboard(p, row, col);
476 476
477 } 477 }
478 478
479 if (useRepeat) repeatTimer->start( 800 ); 479 if (useRepeat) repeatTimer->start( 800 );
480 //pressTid = startTimer(80); 480 //pressTid = startTimer(80);
481 481
482} 482}
483 483
484 484
485/* Keyboard::mouseReleaseEvent {{{1 */ 485/* Keyboard::mouseReleaseEvent {{{1 */
486void Keyboard::mouseReleaseEvent(QMouseEvent*) 486void Keyboard::mouseReleaseEvent(QMouseEvent*)
487{ 487{
488 pressed = FALSE; 488 pressed = FALSE;
489 //if ( pressTid == 0 ) 489 //if ( pressTid == 0 )
490#if defined(Q_WS_QWS) || defined(_WS_QWS_) 490#if defined(Q_WS_QWS) || defined(_WS_QWS_)
491 if ( unicode != -1 ) { 491 if ( unicode != -1 ) {
492 emit key( unicode, qkeycode, modifiers, false, false ); 492 emit key( unicode, qkeycode, modifiers, false, false );
493 repeatTimer->stop(); 493 repeatTimer->stop();
494 } 494 }
495#endif 495#endif
496 if (shift && unicode != 0) { 496 if (shift && unicode != 0) {
497 497
498 498
499 *shift = 0; // unpress shift key 499 *shift = 0; // unpress shift key
500 shift = 0; // reset the shift pointer 500 shift = 0; // reset the shift pointer
501 repaint(FALSE); 501 repaint(FALSE);
502 502
503 } else if (meta && unicode != 0) { 503 } else if (meta && unicode != 0) {
504 504
505 *meta = 0; 505 *meta = 0;
506 meta = 0; 506 meta = 0;
507 repaint(FALSE); 507 repaint(FALSE);
508 } 508 }
509 else 509 else
510 510
511 clearHighlight(); 511 clearHighlight();
512} 512}
513 513
514/* Keyboard::timerEvent {{{1 */ 514/* Keyboard::timerEvent {{{1 */
515 515
516/* dont know what this does, but i think it is here so that if your screen 516/* dont know what this does, but i think it is here so that if your screen
517 * sticks (like on an ipaq) then it will stop repeating if you click another 517 * sticks (like on an ipaq) then it will stop repeating if you click another
518 * key... but who knows what anything does in this thing anyway? 518 * key... but who knows what anything does in this thing anyway?
519 519
520 void Keyboard::timerEvent(QTimerEvent* e) 520 void Keyboard::timerEvent(QTimerEvent* e)
521{ 521{
522 if ( e->timerId() == pressTid ) { 522 if ( e->timerId() == pressTid ) {
523 killTimer(pressTid); 523 killTimer(pressTid);
524 pressTid = 0; 524 pressTid = 0;
525 if ( !pressed ) 525 if ( !pressed )
526 cout << "calling clearHighlight from timerEvent\n"; 526 cout << "calling clearHighlight from timerEvent\n";
527 //clearHighlight(); 527 //clearHighlight();
528 } 528 }
529} 529}
530*/ 530*/
531 531
532void Keyboard::repeat() 532void Keyboard::repeat()
533{ 533{
534 534
535 repeatTimer->start( 200 ); 535 repeatTimer->start( 200 );
536 emit key( unicode, qkeycode, modifiers, true, true ); 536 emit key( unicode, qkeycode, modifiers, true, true );
537} 537}
538 538
539void Keyboard::clearHighlight() 539void Keyboard::clearHighlight()
540{ 540{
541 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) { 541 if ( pressedKeyRow >= 0 && pressedKeyCol >= 0) {
542 int tmpRow = pressedKeyRow; 542 int tmpRow = pressedKeyRow;
543 int tmpCol = pressedKeyCol; 543 int tmpCol = pressedKeyCol;
544 544
545 pressedKeyRow = -1; 545 pressedKeyRow = -1;
546 pressedKeyCol = -1; 546 pressedKeyCol = -1;
547 547
548 QPainter p(this); 548 QPainter p(this);
549 drawKeyboard(p, tmpRow, tmpCol); 549 drawKeyboard(p, tmpRow, tmpCol);
550 } 550 }
551} 551}
552 552
553 553
554/* Keyboard::sizeHint {{{1 */ 554/* Keyboard::sizeHint {{{1 */
555QSize Keyboard::sizeHint() const 555QSize Keyboard::sizeHint() const
556{ 556{
557 QFontMetrics fm=fontMetrics(); 557 QFontMetrics fm=fontMetrics();
558 int keyHeight = fm.lineSpacing() + 2; 558 int keyHeight = fm.lineSpacing() + 2;
559 559
560 return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1); 560 return QSize( 240, keyHeight * 5 + (usePicks ? picks->sizeHint().height() : 0) + 1);
561} 561}
562 562
563 563
564void Keyboard::resetState() 564void Keyboard::resetState()
565{ 565{
566 schar = mchar = echar = 0; 566 schar = mchar = echar = 0;
567 picks->resetState(); 567 picks->resetState();
568} 568}
569 569
570/* Keyboard::togglePickboard {{{1 */ 570/* Keyboard::togglePickboard {{{1 */
571void Keyboard::togglePickboard(bool on_off) 571void Keyboard::togglePickboard(bool on_off)
572{ 572{
573 usePicks = on_off; 573 usePicks = on_off;
574 if (usePicks) { 574 if (usePicks) {
575 picks->show(); 575 picks->show();
576 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send 576 //move(x(), y() - picks->height()); // not required anymore because QCopChannel::send
577 //adjustSize(); 577 //adjustSize();
578 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 578 QObject::connect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
579 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 579 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
580 } else { 580 } else {
581 581
582 picks->hide(); 582 picks->hide();
583 picks->resetState(); 583 picks->resetState();
584 //move(x(), y() + picks->height()); 584 //move(x(), y() + picks->height());
585 //adjustSize(); 585 //adjustSize();
586 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ), 586 QObject::disconnect( picks, SIGNAL(key(ushort,ushort,ushort,bool,bool) ),
587 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) ); 587 this, SIGNAL(key(ushort,ushort,ushort,bool,bool)) );
588 588
589 } 589 }
590 /* 590 /*
591 * this closes && opens the input method 591 * this closes && opens the input method
592 */ 592 */
593 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()"); 593 QCopChannel::send ("QPE/TaskBar", "hideInputMethod()");
594 QCopChannel::send ("QPE/TaskBar", "showInputMethod()"); 594 QCopChannel::send ("QPE/TaskBar", "showInputMethod()");
595} 595}
596 596
597void Keyboard::toggleRepeat(bool on) { 597void Keyboard::toggleRepeat(bool on) {
598 598
599 useRepeat = on; 599 useRepeat = on;
600 cout << "setting useRepeat to: " << useRepeat << "\n"; 600 cout << "setting useRepeat to: " << useRepeat << "\n";
601} 601}
602 602
603/* Keyboard::setMapTo ... {{{1 */ 603/* Keyboard::setMapTo ... {{{1 */
604void Keyboard::setMapToDefault() { 604void Keyboard::setMapToDefault() {
605 605
606 606
607 /* load current locale language map */ 607 /* load current locale language map */
608 Config *config = new Config("locale"); 608 Config *config = new Config("locale");
609 config->setGroup( "Language" ); 609 config->setGroup( "Language" );
610 QString l = config->readEntry( "Language" , "en" ); 610 QString l = config->readEntry( "Language" , "en" );
611 delete config; 611 delete config;
612 612
613 QString key_map = QPEApplication::qpeDir() + "/share/multikey/" 613 QString key_map = QPEApplication::qpeDir() + "/share/multikey/"
614 + l + ".keymap"; 614 + l + ".keymap";
615 615
616 /* save change to multikey config file */ 616 /* save change to multikey config file */
617 config = new Config("multikey"); 617 config = new Config("multikey");
618 config->setGroup ("keymaps"); 618 config->setGroup ("keymaps");
619 config->writeEntry ("current", key_map); // default closed 619 config->writeEntry ("current", key_map); // default closed
620 delete config; 620 delete config;
621 621
622 delete keys; 622 delete keys;
623 keys = new Keys(key_map); 623 keys = new Keys(key_map);
624 624
625 // have to repaint the keyboard 625 // have to repaint the keyboard
626 repaint(FALSE); 626 repaint(FALSE);
627} 627}
628 628
629void Keyboard::setMapToFile(QString map) { 629void Keyboard::setMapToFile(QString map) {
630 630
631 /* save change to multikey config file */ 631 /* save change to multikey config file */
632 Config *config = new Config("multikey"); 632 Config *config = new Config("multikey");
633 config->setGroup ("keymaps"); 633 config->setGroup ("keymaps");
634 config->writeEntry ("current", map); // default closed 634 config->writeEntry ("current", map); // default closed
635 635
636 delete config; 636 delete config;
637 637
638 delete keys; 638 delete keys;
639 if (QFile(map).exists()) 639 if (QFile(map).exists())
640 keys = new Keys(map); 640 keys = new Keys(map);
641 else 641 else
642 keys = new Keys(); 642 keys = new Keys();
643 643
644 repaint(FALSE); 644 repaint(FALSE);
645 645
646} 646}
647 647
648/* Keybaord::reloadKeyboard {{{1 */ 648/* Keybaord::reloadKeyboard {{{1 */
649void Keyboard::reloadKeyboard() { 649void Keyboard::reloadKeyboard() {
650 650
651 // reload colors and redraw 651 // reload colors and redraw
652 loadKeyboardColors(); 652 loadKeyboardColors();
653 repaint(); 653 repaint();
654 654
655} 655}
656 656
657void Keyboard::loadKeyboardColors() { 657void Keyboard::loadKeyboardColors() {
658 658
659 Config config ("multikey"); 659 Config config ("multikey");
660 config.setGroup("colors"); 660 config.setGroup("colors");
661 661
662 QStringList color; 662 QStringList color;
663 color = config.readListEntry("keycolor", QChar(',')); 663 color = config.readListEntry("keycolor", QChar(','));
664 if (color.isEmpty()) { 664 if (color.isEmpty()) {
665 color = QStringList::split(",", "240,240,240"); 665 color = QStringList::split(",", "240,240,240");
666 config.writeEntry("keycolor", color.join(",")); 666 config.writeEntry("keycolor", color.join(","));
667 667
668 } 668 }
669 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 669 keycolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
670 670
671 color = config.readListEntry("keycolor_pressed", QChar(',')); 671 color = config.readListEntry("keycolor_pressed", QChar(','));
672 if (color.isEmpty()) { 672 if (color.isEmpty()) {
673 color = QStringList::split(",", "171,183,198"); 673 color = QStringList::split(",", "171,183,198");
674 config.writeEntry("keycolor_pressed", color.join(",")); 674 config.writeEntry("keycolor_pressed", color.join(","));
675 675
676 } 676 }
677 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 677 keycolor_pressed = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
678 678
679 color = config.readListEntry("keycolor_lines", QChar(',')); 679 color = config.readListEntry("keycolor_lines", QChar(','));
680 if (color.isEmpty()) { 680 if (color.isEmpty()) {
681 color = QStringList::split(",", "138,148,160"); 681 color = QStringList::split(",", "138,148,160");
682 config.writeEntry("keycolor_lines", color.join(",")); 682 config.writeEntry("keycolor_lines", color.join(","));
683 683
684 } 684 }
685 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 685 keycolor_lines = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
686 686
687 color = config.readListEntry("textcolor", QChar(',')); 687 color = config.readListEntry("textcolor", QChar(','));
688 if (color.isEmpty()) { 688 if (color.isEmpty()) {
689 color = QStringList::split(",", "43,54,68"); 689 color = QStringList::split(",", "43,54,68");
690 config.writeEntry("textcolor", color.join(",")); 690 config.writeEntry("textcolor", color.join(","));
691 691
692 } 692 }
693 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt()); 693 textcolor = QColor(color[0].toInt(), color[1].toInt(), color[2].toInt());
694 694
695} 695}
696 696
697/* korean input functions {{{1 697/* korean input functions {{{1
698 * 698 *
699 * TODO 699 * TODO
700 * one major problem with this implementation is that you can't move the 700 * one major problem with this implementation is that you can't move the
701 * cursor after inputing korean chars, otherwise it will eat up and replace 701 * cursor after inputing korean chars, otherwise it will eat up and replace
702 * the char before the cursor you move to. fix that 702 * the char before the cursor you move to. fix that
703 * 703 *
704 * make backspace delete one single char, not the whole thing if still 704 * make backspace delete one single char, not the whole thing if still
705 * editing. 705 * editing.
706 * 706 *
707 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 707 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
708 * 708 *
709 * how korean input works 709 * how korean input works
710 * 710 *
711 * all following chars means unicode char value and are in hex 711 * all following chars means unicode char value and are in hex
712 * 712 *
713 * ÃÊÀ½ = schar (start char) 713 * ÃÊÀ½ = schar (start char)
714 * ÁßÀ½ = mchar (middle char) 714 * ÁßÀ½ = mchar (middle char)
715 * ³¡À½ = echar (end char) 715 * ³¡À½ = echar (end char)
716 * 716 *
717 * there are 19 schars. unicode position is at 1100 - 1112 717 * there are 19 schars. unicode position is at 1100 - 1112
718 * there are 21 mchars. unicode position is at 1161 - 1175 718 * there are 21 mchars. unicode position is at 1161 - 1175
719 * there are 27 echars. unicode position is at 11a8 - 11c2 719 * there are 27 echars. unicode position is at 11a8 - 11c2
720 * 720 *
721 * the map with everything combined is at ac00 - d7a3 721 * the map with everything combined is at ac00 - d7a3
722 * 722 *
723 */ 723 */
724 724
725ushort Keyboard::parseKoreanInput (ushort c) { 725ushort Keyboard::parseKoreanInput (ushort c) {
726 726
727 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c)) 727 if ((c != 0 && (c < 0x1100 || 0x11c2 < c) && (c < 0xac00 || 0xd7a3 < c))
728 || 728 ||
729 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode 729 (c == 0 && qkeycode != Qt::Key_Shift && Qt::Key_CapsLock != qkeycode
730 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) { 730 && qkeycode != Qt::Key_Control && qkeycode != Qt::Key_Alt)) {
731 731
732 schar = 0, mchar = 0, echar = 0; 732 schar = 0, mchar = 0, echar = 0;
733 return c; 733 return c;
734 } 734 }
735 735
736 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input 736 if ( 0x1100 <= c && c <= 0x1112 ) { // schar or echar was input
737 737
738 if (schar == 0 || (schar != 0 && mchar == 0)) { 738 if (schar == 0 || (schar != 0 && mchar == 0)) {
739 schar = c; mchar = 0; echar = 0; 739 schar = c; mchar = 0; echar = 0;
740 return c; 740 return c;
741 } 741 }
742 else if (mchar != 0) { 742 else if (mchar != 0) {
743 743
744 if (echar == 0) { 744 if (echar == 0) {
745 745
746 if (!(echar = constoe(c))) { 746 if (!(echar = constoe(c))) {
747 747
748 schar = c; mchar = 0; echar = 0; 748 schar = c; mchar = 0; echar = 0;
749 return c; 749 return c;
750 } 750 }
751 751
752 } 752 }
753 else { // must figure out what the echar is 753 else { // must figure out what the echar is
754 754
755 if (echar == 0x11a8) { // ¤¡ 755 if (echar == 0x11a8) { // ¤¡
756 756
757 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡ 757 if (c == 0x1100) echar = 0x11a9; // ¤¡ + ¤¡
758 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ 758 else if (c == 0x1109) echar = 0x11aa; // ¤¡ + ¤µ
759 else { 759 else {
760 schar = c; mchar = 0; echar = 0; 760 schar = c; mchar = 0; echar = 0;
761 return c; 761 return c;
762 } 762 }
763 763
764 } else if (echar == 0x11ab) { // ¤¤ 764 } else if (echar == 0x11ab) { // ¤¤
765 765
766 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸ 766 if (c == 0x110c) echar = 0x11ac; // ¤¤ + ¤¸
767 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾ 767 else if (c == 0x1112) echar = 0x11ad; // ¤¤ + ¤¾
768 else { 768 else {
769 schar = c; mchar = 0; echar = 0; 769 schar = c; mchar = 0; echar = 0;
770 return c; 770 return c;
771 } 771 }
772 772
773 } else if (echar == 0x11af) { // ¤© 773 } else if (echar == 0x11af) { // ¤©
774 774
775 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡ 775 if (c == 0x1100) echar = 0x11b0; // ¤© + ¤¡
776 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤± 776 else if (c == 0x1106) echar = 0x11b1; // ¤© + ¤±
777 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤² 777 else if (c == 0x1107) echar = 0x11b2; // ¤© + ¤²
778 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ 778 else if (c == 0x1109) echar = 0x11b3; // ¤© + ¤µ
779 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼ 779 else if (c == 0x1110) echar = 0x11b4; // ¤© + ¤¼
780 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½ 780 else if (c == 0x1111) echar = 0x11b5; // ¤© + ¤½
781 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾ 781 else if (c == 0x1112) echar = 0x11b6; // ¤© + ¤¾
782 else { 782 else {
783 schar = c; mchar = 0; echar = 0; 783 schar = c; mchar = 0; echar = 0;
784 return c; 784 return c;
785 } 785 }
786 786
787 } else if (echar == 0x11b8) { // ¤² 787 } else if (echar == 0x11b8) { // ¤²
788 788
789 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ 789 if (c == 0x1109) echar = 0x11b9; // ¤² + ¤µ
790 else { 790 else {
791 schar = c; mchar = 0; echar = 0; 791 schar = c; mchar = 0; echar = 0;
792 return c; 792 return c;
793 } 793 }
794 794
795 } else if (echar == 0x11ba) { // ¤µ 795 } else if (echar == 0x11ba) { // ¤µ
796 796
797 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ 797 if (c == 0x1109) echar = 0x11bb; // ¤µ + ¤µ
798 else { 798 else {
799 schar = c; mchar = 0; echar = 0; 799 schar = c; mchar = 0; echar = 0;
800 return c; 800 return c;
801 } 801 }
802 802
803 } else { // if any other char, cannot combine chars 803 } else { // if any other char, cannot combine chars
804 804
805 schar = c; mchar = 0; echar = 0; 805 schar = c; mchar = 0; echar = 0;
806 return c; 806 return c;
807 } 807 }
808 808
809 unicode = echar; 809 unicode = echar;
810 } 810 }
811 } 811 }
812 812
813 } 813 }
814 else if (0x1161 <= c && c <= 0x1175) { // mchar was input 814 else if (0x1161 <= c && c <= 0x1175) { // mchar was input
815 815
816 if (schar != 0 && mchar == 0) { mchar = c; } 816 if (schar != 0 && mchar == 0) { mchar = c; }
817 817
818 else if (schar != 0 && mchar != 0 && echar == 0) { 818 else if (schar != 0 && mchar != 0 && echar == 0) {
819 819
820 switch (mchar) { 820 switch (mchar) {
821 case 0x1169: 821 case 0x1169:
822 if (c == 0x1161) mchar = 0x116a; 822 if (c == 0x1161) mchar = 0x116a;
823 else if (c == 0x1162) mchar = 0x116b; 823 else if (c == 0x1162) mchar = 0x116b;
824 else if (c == 0x1175) mchar = 0x116c; 824 else if (c == 0x1175) mchar = 0x116c;
825 else { 825 else {
826 schar = 0; mchar = 0; echar = 0; 826 schar = 0; mchar = 0; echar = 0;
827 return c; 827 return c;
828 } 828 }
829 break; 829 break;
830 case 0x116e: 830 case 0x116e:
831 if (c == 0x1165) mchar = 0x116f; 831 if (c == 0x1165) mchar = 0x116f;
832 else if (c == 0x1166) mchar = 0x1170; 832 else if (c == 0x1166) mchar = 0x1170;
833 else if (c == 0x1175) mchar = 0x1171; 833 else if (c == 0x1175) mchar = 0x1171;
834 else { 834 else {
835 schar = 0; mchar = 0; echar = 0; 835 schar = 0; mchar = 0; echar = 0;
836 return c; 836 return c;
837 } 837 }
838 break; 838 break;
839 case 0x1173: 839 case 0x1173:
840 if (c == 0x1175) mchar = 0x1174; 840 if (c == 0x1175) mchar = 0x1174;
841 else { 841 else {
842 schar = 0; mchar = 0; echar = 0; 842 schar = 0; mchar = 0; echar = 0;
843 return c; 843 return c;
844 } 844 }
845 break; 845 break;
846 default: 846 default:
847 schar = 0; mchar = 0; echar = 0; 847 schar = 0; mchar = 0; echar = 0;
848 return c; 848 return c;
849 } 849 }
850 } 850 }
851 else if (schar != 0 && mchar != 0 && echar != 0) { 851 else if (schar != 0 && mchar != 0 && echar != 0) {
852 852
853 emit key( 8, Qt::Key_Backspace, 0, true, false ); 853 emit key( 8, Qt::Key_Backspace, 0, true, false );
854 854
855 ushort prev = 0; 855 ushort prev = 0;
856 switch (echar) { 856 switch (echar) {
857 /* 857 /*
858 case 0x11a9: 858 case 0x11a9:
859 prev = combineKoreanChars(schar, mchar, 0x11a8); 859 prev = combineKoreanChars(schar, mchar, 0x11a8);
860 schar = 0x1100; 860 schar = 0x1100;
861 break; 861 break;
862 */ 862 */
863 case 0x11aa: 863 case 0x11aa:
864 prev = combineKoreanChars(schar, mchar, 0x11a8); 864 prev = combineKoreanChars(schar, mchar, 0x11a8);
865 schar = 0x1109; 865 schar = 0x1109;
866 break; 866 break;
867 case 0x11ac: 867 case 0x11ac:
868 prev = combineKoreanChars(schar, mchar, 0x11ab); 868 prev = combineKoreanChars(schar, mchar, 0x11ab);
869 schar = 0x110c; 869 schar = 0x110c;
870 break; 870 break;
871 case 0x11ad: 871 case 0x11ad:
872 prev = combineKoreanChars(schar, mchar, 0x11ab); 872 prev = combineKoreanChars(schar, mchar, 0x11ab);
873 schar = 0x1112; 873 schar = 0x1112;
874 break; 874 break;
875 case 0x11b0: 875 case 0x11b0:
876 prev = combineKoreanChars(schar, mchar, 0x11af); 876 prev = combineKoreanChars(schar, mchar, 0x11af);
877 schar = 0x1100; 877 schar = 0x1100;
878 break; 878 break;
879 case 0x11b1: 879 case 0x11b1:
880 prev = combineKoreanChars(schar, mchar, 0x11af); 880 prev = combineKoreanChars(schar, mchar, 0x11af);
881 schar = 0x1106; 881 schar = 0x1106;
882 break; 882 break;
883 case 0x11b2: 883 case 0x11b2:
884 prev = combineKoreanChars(schar, mchar, 0x11af); 884 prev = combineKoreanChars(schar, mchar, 0x11af);
885 schar = 0x1107; 885 schar = 0x1107;
886 break; 886 break;
887 case 0x11b3: 887 case 0x11b3:
888 prev = combineKoreanChars(schar, mchar, 0x11af); 888 prev = combineKoreanChars(schar, mchar, 0x11af);
889 schar = 0x1109; 889 schar = 0x1109;
890 break; 890 break;
891 case 0x11b4: 891 case 0x11b4:
892 prev = combineKoreanChars(schar, mchar, 0x11af); 892 prev = combineKoreanChars(schar, mchar, 0x11af);
893 schar = 0x1110; 893 schar = 0x1110;
894 break; 894 break;
895 case 0x11b9: 895 case 0x11b9:
896 prev = combineKoreanChars(schar, mchar, 0x11b8); 896 prev = combineKoreanChars(schar, mchar, 0x11b8);
897 schar = 0x1109; 897 schar = 0x1109;
898 break; 898 break;
899 /* 899 /*
900 case 0x11bb: 900 case 0x11bb:
901 prev = combineKoreanChars(schar, mchar, 0x11ba); 901 prev = combineKoreanChars(schar, mchar, 0x11ba);
902 schar = 0x1109; 902 schar = 0x1109;
903 break; 903 break;
904 */ 904 */
905 default: 905 default:
906 906
907 if (constoe(echar)) { 907 if (constoe(echar)) {
908 908
909 prev = combineKoreanChars(schar, mchar, 0); 909 prev = combineKoreanChars(schar, mchar, 0);
910 schar = constoe(echar); 910 schar = constoe(echar);
911 } 911 }
912 break; 912 break;
913 } 913 }
914 914
915 emit key( prev, prev, 0, true, false ); 915 emit key( prev, prev, 0, true, false );
916 916
917 mchar = c; echar = 0; 917 mchar = c; echar = 0;
918 918
919 return combineKoreanChars(schar, mchar, 0); 919 return combineKoreanChars(schar, mchar, 0);
920 920
921 } 921 }
922 else { 922 else {
923 schar = 0; mchar = 0; echar = 0; 923 schar = 0; mchar = 0; echar = 0;
924 return c; 924 return c;
925 } 925 }
926 926
927 } 927 }
928 else /*if (c == ' ')*/ return c; 928 else /*if (c == ' ')*/ return c;
929 929
930 930
931 // and now... finally delete previous char, and return new char 931 // and now... finally delete previous char, and return new char
932 emit key( 8, Qt::Key_Backspace, 0, true, false ); 932 emit key( 8, Qt::Key_Backspace, 0, true, false );
933 933
934 934
935 return combineKoreanChars( schar, mchar, echar); 935 return combineKoreanChars( schar, mchar, echar);
936 936
937} 937}
938 938
939ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) { 939ushort Keyboard::combineKoreanChars(const ushort s, const ushort m, const ushort e) {
940 940
941 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00; 941 return ((s - 0x1100) * 588) + ((m - 0x1161) * 28) + (e ? e - 0x11a7 : 0) + 0xac00;
942 942
943} 943}
944 944
945ushort Keyboard::constoe(const ushort c) { 945ushort Keyboard::constoe(const ushort c) {
946 946
947 // converts schars to echars if possible 947 // converts schars to echars if possible
948 948
949 if (0x1100 <= c && c <= 0x1112) { // schar to echar 949 if (0x1100 <= c && c <= 0x1112) { // schar to echar
950 950
951 switch (c) { 951 switch (c) {
952 case 0x1100: return 0x11a8; 952 case 0x1100: return 0x11a8;
953 case 0x1101: return 0x11a9; 953 case 0x1101: return 0x11a9;
954 case 0x1102: return 0x11ab; 954 case 0x1102: return 0x11ab;
955 case 0x1103: return 0x11ae; 955 case 0x1103: return 0x11ae;
956 case 0x1105: return 0x11af; 956 case 0x1105: return 0x11af;
957 case 0x1106: return 0x11b7; 957 case 0x1106: return 0x11b7;
958 case 0x1107: return 0x11b8; 958 case 0x1107: return 0x11b8;
959 case 0x1109: return 0x11ba; 959 case 0x1109: return 0x11ba;
960 case 0x110a: return 0x11bb; 960 case 0x110a: return 0x11bb;
961 case 0x110b: return 0x11bc; 961 case 0x110b: return 0x11bc;
962 case 0x110c: return 0x11bd; 962 case 0x110c: return 0x11bd;
963 case 0x110e: return 0x11be; 963 case 0x110e: return 0x11be;
964 case 0x110f: return 0x11bf; 964 case 0x110f: return 0x11bf;
965 case 0x1110: return 0x11c0; 965 case 0x1110: return 0x11c0;
966 case 0x1111: return 0x11c1; 966 case 0x1111: return 0x11c1;
967 case 0x1112: return 0x11c2; 967 case 0x1112: return 0x11c2;
968 default: return 0; 968 default: return 0;
969 969
970 } 970 }
971 971
972 } else { //echar to schar 972 } else { //echar to schar
973 973
974 switch (c) { 974 switch (c) {
975 case 0x11a8: return 0x1100; 975 case 0x11a8: return 0x1100;
976 case 0x11a9: return 0x1101; 976 case 0x11a9: return 0x1101;
977 case 0x11ab: return 0x1102; 977 case 0x11ab: return 0x1102;
978 case 0x11ae: return 0x1103; 978 case 0x11ae: return 0x1103;
979 case 0x11af: return 0x1105; 979 case 0x11af: return 0x1105;
980 case 0x11b7: return 0x1106; 980 case 0x11b7: return 0x1106;
981 case 0x11b8: return 0x1107; 981 case 0x11b8: return 0x1107;
982 case 0x11ba: return 0x1109; 982 case 0x11ba: return 0x1109;
983 case 0x11bb: return 0x110a; 983 case 0x11bb: return 0x110a;
984 case 0x11bc: return 0x110b; 984 case 0x11bc: return 0x110b;
985 case 0x11bd: return 0x110c; 985 case 0x11bd: return 0x110c;
986 case 0x11be: return 0x110e; 986 case 0x11be: return 0x110e;
987 case 0x11bf: return 0x110f; 987 case 0x11bf: return 0x110f;
988 case 0x11c0: return 0x1110; 988 case 0x11c0: return 0x1110;
989 case 0x11c1: return 0x1111; 989 case 0x11c1: return 0x1111;
990 case 0x11c2: return 0x1112; 990 case 0x11c2: return 0x1112;
991 default: return 0; 991 default: return 0;
992 992
993 } 993 }
994 994
995 } 995 }
996} 996}
997 997
998 998
999// Keys::Keys {{{1 999// Keys::Keys {{{1
1000 1000
1001Keys::Keys() { 1001Keys::Keys() {
1002 1002
1003 Config *config = new Config ("multikey"); 1003 Config *config = new Config ("multikey");
1004 config->setGroup( "keymaps" ); 1004 config->setGroup( "keymaps" );
1005 QString map = config->readEntry( "current" ); 1005 QString map = config->readEntry( "current" );
1006 delete config; 1006 delete config;
1007 1007
1008 if (map.isNull() || !(QFile(map).exists())) { 1008 if (map.isNull() || !(QFile(map).exists())) {
1009 1009
1010 Config *config = new Config("locale"); 1010 Config *config = new Config("locale");
1011 config->setGroup( "Language" ); 1011 config->setGroup( "Language" );
1012 QString l = config->readEntry( "Language" , "en" ); 1012 QString l = config->readEntry( "Language" , "en" );
1013 delete config; 1013 delete config;
1014 1014
1015 map = QPEApplication::qpeDir() + "/share/multikey/" 1015 map = QPEApplication::qpeDir() + "/share/multikey/"
1016 + l + ".keymap"; 1016 + l + ".keymap";
1017 1017
1018 } 1018 }
1019 1019
1020 setKeysFromFile(map); 1020 setKeysFromFile(map);
1021} 1021}
1022 1022
1023Keys::Keys(const char * filename) { 1023Keys::Keys(const char * filename) {
1024 1024
1025 setKeysFromFile(filename); 1025 setKeysFromFile(filename);
1026} 1026}
1027 1027
1028// Keys::setKeysFromFile {{{2 1028// Keys::setKeysFromFile {{{2
1029void Keys::setKeysFromFile(const char * filename) { 1029void Keys::setKeysFromFile(const char * filename) {
1030 1030
1031 QFile f(filename); 1031 QFile f(filename);
1032 1032
1033 if (f.open(IO_ReadOnly)) { 1033 if (f.open(IO_ReadOnly)) {
1034 1034
1035 QTextStream t(&f); 1035 QTextStream t(&f);
1036 int row; 1036 int row;
1037 int qcode; 1037 int qcode;
1038 ushort unicode; 1038 ushort unicode;
1039 int width; 1039 int width;
1040 QString buf; 1040 QString buf;
1041 QString comment; 1041 QString comment;
1042 char * xpm[256]; //couldnt be larger than that... could it? 1042 char * xpm[256]; //couldnt be larger than that... could it?
1043 QPixmap *xpm2pix = 0; 1043 QPixmap *xpm2pix = 0;
1044 1044
1045 buf = t.readLine(); 1045 buf = t.readLine();
1046 while (buf) { 1046 while (buf) {
1047 1047
1048 // get rid of comments
1049 buf.replace(QRegExp("#.*$", FALSE, FALSE), "");
1050
1048 // key definition 1051 // key definition
1049 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) { 1052 if (buf.contains(QRegExp("^\\d+\\s+[0-1a-fx]+", FALSE, FALSE))) {
1050 // no $1 type referencing!!! this implementation of regexp sucks 1053 // no $1 type referencing!!! this implementation of regexp sucks
1051 1054
1052 // dont know of any sscanf() type funcs in Qt lib 1055 // dont know of any sscanf() type funcs in Qt lib
1053 QTextStream tmp (buf, IO_ReadOnly); 1056 QTextStream tmp (buf, IO_ReadOnly);
1054 tmp >> row >> qcode >> unicode >> width >> comment; 1057 tmp >> row >> qcode >> unicode >> width >> comment;
1055 1058
1056 buf = t.readLine(); 1059 buf = t.readLine();
1057 int xpmLineCount = 0; 1060 int xpmLineCount = 0;
1058 xpm2pix = 0; 1061 xpm2pix = 0;
1059 1062
1060 // erase blank space 1063 // erase blank space
1061 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine(); 1064 while (buf.contains(QRegExp("^\\s*$")) && buf) buf = t.readLine();
1062 1065
1063 while (buf.contains(QRegExp("^\\s*\".*\""))) { 1066 while (buf.contains(QRegExp("^\\s*\".*\""))) {
1064 1067
1065 QString xpmBuf = buf.stripWhiteSpace(); 1068 QString xpmBuf = buf.stripWhiteSpace();
1066 1069
1067 xpm[xpmLineCount] = new char [xpmBuf.length()]; 1070 xpm[xpmLineCount] = new char [xpmBuf.length()];
1068 1071
1069 int j = 0; 1072 int j = 0;
1070 for (ushort i = 0; i < xpmBuf.length(); i++) { 1073 for (ushort i = 0; i < xpmBuf.length(); i++) {
1071 if (xpmBuf[i].latin1() != '"') { 1074 if (xpmBuf[i].latin1() != '"') {
1072 1075
1073 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1(); 1076 ((char *)xpm[xpmLineCount])[j] = xpmBuf.at(i).latin1();
1074 j++; 1077 j++;
1075 } 1078 }
1076 1079
1077 } 1080 }
1078 // have to close that facker up 1081 // have to close that facker up
1079 ((char *)xpm[xpmLineCount])[j] = '\0'; 1082 ((char *)xpm[xpmLineCount])[j] = '\0';
1080 1083
1081 xpmLineCount++; 1084 xpmLineCount++;
1082 buf = t.readLine(); 1085 buf = t.readLine();
1083 } 1086 }
1084 if (xpmLineCount) { 1087 if (xpmLineCount) {
1085 1088
1086 xpm2pix = new QPixmap((const char **)xpm); 1089 xpm2pix = new QPixmap((const char **)xpm);
1087 for (int i = 0; i < xpmLineCount; i++) 1090 for (int i = 0; i < xpmLineCount; i++)
1088 1091
1089 delete [] (xpm[i]); 1092 delete [] (xpm[i]);
1090 1093
1091 } 1094 }
1092 setKey(row, qcode, unicode, width, xpm2pix); 1095 setKey(row, qcode, unicode, width, xpm2pix);
1093 } 1096 }
1094 1097
1095 // shift map 1098 // shift map
1096 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1099 else if (buf.contains(QRegExp("^[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1097 1100
1098 QTextStream tmp (buf, IO_ReadOnly); 1101 QTextStream tmp (buf, IO_ReadOnly);
1099 ushort lower, shift; 1102 ushort lower, shift;
1100 tmp >> lower >> shift; 1103 tmp >> lower >> shift;
1101 1104
1102 shiftMap.insert(lower, shift); 1105 shiftMap.insert(lower, shift);
1103 1106
1104 buf = t.readLine(); 1107 buf = t.readLine();
1105 } 1108 }
1106 1109
1107 // meta key map 1110 // meta key map
1108 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) { 1111 else if (buf.contains(QRegExp("^\\s*m\\s+[0-9a-fx]+\\s+[0-9a-fx]+\\s*$", FALSE, FALSE))) {
1109 1112
1110 QTextStream tmp (buf, IO_ReadOnly); 1113 QTextStream tmp (buf, IO_ReadOnly);
1111 ushort lower, shift; 1114 ushort lower, shift;
1112 QChar m; 1115 QChar m;
1113 tmp >> m >> lower >> shift; 1116 tmp >> m >> lower >> shift;
1114 1117
1115 metaMap.insert(lower, shift); 1118 metaMap.insert(lower, shift);
1116 1119
1117 buf = t.readLine(); 1120 buf = t.readLine();
1118 } 1121 }
1119 1122
1120 // other variables like lang & title 1123 // other variables like lang & title
1121 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) { 1124 else if (buf.contains(QRegExp("^\\s*[a-zA-Z]+\\s*=\\s*[a-zA-Z0-9/]+\\s*$", FALSE, FALSE))) {
1122 1125
1123 QTextStream tmp (buf, IO_ReadOnly); 1126 QTextStream tmp (buf, IO_ReadOnly);
1124 QString name, equals, value; 1127 QString name, equals, value;
1125 1128
1126 tmp >> name >> equals >> value; 1129 tmp >> name >> equals >> value;
1127 1130
1128 if (name == "lang") { 1131 if (name == "lang") {
1129 1132
1130 lang = value; 1133 lang = value;
1131 1134
1132 } 1135 }
1133 1136
1134 buf = t.readLine(); 1137 buf = t.readLine();
1135 } 1138 }
1136 // comments 1139 // comments
1137 else if (buf.contains(QRegExp("^\\s*#"))) { 1140 else if (buf.contains(QRegExp("^\\s*#"))) {
1138 1141
1139 buf = t.readLine(); 1142 buf = t.readLine();
1140 1143
1141 } else { // blank line, or garbage 1144 } else { // blank line, or garbage
1142 1145
1143 buf = t.readLine(); 1146 buf = t.readLine();
1144 1147
1145 } 1148 }
1146 1149
1147 } 1150 }
1148 f.close(); 1151 f.close();
1149 } 1152 }
1150 1153
1151} 1154}
1152 1155
1153// Keys::setKey {{{2 1156// Keys::setKey {{{2
1154void Keys::setKey(const int row, const int qcode, const ushort unicode, 1157void Keys::setKey(const int row, const int qcode, const ushort unicode,
1155 const int width, QPixmap *pix) { 1158 const int width, QPixmap *pix) {
1156 1159
1157 Key * key; 1160 Key * key;
1158 key = new Key; 1161 key = new Key;
1159 key->qcode = qcode; 1162 key->qcode = qcode;
1160 key->unicode = unicode; 1163 key->unicode = unicode;
1161 key->width = width; 1164 key->width = width;
1162 1165
1163 // share key->pressed between same keys 1166 // share key->pressed between same keys
1164 bool found = 0; 1167 bool found = 0;
1165 for (int i = 1; i <= 5; i++) { 1168 for (int i = 1; i <= 5; i++) {
1166 for (unsigned int j = 0; j < keys[i].count(); j++) 1169 for (unsigned int j = 0; j < keys[i].count(); j++)
1167 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) { 1170 if (keys[i].at(j)->qcode == qcode && keys[i].at(j)->unicode == unicode) {
1168 1171
1169 key->pressed = keys[i].at(j)->pressed; 1172 key->pressed = keys[i].at(j)->pressed;
1170 found = 1; 1173 found = 1;
1171 } 1174 }
1172 1175
1173 } 1176 }
1174 if (!found) { 1177 if (!found) {
1175 1178
1176 key->pressed = new bool; 1179 key->pressed = new bool;
1177 *(key->pressed) = 0; 1180 *(key->pressed) = 0;
1178 } 1181 }
1179 1182
1180 key->pix = pix; 1183 key->pix = pix;
1181 1184
1182 1185
1183 keys[row].append(key); 1186 keys[row].append(key);
1184} 1187}
1185 1188
1186// Keys::~Keys {{{2 1189// Keys::~Keys {{{2
1187Keys::~Keys() { 1190Keys::~Keys() {
1188 1191
1189 for (int i = 1; i <= 5; i++) 1192 for (int i = 1; i <= 5; i++)
1190 for (unsigned int j = 0; j < keys[i].count(); j++) 1193 for (unsigned int j = 0; j < keys[i].count(); j++)
1191 delete keys[i].at(j); 1194 delete keys[i].at(j);
1192 1195
1193} 1196}
1194 1197
1195// Keys:: other functions {{{2 1198// Keys:: other functions {{{2
1196int Keys::width(const int row, const int col) { 1199int Keys::width(const int row, const int col) {
1197 1200
1198 return keys[row].at(col)->width; 1201 return keys[row].at(col)->width;
1199 1202
1200} 1203}
1201ushort Keys::uni(const int row, const int col) { 1204ushort Keys::uni(const int row, const int col) {
1202 1205
1203 return keys[row].at(col)->unicode; 1206 return keys[row].at(col)->unicode;
1204 1207
1205} 1208}
1206 1209
1207int Keys::qcode(const int row, const int col) { 1210int Keys::qcode(const int row, const int col) {
1208 1211
1209 return keys[row].at(col)->qcode; 1212 return keys[row].at(col)->qcode;
1210} 1213}
1211 1214
1212QPixmap *Keys::pix(const int row, const int col) { 1215QPixmap *Keys::pix(const int row, const int col) {
1213 1216
1214 return keys[row].at(col)->pix; 1217 return keys[row].at(col)->pix;
1215 1218
1216} 1219}
1217bool Keys::pressed(const int row, const int col) { 1220bool Keys::pressed(const int row, const int col) {
1218 1221
1219 return *(keys[row].at(col)->pressed); 1222 return *(keys[row].at(col)->pressed);
1220} 1223}
1221 1224
1222int Keys::numKeys(const int row) { 1225int Keys::numKeys(const int row) {
1223 1226
1224 return keys[row].count(); 1227 return keys[row].count();
1225} 1228}
1226 1229
1227void Keys::setPressed(const int row, const int col, const bool pressed) { 1230void Keys::setPressed(const int row, const int col, const bool pressed) {
1228 1231
1229 *(keys[row].at(col)->pressed) = pressed; 1232 *(keys[row].at(col)->pressed) = pressed;
1230} 1233}
1231 1234
1232ushort Keys::shift(const ushort uni) { 1235ushort Keys::shift(const ushort uni) {
1233 1236
1234 if (shiftMap[uni]) { 1237 if (shiftMap[uni]) {
1235 1238
1236 return shiftMap[uni]; 1239 return shiftMap[uni];
1237 } 1240 }
1238 else 1241 else
1239 return 0; 1242 return 0;
1240 1243
1241} 1244}
1242 1245
1243ushort Keys::meta(const ushort uni) { 1246ushort Keys::meta(const ushort uni) {
1244 1247
1245 if (metaMap[uni]) { 1248 if (metaMap[uni]) {
1246 1249
1247 return metaMap[uni]; 1250 return metaMap[uni];
1248 } 1251 }
1249 else 1252 else
1250 return 0; 1253 return 0;
1251 1254
1252} 1255}
1253 1256
1254bool *Keys::pressedPtr(const int row, const int col) { 1257bool *Keys::pressedPtr(const int row, const int col) {
1255 1258
1256 return keys[row].at(col)->pressed; 1259 return keys[row].at(col)->pressed;
1257} 1260}