Qt 4.8
qbbkeytranslator.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2011 - 2012 Research In Motion <blackberry-qt@qnx.com>
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtCore module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 #ifndef QBBKEYTRANSLATOR_H
43 #define QBBKEYTRANSLATOR_H
44 
45 #include <sys/keycodes.h>
46 #include <QDebug>
47 
49 
51 {
52  switch (key) {
53  case KEYCODE_PAUSE:
54  return Qt::Key_Pause;
55 
56  case KEYCODE_SCROLL_LOCK:
57  return Qt::Key_ScrollLock;
58 
59  case KEYCODE_PRINT:
60  return Qt::Key_Print;
61 
62  case KEYCODE_SYSREQ:
63  return Qt::Key_SysReq;
64 
65 // case KEYCODE_BREAK:
66 
67  case KEYCODE_ESCAPE:
68  return Qt::Key_Escape;
69 
70  case KEYCODE_BACKSPACE:
71  return Qt::Key_Backspace;
72 
73  case KEYCODE_TAB:
74  return Qt::Key_Tab;
75 
76  case KEYCODE_BACK_TAB:
77  return Qt::Key_Backtab;
78 
79  case KEYCODE_RETURN:
80  return Qt::Key_Return;
81 
82  case KEYCODE_CAPS_LOCK:
83  return Qt::Key_CapsLock;
84 
85  case KEYCODE_LEFT_SHIFT:
86  case KEYCODE_RIGHT_SHIFT:
87  return Qt::Key_Shift;
88 
89  case KEYCODE_LEFT_CTRL:
90  case KEYCODE_RIGHT_CTRL:
91  return Qt::Key_Control;
92 
93  case KEYCODE_LEFT_ALT:
94  case KEYCODE_RIGHT_ALT:
95  return Qt::Key_Alt;
96 
97  case KEYCODE_MENU:
98  return Qt::Key_Menu;
99 
100  case KEYCODE_LEFT_HYPER:
101  return Qt::Key_Hyper_L;
102 
103  case KEYCODE_RIGHT_HYPER:
104  return Qt::Key_Hyper_R;
105 
106 
107  case KEYCODE_INSERT:
108  return Qt::Key_Insert;
109 
110  case KEYCODE_HOME:
111  return Qt::Key_Home;
112 
113  case KEYCODE_PG_UP:
114  return Qt::Key_PageUp;
115 
116  case KEYCODE_DELETE:
117  return Qt::Key_Delete;
118 
119  case KEYCODE_END:
120  return Qt::Key_End;
121 
122  case KEYCODE_PG_DOWN:
123  return Qt::Key_PageDown;
124 
125  case KEYCODE_LEFT:
126  return Qt::Key_Left;
127 
128  case KEYCODE_RIGHT:
129  return Qt::Key_Right;
130 
131  case KEYCODE_UP:
132  return Qt::Key_Up;
133 
134  case KEYCODE_DOWN:
135  return Qt::Key_Down;
136 
137 
138  case KEYCODE_NUM_LOCK:
139  return Qt::Key_NumLock;
140 
141  case KEYCODE_KP_PLUS:
142  return Qt::Key_Plus;
143 
144  case KEYCODE_KP_MINUS:
145  return Qt::Key_Minus;
146 
147  case KEYCODE_KP_MULTIPLY:
148  return Qt::Key_Asterisk;
149 
150  case KEYCODE_KP_DIVIDE:
151  return Qt::Key_Slash;
152 
153  case KEYCODE_KP_ENTER:
154  return Qt::Key_Enter;
155 
156  case KEYCODE_KP_HOME:
157  return Qt::Key_Home;
158 
159  case KEYCODE_KP_UP:
160  return Qt::Key_Up;
161 
162  case KEYCODE_KP_PG_UP:
163  return Qt::Key_PageUp;
164 
165  case KEYCODE_KP_LEFT:
166  return Qt::Key_Left;
167 
168  // Is this right?
169  case KEYCODE_KP_FIVE:
170  return Qt::Key_5;
171 
172  case KEYCODE_KP_RIGHT:
173  return Qt::Key_Right;
174 
175  case KEYCODE_KP_END:
176  return Qt::Key_End;
177 
178  case KEYCODE_KP_DOWN:
179  return Qt::Key_Down;
180 
181  case KEYCODE_KP_PG_DOWN:
182  return Qt::Key_PageDown;
183 
184  case KEYCODE_KP_INSERT:
185  return Qt::Key_Insert;
186 
187  case KEYCODE_KP_DELETE:
188  return Qt::Key_Delete;
189 
190 
191  case KEYCODE_F1:
192  return Qt::Key_F1;
193 
194  case KEYCODE_F2:
195  return Qt::Key_F2;
196 
197  case KEYCODE_F3:
198  return Qt::Key_F3;
199 
200  case KEYCODE_F4:
201  return Qt::Key_F4;
202 
203  case KEYCODE_F5:
204  return Qt::Key_F5;
205 
206  case KEYCODE_F6:
207  return Qt::Key_F6;
208 
209  case KEYCODE_F7:
210  return Qt::Key_F7;
211 
212  case KEYCODE_F8:
213  return Qt::Key_F8;
214 
215  case KEYCODE_F9:
216  return Qt::Key_F9;
217 
218  case KEYCODE_F10:
219  return Qt::Key_F10;
220 
221  case KEYCODE_F11:
222  return Qt::Key_F11;
223 
224  case KEYCODE_F12:
225  return Qt::Key_F12;
226 
227  // See keycodes.h for more, but these are all the basics. And printables are already included.
228 
229  default:
230 #if defined(QBBEVENTTHREAD_DEBUG)
231  qDebug() << "QBB: unknown key for translation:" << key;
232 #endif
233  break;
234  }
235 
236  return Qt::Key_Escape;
237 }
238 
239 bool isKeypadKey( int key )
240 {
241  switch (key)
242  {
243  case KEYCODE_KP_PLUS:
244  case KEYCODE_KP_MINUS:
245  case KEYCODE_KP_MULTIPLY:
246  case KEYCODE_KP_DIVIDE:
247  case KEYCODE_KP_ENTER:
248  case KEYCODE_KP_HOME:
249  case KEYCODE_KP_UP:
250  case KEYCODE_KP_PG_UP:
251  case KEYCODE_KP_LEFT:
252  case KEYCODE_KP_FIVE:
253  case KEYCODE_KP_RIGHT:
254  case KEYCODE_KP_END:
255  case KEYCODE_KP_DOWN:
256  case KEYCODE_KP_PG_DOWN:
257  case KEYCODE_KP_INSERT:
258  case KEYCODE_KP_DELETE:
259  return true;
260  default:
261  break;
262  }
263 
264  return false;
265 }
266 
268 #endif // QBBKEYTRANSLATOR_H
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
bool isKeypadKey(int key)
Q_CORE_EXPORT void qDebug(const char *,...)
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
Qt::Key keyTranslator(int key)
int key