Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavide Beatrici <git@davidebeatrici.dev>2021-02-05 05:35:58 +0300
committerDavide Beatrici <git@davidebeatrici.dev>2021-02-05 05:35:58 +0300
commit2e04d1e23f284c00da54565e2d415f30b9f09a33 (patch)
tree11c1cfbae869fba37fa0108fb7974dbdea345b07
parent0d125a3c30a4bf3dc33058b9f5a869df0a962675 (diff)
FEAT(client): Update platform-specific GlobalShortcut backends for ButtonInfo
-rw-r--r--src/mumble/GlobalShortcut_macx.h2
-rw-r--r--src/mumble/GlobalShortcut_macx.mm33
-rw-r--r--src/mumble/GlobalShortcut_unix.cpp25
-rw-r--r--src/mumble/GlobalShortcut_unix.h2
-rw-r--r--src/mumble/GlobalShortcut_win.cpp93
-rw-r--r--src/mumble/GlobalShortcut_win.h2
6 files changed, 94 insertions, 63 deletions
diff --git a/src/mumble/GlobalShortcut_macx.h b/src/mumble/GlobalShortcut_macx.h
index 032845007..20f8d4498 100644
--- a/src/mumble/GlobalShortcut_macx.h
+++ b/src/mumble/GlobalShortcut_macx.h
@@ -21,7 +21,7 @@ private:
public:
GlobalShortcutMac();
~GlobalShortcutMac() Q_DECL_OVERRIDE;
- QString buttonName(const QVariant &) Q_DECL_OVERRIDE;
+ ButtonInfo buttonInfo(const QVariant &) Q_DECL_OVERRIDE;
void dumpEventTaps();
void needRemap() Q_DECL_OVERRIDE;
bool handleModButton(CGEventFlags newmask);
diff --git a/src/mumble/GlobalShortcut_macx.mm b/src/mumble/GlobalShortcut_macx.mm
index ef3366da9..94ba6e5dd 100644
--- a/src/mumble/GlobalShortcut_macx.mm
+++ b/src/mumble/GlobalShortcut_macx.mm
@@ -352,7 +352,7 @@ bool GlobalShortcutMac::handleModButton(const CGEventFlags newmask) {
}
QString GlobalShortcutMac::translateMouseButton(const unsigned int keycode) const {
- return QString::fromLatin1("Mouse Button %1").arg(keycode-MOUSE_OFFSET+1);
+ return QString::fromLatin1("%1").arg(keycode - MOUSE_OFFSET + 1);
}
QString GlobalShortcutMac::translateModifierKey(const unsigned int keycode) const {
@@ -424,23 +424,30 @@ QString GlobalShortcutMac::translateKeyName(const unsigned int keycode) const {
return QString(reinterpret_cast<const QChar *>(unicodeString), len).toUpper();
}
-QString GlobalShortcutMac::buttonName(const QVariant &v) {
+GlobalShortcutMac::ButtonInfo GlobalShortcutMac::buttonInfo(const QVariant &v) {
bool ok;
unsigned int key = v.toUInt(&ok);
- if (!ok)
- return QString();
+ if (!ok) {
+ return ButtonInfo();
+ }
- if (key >= MOUSE_OFFSET)
- return translateMouseButton(key);
- else if (key >= MOD_OFFSET)
- return translateModifierKey(key);
- else {
- QString str = translateKeyName(key);
- if (!str.isEmpty())
- return str;
+ ButtonInfo info;
+
+ if (key >= MOUSE_OFFSET) {
+ info.device = tr("Mouse");
+ info.devicePrefix = QLatin1String("M");
+ info.name = translateMouseButton(key);
+ return info;
+ } else {
+ info.device = tr("Keyboard");
+ info.name = key >= MOD_OFFSET ? translateModifierKey(key) : translateKeyName(key);
+ if (!info.name.isEmpty()) {
+ return info;
+ }
}
- return QString::fromLatin1("Keycode %1").arg(key);
+ info.name = QString::number(key);
+ return info;
}
void GlobalShortcutMac::setEnabled(bool b) {
diff --git a/src/mumble/GlobalShortcut_unix.cpp b/src/mumble/GlobalShortcut_unix.cpp
index 73961e5ce..ce89ca787 100644
--- a/src/mumble/GlobalShortcut_unix.cpp
+++ b/src/mumble/GlobalShortcut_unix.cpp
@@ -353,28 +353,37 @@ void GlobalShortcutX::directoryChanged(const QString &dir) {
#endif
}
-QString GlobalShortcutX::buttonName(const QVariant &v) {
+GlobalShortcutX::ButtonInfo GlobalShortcutX::buttonInfo(const QVariant &v) {
bool ok;
unsigned int key = v.toUInt(&ok);
- if (!ok)
- return QString();
+ if (!ok) {
+ return ButtonInfo();
+ }
+
+ ButtonInfo info;
+
if ((key < 0x118) || (key >= 0x128)) {
+ info.device = tr("Keyboard");
// For backwards compatibility reasons we want to keep using the
// old function as long as possible. The replacement function
// XkbKeycodeToKeysym requires the XKB extension which isn't
// guaranteed to be present.
KeySym ks = XKeycodeToKeysym(display, static_cast< KeyCode >(key), 0);
if (ks == NoSymbol) {
- return QLatin1String("0x") + QString::number(key, 16);
+ info.name = QLatin1String("0x") + QString::number(key, 16);
} else {
const char *str = XKeysymToString(ks);
- if (*str == '\0') {
- return QLatin1String("KS0x") + QString::number(ks, 16);
+ if (str[0] == '\0') {
+ info.name = QLatin1String("KS0x") + QString::number(ks, 16);
} else {
- return QLatin1String(str);
+ info.name = QLatin1String(str);
}
}
} else {
- return tr("Mouse %1").arg(key - 0x118);
+ info.device = tr("Mouse");
+ info.devicePrefix = QLatin1String("M");
+ info.name = QString::number(key - 0x118);
}
+
+ return info;
}
diff --git a/src/mumble/GlobalShortcut_unix.h b/src/mumble/GlobalShortcut_unix.h
index b29310f7f..6f0022757 100644
--- a/src/mumble/GlobalShortcut_unix.h
+++ b/src/mumble/GlobalShortcut_unix.h
@@ -34,7 +34,7 @@ public:
GlobalShortcutX();
~GlobalShortcutX() Q_DECL_OVERRIDE;
void run() Q_DECL_OVERRIDE;
- QString buttonName(const QVariant &) Q_DECL_OVERRIDE;
+ ButtonInfo buttonInfo(const QVariant &) Q_DECL_OVERRIDE;
void queryXIMasterList();
public slots:
diff --git a/src/mumble/GlobalShortcut_win.cpp b/src/mumble/GlobalShortcut_win.cpp
index 4ea28fdb3..76286bb28 100644
--- a/src/mumble/GlobalShortcut_win.cpp
+++ b/src/mumble/GlobalShortcut_win.cpp
@@ -787,36 +787,42 @@ void GlobalShortcutWin::timeTicked() {
}
}
-QString GlobalShortcutWin::buttonName(const QVariant &v) {
+GlobalShortcutWin::ButtonInfo GlobalShortcutWin::buttonInfo(const QVariant &v) {
GlobalShortcutWin *gsw = static_cast< GlobalShortcutWin * >(GlobalShortcutEngine::engine);
const QList< QVariant > &sublist = v.toList();
- if (sublist.count() != 2)
- return QString();
+ if (sublist.count() != 2) {
+ return ButtonInfo();
+ }
bool ok = false;
DWORD type = sublist.at(0).toUInt(&ok);
QUuid guid(sublist.at(1).toString());
- if (guid.isNull() || (!ok))
- return QString();
+ if (guid.isNull() || (!ok)) {
+ return ButtonInfo();
+ }
- QString device = guid.toString();
- QString name = QLatin1String("Unknown");
+ ButtonInfo info;
+ info.device = guid.toString();
#ifdef USE_GKEY
if (g.s.bEnableGKey && gkey && gkey->isValid()) {
bool isGKey = false;
if (guid == GKeyLibrary::quMouse) {
- isGKey = true;
- name = gkey->getMouseButtonString(type);
+ isGKey = true;
+ info.name = gkey->getMouseButtonString(type);
} else if (guid == GKeyLibrary::quKeyboard) {
- isGKey = true;
- name = gkey->getKeyboardGkeyString(type & 0xFFFF, type >> 16);
+ isGKey = true;
+ info.name = gkey->getKeyboardGkeyString(type & 0xFFFF, type >> 16);
}
if (isGKey) {
- device = QLatin1String("GKey:");
- return device + name; // Example output: "Gkey:G6/M1"
+ // Example output:
+ // "Logitech G-keys"
+ // "G6/M1"
+ info.device = QLatin1String("Logitech G-keys");
+ info.devicePrefix = QLatin1String("GKey:");
+ return info;
}
}
#endif
@@ -826,65 +832,74 @@ QString GlobalShortcutWin::buttonName(const QVariant &v) {
uint32_t idx = (type >> 24) & 0xff;
uint32_t button = (type & 0x00ffffff);
+ info.device = QString::fromLatin1("Xbox controller #%1").arg(idx + 1);
+ info.devicePrefix = QString::fromLatin1("Xbox%1:").arg(idx + 1);
+
// Translate from our own button index mapping to
// the actual Xbox controller button names.
// For a description of the mapping, see the state
// querying code in GlobalShortcutWin::timeTicked().
switch (button) {
case 0:
- return QString::fromLatin1("Xbox%1:Up").arg(idx + 1);
+ info.name = QLatin1String("Up");
case 1:
- return QString::fromLatin1("Xbox%1:Down").arg(idx + 1);
+ info.name = QLatin1String("Down");
case 2:
- return QString::fromLatin1("Xbox%1:Left").arg(idx + 1);
+ info.name = QLatin1String("Left");
case 3:
- return QString::fromLatin1("Xbox%1:Right").arg(idx + 1);
+ info.name = QLatin1String("Right");
case 4:
- return QString::fromLatin1("Xbox%1:Start").arg(idx + 1);
+ info.name = QLatin1String("Start");
case 5:
- return QString::fromLatin1("Xbox%1:Back").arg(idx + 1);
+ info.name = QLatin1String("Back");
case 6:
- return QString::fromLatin1("Xbox%1:LeftThumb").arg(idx + 1);
+ info.name = QLatin1String("LeftThumb");
case 7:
- return QString::fromLatin1("Xbox%1:RightThumb").arg(idx + 1);
+ info.name = QLatin1String("RightThumb");
case 8:
- return QString::fromLatin1("Xbox%1:LeftShoulder").arg(idx + 1);
+ info.name = QLatin1String("LeftShoulder");
case 9:
- return QString::fromLatin1("Xbox%1:RightShoulder").arg(idx + 1);
+ info.name = QLatin1String("RightShoulder");
case 10:
- return QString::fromLatin1("Xbox%1:Guide").arg(idx + 1);
+ info.name = QLatin1String("Guide");
case 11:
- return QString::fromLatin1("Xbox%1:11").arg(idx + 1);
+ info.name = QLatin1String("11");
case 12:
- return QString::fromLatin1("Xbox%1:A").arg(idx + 1);
+ info.name = QLatin1String("A");
case 13:
- return QString::fromLatin1("Xbox%1:B").arg(idx + 1);
+ info.name = QLatin1String("B");
case 14:
- return QString::fromLatin1("Xbox%1:X").arg(idx + 1);
+ info.name = QLatin1String("X");
case 15:
- return QString::fromLatin1("Xbox%1:Y").arg(idx + 1);
+ info.name = QLatin1String("Y");
case 16:
- return QString::fromLatin1("Xbox%1:LeftTrigger").arg(idx + 1);
+ info.name = QLatin1String("LeftTrigger");
case 17:
- return QString::fromLatin1("Xbox%1:RightTrigger").arg(idx + 1);
+ info.name = QLatin1String("RightTrigger");
}
+
+ return info;
}
#endif
InputDevice *id = gsw->qhInputDevices.value(guid);
- if (guid == GUID_SysMouse)
- device = QLatin1String("M:");
- else if (guid == GUID_SysKeyboard)
- device = QLatin1String("K:");
- else if (id)
- device = id->name + QLatin1String(":");
+ if (guid == GUID_SysMouse) {
+ info.device = tr("Mouse");
+ info.devicePrefix = QLatin1String("M");
+ } else if (guid == GUID_SysKeyboard) {
+ info.device = tr("Keyboard");
+ } else if (id) {
+ info.device = id->name;
+ }
+
if (id) {
QString result = id->qhNames.value(type);
if (!result.isEmpty()) {
- name = result;
+ info.name = result;
}
}
- return device + name;
+
+ return info;
}
bool GlobalShortcutWin::canSuppress() {
diff --git a/src/mumble/GlobalShortcut_win.h b/src/mumble/GlobalShortcut_win.h
index 7772fac3f..988eafeb9 100644
--- a/src/mumble/GlobalShortcut_win.h
+++ b/src/mumble/GlobalShortcut_win.h
@@ -104,7 +104,7 @@ public:
GlobalShortcutWin();
~GlobalShortcutWin() Q_DECL_OVERRIDE;
void unacquire();
- QString buttonName(const QVariant &) Q_DECL_OVERRIDE;
+ ButtonInfo buttonInfo(const QVariant &) Q_DECL_OVERRIDE;
/// Inject a native Windows keyboard message into GlobalShortcutWin's
/// event stream. This method is meant to be called from the main thread