Qt 4.8
Public Functions | Public Variables | List of all members
QKeyMapperPrivate Class Reference

#include <qkeymapper_p.h>

Inheritance diagram for QKeyMapperPrivate:
QObjectPrivate QObjectData

Public Functions

void clearMappings ()
 
void clearRecordedKeys ()
 
void deleteLayouts ()
 
bool isADeadKey (unsigned int vk_key, unsigned int modifiers)
 
QList< int > possibleKeys (QKeyEvent *e)
 
 QKeyMapperPrivate ()
 
bool translateKeyEvent (QWidget *receiver, const MSG &msg, bool grab)
 
void updateKeyMap (const MSG &msg)
 
void updatePossibleKeyCodes (unsigned char *kbdBuffer, quint32 scancode, quint32 vk_key)
 
 ~QKeyMapperPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Public Variables

Qt::LayoutDirection keyboardInputDirection
 
QLocale keyboardInputLocale
 
KeyboardLayoutItemkeyLayout [256]
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Detailed Description

Definition at line 145 of file qkeymapper_p.h.

Constructors and Destructors

◆ QKeyMapperPrivate()

QKeyMapperPrivate::QKeyMapperPrivate ( )

Definition at line 592 of file qkeymapper_mac.cpp.

Referenced by qt_XTranslateKey().

593 {
594  memset(keyLayout, 0, sizeof(keyLayout));
595  keyboard_layout_format.unicode = 0;
596 #ifdef Q_OS_MAC32
597  keyboard_mode = NullMode;
598 #else
599  currentInputSource = 0;
600 #endif
601 }
KeyboardLayoutItem * keyLayout[256]
Definition: qkeymapper_p.h:166

◆ ~QKeyMapperPrivate()

QKeyMapperPrivate::~QKeyMapperPrivate ( )

Definition at line 603 of file qkeymapper_mac.cpp.

Referenced by qt_XTranslateKey().

604 {
605  deleteLayouts();
606 }

Functions

◆ clearMappings()

void QKeyMapperPrivate::clearMappings ( )

Definition at line 696 of file qkeymapper_mac.cpp.

697 {
698  deleteLayouts();
699  updateKeyboard();
700 }

◆ clearRecordedKeys()

void QKeyMapperPrivate::clearRecordedKeys ( )

Definition at line 651 of file qkeymapper_win.cpp.

652 {
654 }
static KeyRecorder key_recorder

◆ deleteLayouts()

void QKeyMapperPrivate::deleteLayouts ( )

Definition at line 684 of file qkeymapper_mac.cpp.

685 {
686  keyboard_mode = NullMode;
687  for (int i = 0; i < 255; ++i) {
688  if (keyLayout[i]) {
689  delete keyLayout[i];
690  keyLayout[i] = 0;
691  }
692  }
693 }
KeyboardLayoutItem * keyLayout[256]
Definition: qkeymapper_p.h:166

◆ isADeadKey()

bool QKeyMapperPrivate::isADeadKey ( unsigned int  vk_key,
unsigned int  modifiers 
)

Definition at line 760 of file qkeymapper_win.cpp.

761 {
762  if (keyLayout && (vk_key < 256) && keyLayout[vk_key]) {
763  for(register int i = 0; i < 9; ++i) {
764  if (uint(ModsTbl[i]) == modifiers)
765  return bool(keyLayout[vk_key]->deadkeys & 1<<i);
766  }
767  }
768  return false;
769 }
KeyboardLayoutItem * keyLayout[256]
Definition: qkeymapper_p.h:166
unsigned int uint
Definition: qglobal.h:996
static const Qt::KeyboardModifiers ModsTbl[]

◆ possibleKeys()

QList< int > QKeyMapperPrivate::possibleKeys ( QKeyEvent e)

Definition at line 703 of file qkeymapper_mac.cpp.

Referenced by isADeadKey(), and qt_XTranslateKey().

