Compare commits

..

No commits in common. "659bf38bdac0861a797173024bf53184cbb7447d" and "d4a49fbf79d52f7d155be8e0a4ab83290cdf1f0e" have entirely different histories.

View file

@ -33,13 +33,14 @@ struct ReverseMapEntry {
UInt16 keyCode;
};
static std::vector<ReverseMapEntry> mapping;
std::vector<ReverseMapEntry> mapping;
/// References:
/// * https://github.com/libsdl-org/SDL/blob/fc12cc6dfd859a4e01376162a58f12208e539ac6/src/video/cocoa/SDL_cocoakeyboard.m#L345
/// * https://github.com/qt/qtbase/blob/922369844fcb75386237bca3eef59edd5093f58d/src/gui/platform/darwin/qapplekeymapper.mm#L449
///
/// Known possible flaws 1) UCKeyTranslate doesn't handle modifiers at all 2) Handling keyboard switching
/// Known flaw:
/// * UCKeyTranslate doesn't handle modifiers at all.
void createMapping()
{
if (mapping.empty()) {
@ -52,13 +53,13 @@ void createMapping()
CFDataRef uchrDataRef = (CFDataRef)TISGetInputSourceProperty(inputSourceRef, kTISPropertyUnicodeKeyLayoutData);
const UCKeyboardLayout* UCKeyboardLayoutPtr;
const UCKeyboardLayout* UCkeyboardLayoutPtr;
if (uchrDataRef) {
UCKeyboardLayoutPtr = (const UCKeyboardLayout*)CFDataGetBytePtr(uchrDataRef);
UCkeyboardLayoutPtr = (const UCKeyboardLayout*)CFDataGetBytePtr(uchrDataRef);
}
if (!UCKeyboardLayoutPtr) {
if (!UCkeyboardLayoutPtr) {
return;
}
@ -66,7 +67,7 @@ void createMapping()
UInt32 theDeadKeyState = 0;
UniCharCount theLength = 0;
UniChar temp_char_buf;
if (UCKeyTranslate(UCKeyboardLayoutPtr, i, kUCKeyActionDown, 0, LMGetKbdType(),
if (UCKeyTranslate(UCkeyboardLayoutPtr, i, kUCKeyActionDown, 0, LMGetKbdType(),
kUCKeyTranslateNoDeadKeysBit, &theDeadKeyState, 1, &theLength,
&temp_char_buf)
== noErr
@ -80,7 +81,7 @@ void createMapping()
}
}
quint32 qtKeyToNativeKey(UniChar key)
quint32 qtKeyToNativeKey(quint32 key)
{
createMapping();
if (mapping.empty()) {
@ -340,7 +341,7 @@ quint32 HotkeyWrapper::nativeKey(int key)
return 0x72;
default:;
}
return MacKeyMapping::qtKeyToNativeKey(QChar(key).toLower().unicode());
return MacKeyMapping::qtKeyToNativeKey(QChar(key).toLower().toLatin1());
}
void HotkeyWrapper::sendCmdC()