Qt 4.8
qkeymapper_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtGui 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 #ifndef QKEYMAPPER_P_H
42 #define QKEYMAPPER_P_H
43 
44 //
45 // W A R N I N G
46 // -------------
47 //
48 // This file is not part of the Qt API. It exists purely as an
49 // implementation detail. This header file may change from version to
50 // version without notice, or even be removed.
51 //
52 // We mean it.
53 //
54 
55 #include <qobject.h>
56 #include <private/qobject_p.h>
57 #include <qkeysequence.h>
58 #include <qlist.h>
59 #include <qlocale.h>
60 #include <qevent.h>
61 #include <qhash.h>
62 
63 #if defined (Q_WS_MAC64)
64 # include <private/qt_mac_p.h>
65 #endif
66 
68 
69 class QKeyMapperPrivate;
70 class QKeyMapper : public QObject
71 {
72  Q_OBJECT
73 public:
74  explicit QKeyMapper();
75  ~QKeyMapper();
76 
77  static QKeyMapper *instance();
78  static void changeKeyboard();
79  static bool sendKeyEvent(QWidget *widget, bool grab,
80  QEvent::Type type, int code, Qt::KeyboardModifiers modifiers,
81  const QString &text, bool autorepeat, int count,
82  quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
83  bool *unusedExceptForCocoa = 0);
85 
86 private:
90 };
91 
92 
93 
94 #if defined(Q_OS_WIN)
96  ShiftLeft = 0x00000001,
97  ControlLeft = 0x00000002,
98  AltLeft = 0x00000004,
99  MetaLeft = 0x00000008,
100  ShiftRight = 0x00000010,
101  ControlRight = 0x00000020,
102  AltRight = 0x00000040,
103  MetaRight = 0x00000080,
104  CapsLock = 0x00000100,
105  NumLock = 0x00000200,
106  ScrollLock = 0x00000400,
107  ExtendedKey = 0x01000000,
108 
109  // Convenience mappings
110  ShiftAny = 0x00000011,
111  ControlAny = 0x00000022,
112  AltAny = 0x00000044,
113  MetaAny = 0x00000088,
114  LockAny = 0x00000700
115 };
116 # if !defined(tagMSG)
117  typedef struct tagMSG MSG;
118 # endif
119 #elif defined(Q_WS_MAC)
121 # include <private/qt_mac_p.h>
123 #elif defined(Q_WS_X11)
124 
126 typedef ulong XID;
127 typedef XID KeySym;
129 
130 struct QXCoreDesc {
131  int min_keycode;
132  int max_keycode;
133  int keysyms_per_keycode;
134  KeySym *keysyms;
135  uchar mode_switch;
136  uchar num_lock;
137  KeySym lock_meaning;
138 };
139 
140 #endif
141 
142 struct KeyboardLayoutItem;
143 typedef struct __TISInputSource * TISInputSourceRef;
144 class QKeyEvent;
146 {
148 public:
151 
152  void clearMappings();
154 
157 
158 #if defined(Q_OS_WIN)
159  void clearRecordedKeys();
160  void updateKeyMap(const MSG &msg);
161  bool translateKeyEvent(QWidget *receiver, const MSG &msg, bool grab);
162  void updatePossibleKeyCodes(unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key);
163  bool isADeadKey(unsigned int vk_key, unsigned int modifiers);
164  void deleteLayouts();
165 
166  KeyboardLayoutItem *keyLayout[256];
167 
168 #elif defined(Q_WS_X11)
169 
170  QList<int> possibleKeysXKB(QKeyEvent *event);
171  QList<int> possibleKeysCore(QKeyEvent *event);
172 
173  bool translateKeyEventInternal(QWidget *keywidget,
174  const XEvent *,
175  KeySym &keysym,
176  int& count,
177  QString& text,
178  Qt::KeyboardModifiers& modifiers,
179  int &code,
181  bool statefulTranslation = true);
182  bool translateKeyEvent(QWidget *keywidget,
183  const XEvent *,
184  bool grab);
185 
186  int xkb_currentGroup;
187  QXCoreDesc coreDesc;
188 
189 #elif defined(Q_WS_MAC)
190  bool updateKeyboard();
191  void updateKeyMap(EventHandlerCallRef, EventRef, void *);
192  bool translateKeyEvent(QWidget *, EventHandlerCallRef, EventRef, void *, bool);
193  void deleteLayouts();
194 
195  enum { NullMode, UnicodeMode, OtherMode } keyboard_mode;
196  union {
197  const UCKeyboardLayout *unicode;
198  void *other;
199  } keyboard_layout_format;
200 #ifdef Q_WS_MAC64
201  QCFType<TISInputSourceRef> currentInputSource;
202 #else
203  KeyboardLayoutRef currentKeyboardLayout;
204 #endif
205  KeyboardLayoutKind keyboard_kind;
206  UInt32 keyboard_dead;
207  KeyboardLayoutItem *keyLayout[256];
208 #elif defined(Q_WS_QWS)
209 #elif defined(Q_OS_SYMBIAN)
210 public:
211  QString translateKeyEvent(int keySym, Qt::KeyboardModifiers modifiers);
212  int mapS60KeyToQt(TUint s60key);
213  int mapS60ScanCodesToQt(TUint s60key);
214  int mapQtToS60Key(int qtKey);
215  int mapQtToS60ScanCodes(int qtKey);
216  int mapS60RemConIdToS60Key(int s60RemConId);
217  int mapS60RemConIdToS60ScanCodes(int s60RemConId);
218  void updateInputLanguage();
219 #endif
220 };
221 
222 QKeyMapperPrivate *qt_keymapper_private(); // from qkeymapper.cpp
223 
225 
226 #endif // QKEYMAPPER_P_H
The QKeyEvent class describes a key event.
Definition: qevent.h:224
int type
Definition: qmetatype.cpp:239
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
QPointer< QWidget > widget
~QKeyMapper()
Destroys the key mapper.
Definition: qkeymapper.cpp:70
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:150
#define QT_END_INCLUDE_NAMESPACE
This macro is equivalent to QT_BEGIN_NAMESPACE.
Definition: qglobal.h:92
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
QLocale keyboardInputLocale
Definition: qkeymapper_p.h:155
int keysym
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
virtual bool event(QEvent *)
This virtual function receives events to an object and should return true if the event e was recogniz...
Definition: qobject.cpp:1200
WindowsNativeModifiers
Definition: qkeymapper_p.h:95
union _XEvent XEvent
Definition: qwindowdefs.h:116
static QList< int > possibleKeys(QKeyEvent *e)
Definition: qkeymapper.cpp:74
struct __TISInputSource * TISInputSourceRef
Definition: qkeymapper_p.h:143
unsigned char uchar
Definition: qglobal.h:994
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
LayoutDirection
Definition: qnamespace.h:1580
static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent, int *qtKey, QChar *outChar, Qt::KeyboardModifiers *outModifiers, bool *outHandled)
unsigned long ulong
Definition: qglobal.h:997
static QKeyMapper * instance()
Returns the pointer to the single instance of QKeyMapper in the application.
Definition: qkeymapper.cpp:108
#define Q_OBJECT
Definition: qobjectdefs.h:157
struct OpaqueEventRef * EventRef
struct tagMSG MSG
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
Type
This enum type defines the valid event types in Qt.
Definition: qcoreevent.h:62
static void changeKeyboard()
Definition: qkeymapper.cpp:90
unsigned int quint32
Definition: qglobal.h:938
#define QT_BEGIN_INCLUDE_NAMESPACE
This macro is equivalent to QT_END_NAMESPACE.
Definition: qglobal.h:91
static bool sendKeyEvent(QWidget *widget, bool grab, QEvent::Type type, int code, Qt::KeyboardModifiers modifiers, const QString &text, bool autorepeat, int count, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, bool *unusedExceptForCocoa=0)
struct OpaqueEventHandlerCallRef * EventHandlerCallRef
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
static QString qtKey(CFStringRef cfkey)
Qt::LayoutDirection keyboardInputDirection
Definition: qkeymapper_p.h:156
friend QKeyMapperPrivate * qt_keymapper_private()
Definition: qkeymapper.cpp:113
QKeyMapper()
Constructs a new key mapper.
Definition: qkeymapper.cpp:62
unsigned long XID
Definition: qgtkstyle_p.h:71
#define text
Definition: qobjectdefs.h:80