704 {
705  QList<int> ret;
706 
708  if (!kbItem) // Key is not in any keyboard layout (e.g. eisu-key on Japanese keyboard)
709  return ret;
710 
711  int baseKey = kbItem->qtKey[0];
712  Qt::KeyboardModifiers keyMods = e->modifiers();
713  ret << int(baseKey + keyMods); // The base key is _always_ valid, of course
714 
715  for (int i = 1; i < 8; ++i) {
716  Qt::KeyboardModifiers neededMods = ModsTbl[i];
717  int key = kbItem->qtKey[i];
718  if (key && key != baseKey && ((keyMods & neededMods) == neededMods))
719  ret << int(key + (keyMods & ~neededMods));
720  }
721 
722  return ret;
723 }
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately after the event occurred.
Definition: qevent.cpp:999
KeyboardLayoutItem * keyLayout[256]
Definition: qkeymapper_p.h:166
int key
static const Qt::KeyboardModifiers ModsTbl[]
quint32 nativeVirtualKey() const
Returns the native virtual key, or key sym of the key event.
Definition: qevent.cpp:889

◆ translateKeyEvent()

bool QKeyMapperPrivate::translateKeyEvent ( QWidget receiver,
const MSG msg,
bool  grab 
)

Definition at line 725 of file qkeymapper_mac.cpp.

Referenced by QMacInputContext::globalEventProcessor(), QApplicationPrivate::globalEventProcessor(), isADeadKey(), qt_dispatchKeyEvent(), qt_keyrelease_scanner(), QtWndProc(), and QApplication::x11ProcessEvent().

