Qt 4.8
qt-4.8.6
src
plugins
platforms
blackberry
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
48
QT_BEGIN_NAMESPACE
49
50
Qt::Key
keyTranslator
(
int
key
)
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
267
QT_END_NAMESPACE
268
#endif // QBBKEYTRANSLATOR_H
QT_END_NAMESPACE
#define QT_END_NAMESPACE
This macro expands to.
Definition:
qglobal.h:90
Qt::Key_End
Definition:
qnamespace.h:632
Qt::Key_Control
Definition:
qnamespace.h:646
Qt::Key_Slash
Definition:
qnamespace.h:711
Qt::Key_5
Definition:
qnamespace.h:717
Qt::Key_Asterisk
Definition:
qnamespace.h:706
Qt::Key_Hyper_L
Definition:
qnamespace.h:690
Qt::Key_PageUp
Definition:
qnamespace.h:637
isKeypadKey
bool isKeypadKey(int key)
Definition:
qbbkeytranslator.h:239
Qt::Key_F9
Definition:
qnamespace.h:660
Qt::Key_F5
Definition:
qnamespace.h:656
Qt::Key_Escape
Definition:
qnamespace.h:613
Qt::Key_Enter
Definition:
qnamespace.h:624
Qt::Key_Backspace
Definition:
qnamespace.h:619
Qt::Key_Right
Definition:
qnamespace.h:635
Qt::Key_Menu
Definition:
qnamespace.h:689
Qt::Key_NumLock
Definition:
qnamespace.h:650
Qt::Key_F4
Definition:
qnamespace.h:655
qDebug
Q_CORE_EXPORT void qDebug(const char *,...)
Qt::Key_F6
Definition:
qnamespace.h:657
QT_BEGIN_NAMESPACE
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition:
qglobal.h:89
Qt::Key_F8
Definition:
qnamespace.h:659
Qt::Key_Down
Definition:
qnamespace.h:636
Qt::Key_Shift
Definition:
qnamespace.h:645
Qt::Key_Minus
Definition:
qnamespace.h:709
Qt::Key_F10
Definition:
qnamespace.h:661
Qt::Key_Hyper_R
Definition:
qnamespace.h:691
Qt::Key_Delete
Definition:
qnamespace.h:626
Qt::Key_Return
Definition:
qnamespace.h:623
keyTranslator
Qt::Key keyTranslator(int key)
Definition:
qbbkeytranslator.h:50
Qt::Key
Key
Definition:
qnamespace.h:612
Qt::Key_F7
Definition:
qnamespace.h:658
Qt::Key_ScrollLock
Definition:
qnamespace.h:651
Qt::Key_Plus
Definition:
qnamespace.h:707
Qt::Key_Tab
Definition:
qnamespace.h:614
Qt::Key_CapsLock
Definition:
qnamespace.h:649
Qt::Key_F12
Definition:
qnamespace.h:663
Qt::Key_Pause
Definition:
qnamespace.h:627
Qt::Key_Home
Definition:
qnamespace.h:631
Qt::Key_SysReq
Definition:
qnamespace.h:629
Qt::Key_PageDown
Definition:
qnamespace.h:641
Qt::Key_Up
Definition:
qnamespace.h:634
key
int key
Definition:
qkeysequence.cpp:395
Qt::Key_F3
Definition:
qnamespace.h:654
Qt::Key_Alt
Definition:
qnamespace.h:648
Qt::Key_Backtab
Definition:
qnamespace.h:615
Qt::Key_Insert
Definition:
qnamespace.h:625
Qt::Key_F1
Definition:
qnamespace.h:652
Qt::Key_Print
Definition:
qnamespace.h:628
Qt::Key_F2
Definition:
qnamespace.h:653
Qt::Key_F11
Definition:
qnamespace.h:662
Qt::Key_Left
Definition:
qnamespace.h:633
Qt 4.8 Source Code Browser