727 {
728  Q_ASSERT(GetEventClass(event) == kEventClassKeyboard);
729  bool handled_event=true;
730  UInt32 ekind = GetEventKind(event);
731 
732  // unfortunately modifiers changed event looks quite different, so I have a separate
733  // code path
734  if (ekind == kEventRawKeyModifiersChanged) {
735  //figure out changed modifiers, wish Apple would just send a delta
736  UInt32 modifiers = 0;
737  GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
738  sizeof(modifiers), 0, &modifiers);
740  return true;
741  }
742 #ifndef QT_NO_IM
743  QInputContext *currentContext = qApp->inputContext();
744  if (currentContext && currentContext->isComposing()) {
745  if (ekind == kEventRawKeyDown) {
746  QMacInputContext *context = qobject_cast<QMacInputContext*>(currentContext);
747  if (context)
748  context->setLastKeydownEvent(event);
749  }
750  return false;
751  }
752  // Once we process the key down , we don't need to send the saved event again from
753  // kEventTextInputUnicodeForKeyEvent, so clear it.
754  if (currentContext && ekind == kEventRawKeyDown) {
755  QMacInputContext *context = qobject_cast<QMacInputContext*>(currentContext);
756  if (context)
757  context->setLastKeydownEvent(0);
758  }
759 #endif
760  //get modifiers
761  Qt::KeyboardModifiers modifiers;
762  int qtKey;
763  QChar ourChar;
764  if (translateKeyEventInternal(er, event, &qtKey, &ourChar, &modifiers,
765  &handled_event) == false)
766  return handled_event;
767  QString text(ourChar);
768  /* This is actually wrong - but unfortunately it is the best that can be
769  done for now because of the Control/Meta mapping problems */
770  if (modifiers & (Qt::ControlModifier | Qt::MetaModifier)
771  && !qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
772  text = QString();
773  }
774 
775 
776  if (widget) {
777 #ifndef QT_MAC_USE_COCOA
778  Q_UNUSED(info);
779  // Try not to call "other" event handlers if we have a popup,
780  // However, if the key has text
781  // then we should pass it along because otherwise then people
782  // can use input method stuff.
783  if (!qApp->activePopupWidget()
784  || (qApp->activePopupWidget() && !text.isEmpty())) {
785  //Find out if someone else wants the event, namely
786  //is it of use to text services? If so we won't bother
787  //with a QKeyEvent.
788  qt_mac_eat_unicode_key = false;
789  if (er)
790  CallNextEventHandler(er, event);
791  extern bool qt_mac_menubar_is_open();
793  return true;
794  }
795  }
796 #endif
797  // Try to compress key events.
798  if (!text.isEmpty() && widget->testAttribute(Qt::WA_KeyCompression)) {
799  EventTime lastTime = GetEventTime(event);
800  for (;;) {
801  EventRef releaseEvent = FindSpecificEventInQueue(GetMainEventQueue(),
803  (void*)kEventRawKeyUp);
804  if (!releaseEvent)
805  break;
806  const EventTime releaseTime = GetEventTime(releaseEvent);
807  if (releaseTime < lastTime)
808  break;
809  lastTime = releaseTime;
810 
811  EventRef pressEvent = FindSpecificEventInQueue(GetMainEventQueue(),
813  (void*)kEventRawKeyDown);
814  if (!pressEvent)
815  break;
816  const EventTime pressTime = GetEventTime(pressEvent);
817  if (pressTime < lastTime)
818  break;
819  lastTime = pressTime;
820 
821  Qt::KeyboardModifiers compressMod;
822  int compressQtKey = 0;
823  QChar compressChar;
824  if (translateKeyEventInternal(er, pressEvent,
825  &compressQtKey, &compressChar, &compressMod, 0)
826  == false) {
827  break;
828  }
829  // Copied from qapplication_x11.cpp (change both).
830 
831  bool stopCompression =
832  // 1) misc keys
833  (compressQtKey >= Qt::Key_Escape && compressQtKey <= Qt::Key_SysReq)
834  // 2) cursor movement
835  || (compressQtKey >= Qt::Key_Home && compressQtKey <= Qt::Key_PageDown)
836  // 3) extra keys
837  || (compressQtKey >= Qt::Key_Super_L && compressQtKey <= Qt::Key_Direction_R)
838  // 4) something that a) doesn't translate to text or b) translates
839  // to newline text
840  || (compressQtKey == 0)
841  || (compressChar == QLatin1Char('\n'))
842  || (compressQtKey == Qt::Key_unknown);
843 
844  if (compressMod == modifiers && !compressChar.isNull() && !stopCompression) {
845 #ifdef DEBUG_KEY_BINDINGS
846  qDebug("compressing away %c", compressChar.toLatin1());
847 #endif
848  text += compressChar;
849  // Clean up
850  RemoveEventFromQueue(GetMainEventQueue(), releaseEvent);
851  RemoveEventFromQueue(GetMainEventQueue(), pressEvent);
852  } else {
853 #ifdef DEBUG_KEY_BINDINGS
854  qDebug("stoping compression..");
855 #endif
856  break;
857  }
858  }
859  }
860 
861  // There is no way to get the scan code from carbon. But we cannot use the value 0, since
862  // it indicates that the event originates from somewhere else than the keyboard
863  UInt32 macScanCode = 1;
864  UInt32 macVirtualKey = 0;
865  GetEventParameter(event, kEventParamKeyCode, typeUInt32, 0, sizeof(macVirtualKey), 0, &macVirtualKey);
866  UInt32 macModifiers = 0;
867  GetEventParameter(event, kEventParamKeyModifiers, typeUInt32, 0,
868  sizeof(macModifiers), 0, &macModifiers);
869 #ifdef QT_MAC_USE_COCOA
870  // The unicode characters in the range 0xF700-0xF747 are reserved
871  // by Mac OS X for transient use as keyboard function keys. We
872  // wont send 'text' for such key events. This is done to match
873  // behavior on other platforms.
874  unsigned int *unicodeKey = (unsigned int*)info;
875  if (*unicodeKey >= 0xf700 && *unicodeKey <= 0xf747)
876  text = QString();
877  bool isAccepted;
878 #endif
879  handled_event = QKeyMapper::sendKeyEvent(widget, grab,
880  (ekind == kEventRawKeyUp) ? QEvent::KeyRelease : QEvent::KeyPress,
881  qtKey, modifiers, text, ekind == kEventRawKeyRepeat, 0,
882  macScanCode, macVirtualKey, macModifiers
883 #ifdef QT_MAC_USE_COCOA
884  ,&isAccepted
885 #endif
886  );
887 #ifdef QT_MAC_USE_COCOA
888  *unicodeKey = (unsigned int)isAccepted;
889 #endif
890  }
891  return handled_event;
892 }
T qobject_cast(QObject *object)
Definition: qobject.h:375
static mach_timebase_info_data_t info
EventRef event
QPointer< QWidget > widget
bool isNull() const
Returns true if the character is the Unicode character 0x0000 (&#39;\0&#39;); otherwise returns false...
Definition: qchar.h:262
virtual bool isComposing() const =0
This function indicates whether InputMethodStart event had been sent to the current focus widget...
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
bool qt_mac_eat_unicode_key
Q_CORE_EXPORT void qDebug(const char *,...)
bool testAttribute(Qt::WidgetAttribute) const
Returns true if attribute attribute is set on this widget; otherwise returns false.
Definition: qwidget.h:1041
#define qApp
static bool translateKeyEventInternal(EventHandlerCallRef er, EventRef keyEvent, int *qtKey, QChar *outChar, Qt::KeyboardModifiers *outModifiers, bool *outHandled)
void setLastKeydownEvent(EventRef)
bool qt_mac_menubar_is_open()
Definition: qmenu_mac.mm:750
struct OpaqueEventRef * EventRef
void qt_mac_send_modifiers_changed(quint32 modifiers, QObject *object)
char toLatin1() const
Returns the Latin-1 character equivalent to the QChar, or 0.
Definition: qchar.h:376
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)
static QString qtKey(CFStringRef cfkey)
The QInputContext class abstracts the input method dependent data and composing state.
Definition: qinputcontext.h:83
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
static Boolean qt_KeyEventComparatorProc(EventRef inEvent, void *data)
#define text
Definition: qobjectdefs.h:80

◆ updateKeyMap()

void QKeyMapperPrivate::updateKeyMap ( const MSG msg)

Definition at line 895 of file qkeymapper_mac.cpp.

Referenced by QApplicationPrivate::globalEventProcessor(), qt_dispatchKeyEvent(), QtWndProc(), and setKbdState().

900 {
901  UInt32 macVirtualKey = 0;
902  GetEventParameter(event, kEventParamKeyCode, typeUInt32, 0, sizeof(macVirtualKey), 0, &macVirtualKey);
903  if (updateKeyboard())
905  else if (keyLayout[macVirtualKey])
906  return;
907 
908  UniCharCount buffer_size = 10;
909  UniChar buffer[buffer_size];
910  keyLayout[macVirtualKey] = new KeyboardLayoutItem;
911  for (int i = 0; i < 16; ++i) {
912  UniCharCount out_buffer_size = 0;
913  keyLayout[macVirtualKey]->qtKey[i] = 0;
914 #ifdef Q_WS_MAC32
915  if (keyboard_mode == UnicodeMode) {
916 #endif
917  const UInt32 keyModifier = ((qt_mac_get_mac_modifiers(ModsTbl[i]) >> 8) & 0xFF);
918  OSStatus err = UCKeyTranslate(keyboard_layout_format.unicode, macVirtualKey, kUCKeyActionDown, keyModifier,
919  keyboard_kind, 0, &keyboard_dead, buffer_size, &out_buffer_size, buffer);
920  if (err == noErr && out_buffer_size) {
921  const QChar unicode(buffer[0]);
922  int qtkey = qt_mac_get_key(keyModifier, unicode, macVirtualKey);
923  if (qtkey == Qt::Key_unknown)
924  qtkey = unicode.unicode();
925  keyLayout[macVirtualKey]->qtKey[i] = qtkey;
926  }
927 #ifndef Q_WS_MAC32
928  else {
929  const QChar unicode(*((UniChar *)unicodeKey));
930  int qtkey = qt_mac_get_key(keyModifier, unicode, macVirtualKey);
931  if (qtkey == Qt::Key_unknown)
932  qtkey = unicode.unicode();
933  keyLayout[macVirtualKey]->qtKey[i] = qtkey;
934  }
935 #endif
936 #ifdef Q_WS_MAC32
937  } else {
938  const UInt32 keyModifier = (qt_mac_get_mac_modifiers(ModsTbl[i]));
939 
940  uchar translatedChar = KeyTranslate(keyboard_layout_format.other, keyModifier | macVirtualKey, &keyboard_dead);
941  if (translatedChar) {
942  static QTextCodec *c = 0;
943  if (!c)
944  c = QTextCodec::codecForName("Apple Roman");
945  const QChar unicode(c->toUnicode((const char *)&translatedChar, 1).at(0));
946  int qtkey = qt_mac_get_key(keyModifier, unicode, macVirtualKey);
947  if (qtkey == Qt::Key_unknown)
948  qtkey = unicode.unicode();
949  keyLayout[macVirtualKey]->qtKey[i] = qtkey;
950  }
951  }
952 #endif
953  }
954 #ifdef DEBUG_KEY_MAPS
955  qDebug("updateKeyMap for virtual key = 0x%02x!", (uint)macVirtualKey);
956  for (int i = 0; i < 16; ++i) {
957  qDebug(" [%d] (%d,0x%02x,'%c')", i,
958  keyLayout[macVirtualKey]->qtKey[i],
959  keyLayout[macVirtualKey]->qtKey[i],
960  keyLayout[macVirtualKey]->qtKey[i]);
961  }
962 #endif
963 }
static int qt_mac_get_mac_modifiers(Qt::KeyboardModifiers keys)
unsigned char c[8]
Definition: qnumeric_p.h:62
EventRef event
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
The QChar class provides a 16-bit Unicode character.
Definition: qchar.h:72
Q_CORE_EXPORT void qDebug(const char *,...)
unsigned char uchar
Definition: qglobal.h:994
KeyboardLayoutItem * keyLayout[256]
Definition: qkeymapper_p.h:166
unsigned int uint
Definition: qglobal.h:996
signed long OSStatus
static int qt_mac_get_key(int modif, const QChar &key, int virtualKey)
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
static void changeKeyboard()
Definition: qkeymapper.cpp:90
static QTextCodec * codecForName(const QByteArray &name)
Searches all installed QTextCodec objects and returns the one which best matches name; the match is c...
static const int buffer_size
Definition: qdrawhelper.cpp:80
static QString qtKey(CFStringRef cfkey)
The QTextCodec class provides conversions between text encodings.
Definition: qtextcodec.h:62
static const Qt::KeyboardModifiers ModsTbl[]

◆ updatePossibleKeyCodes()

void QKeyMapperPrivate::updatePossibleKeyCodes ( unsigned char *  kbdBuffer,
quint32  scancode,
quint32  vk_key 
)

Definition at line 675 of file qkeymapper_win.cpp.

677 {
678  if (!vk_key || (keyLayout[vk_key] && !keyLayout[vk_key]->dirty))
679  return;
680 
681  if (!keyLayout[vk_key])
682  keyLayout[vk_key] = new KeyboardLayoutItem;
683 
684  // Copy keyboard state, so we can modify and query output for each possible permutation
685  unsigned char buffer[256];
686  memcpy(buffer, kbdBuffer, sizeof(buffer));
687  // Always 0, as Windows doesn't treat these as modifiers;
688  buffer[VK_LWIN ] = 0;
689  buffer[VK_RWIN ] = 0;
690  buffer[VK_CAPITAL ] = 0;
691  buffer[VK_NUMLOCK ] = 0;
692  buffer[VK_SCROLL ] = 0;
693  // Always 0, since we'll only change the other versions
694  buffer[VK_RSHIFT ] = 0;
695  buffer[VK_RCONTROL] = 0;
696  buffer[VK_LMENU ] = 0; // Use right Alt, since left Ctrl + right Alt is considered AltGraph
697 
698  bool isDeadKey = false;
699  keyLayout[vk_key]->deadkeys = 0;
700  keyLayout[vk_key]->dirty = false;
701  setKbdState(buffer, false, false, false);
702  keyLayout[vk_key]->qtKey[0] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey);
703  keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x01 : 0;
704  setKbdState(buffer, true, false, false);
705  keyLayout[vk_key]->qtKey[1] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey);
706  keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x02 : 0;
707  setKbdState(buffer, false, true, false);
708  keyLayout[vk_key]->qtKey[2] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey);
709  keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x04 : 0;
710  setKbdState(buffer, true, true, false);
711  keyLayout[vk_key]->qtKey[3] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey);
712  keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x08 : 0;
713  setKbdState(buffer, false, false, true);
714  keyLayout[vk_key]->qtKey[4] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey);
715  keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x10 : 0;
716  setKbdState(buffer, true, false, true);
717  keyLayout[vk_key]->qtKey[5] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey);
718  keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x20 : 0;
719  setKbdState(buffer, false, true, true);
720  keyLayout[vk_key]->qtKey[6] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey);
721  keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x40 : 0;
722  setKbdState(buffer, true, true, true);
723  keyLayout[vk_key]->qtKey[7] = toKeyOrUnicode(vk_key, scancode, buffer, &isDeadKey);
724  keyLayout[vk_key]->deadkeys |= isDeadKey ? 0x80 : 0;
725  // Add a fall back key for layouts which don't do composition and show non-latin1 characters
726  int fallbackKey = winceKeyBend(vk_key);
727  if (!fallbackKey || fallbackKey == Qt::Key_unknown) {
728  fallbackKey = 0;
729  if (vk_key != keyLayout[vk_key]->qtKey[0] && vk_key < 0x5B && vk_key > 0x2F)
730  fallbackKey = vk_key;
731  }
732  keyLayout[vk_key]->qtKey[8] = fallbackKey;
733 
734  // If this vk_key makes a dead key with any combination of modifiers
735  if (keyLayout[vk_key]->deadkeys) {
736  // Push a Space, then the original key through the low-level ToAscii functions.
737  // We do this because these functions (ToAscii / ToUnicode) will alter the internal state of
738  // the keyboard driver By doing the following, we set the keyboard driver state back to what
739  // it was before we wrecked it with the code above.
740  // We need to push the space with an empty keystate map, since the driver checks the map for
741  // transitions in modifiers, so this helps us capture all possible deadkeys.
742  unsigned char emptyBuffer[256];
743  memset(emptyBuffer, 0, sizeof(emptyBuffer));
744  ::ToAscii(VK_SPACE, 0, emptyBuffer, reinterpret_cast<LPWORD>(&buffer), 0);
745  ::ToAscii(vk_key, scancode, kbdBuffer, reinterpret_cast<LPWORD>(&buffer), 0);
746  }
747 
748 #ifdef DEBUG_KEYMAPPER
749  qDebug("updatePossibleKeyCodes for virtual key = 0x%02x!", vk_key);
750  for (int i = 0; i < 9; ++i) {
751  qDebug(" [%d] (%d,0x%02x,'%c') %s", i,
752  keyLayout[vk_key]->qtKey[i],
753  keyLayout[vk_key]->qtKey[i],
754  keyLayout[vk_key]->qtKey[i] ? keyLayout[vk_key]->qtKey[i] : 0x03,
755  keyLayout[vk_key]->deadkeys & (1<<i) ? "deadkey" : "");
756  }
757 #endif // DEBUG_KEYMAPPER
758 }
void setKbdState(unsigned char *kbd, bool shift, bool ctrl, bool alt)
Q_CORE_EXPORT void qDebug(const char *,...)
KeyboardLayoutItem * keyLayout[256]
Definition: qkeymapper_p.h:166
int winceKeyBend(int keyCode)
int ToAscii(UINT vk, int scancode, unsigned char *kbdBuffer, LPWORD unicodeBuffer, int flag)
static int toKeyOrUnicode(int vk, int scancode, unsigned char *kbdBuffer, bool *isDeadkey=0)
static QString qtKey(CFStringRef cfkey)

Properties

◆ keyboardInputDirection

Qt::LayoutDirection QKeyMapperPrivate::keyboardInputDirection

Definition at line 156 of file qkeymapper_p.h.

Referenced by QApplication::keyboardInputDirection().

◆ keyboardInputLocale

QLocale QKeyMapperPrivate::keyboardInputLocale

Definition at line 155 of file qkeymapper_p.h.

Referenced by QApplication::keyboardInputLocale().

◆ keyLayout

KeyboardLayoutItem* QKeyMapperPrivate::keyLayout[256]

Definition at line 166 of file qkeymapper_p.h.


The documentation for this class was generated from the following files: