From c95d0b7b07da602d9894a6e01c667dc7e4c80343 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 11 Apr 2017 13:06:50 -0700 Subject: [PATCH 1/2] Qt: Shortcut loading fixes --- src/platform/qt/InputModel.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/platform/qt/InputModel.cpp b/src/platform/qt/InputModel.cpp index ebf94b820..58af9de6e 100644 --- a/src/platform/qt/InputModel.cpp +++ b/src/platform/qt/InputModel.cpp @@ -166,7 +166,13 @@ void InputModel::addKey(QMenu* menu, mPlatform platform, int key, int shortcut, if (!item) { return; } - m_keys[qMakePair(platform, key)] = item; + bool loadedShortcut = false; + if (m_config) { + loadedShortcut = loadShortcuts(item); + } + if (!loadedShortcut && !m_keys.contains(qMakePair(platform, shortcut))) { + m_keys[qMakePair(platform, shortcut)] = item; + } } QModelIndex InputModel::addMenu(QMenu* menu, QMenu* parentMenu) { @@ -254,11 +260,20 @@ void InputModel::updateKey(const QModelIndex& index, int keySequence) { void InputModel::updateKey(InputItem* item, int keySequence) { int oldShortcut = item->shortcut(); - if (item->functions().first || item->key() >= 0) { + if (item->functions().first) { if (oldShortcut > 0) { m_heldKeys.take(oldShortcut); } - if (keySequence >= 0) { + if (keySequence > 0) { + m_heldKeys[keySequence] = item; + } + } + + if (item->key() >= 0) { + if (oldShortcut > 0) { + m_keys.take(qMakePair(item->platform(), oldShortcut)); + } + if (keySequence > 0) { m_keys[qMakePair(item->platform(), keySequence)] = item; } } From 91068d14b9d6e1e028b32aa14a9ae46f99a6a89e Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 11 Apr 2017 13:07:04 -0700 Subject: [PATCH 2/2] Qt: Fix autofire --- src/platform/qt/InputController.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platform/qt/InputController.cpp b/src/platform/qt/InputController.cpp index bd8947b17..93b8718af 100644 --- a/src/platform/qt/InputController.cpp +++ b/src/platform/qt/InputController.cpp @@ -100,8 +100,8 @@ void InputController::addPlatform(mPlatform platform, const QString& visibleName m_inputModel->addMenu(autofire, m_autofireMenu.get()); for (size_t i = 0; i < info->nKeys; ++i) { - m_inputModel->addKey(input, platform, i, 0, info->keyId[i], info->keyId[i]); - m_inputModel->addKey(autofire, platform, i, 0, info->keyId[i], info->keyId[i]); + m_inputModel->addKey(input, platform, i, 0, info->keyId[i], QString("%1.%2").arg(info->platformName).arg(info->keyId[i])); + m_inputModel->addKey(autofire, platform, i, 0, info->keyId[i], QString("%1.autofire.%2").arg(info->platformName).arg(info->keyId[i])); } #ifdef BUILD_SDL @@ -693,7 +693,7 @@ void InputController::releaseFocus(QWidget* focus) { void InputController::setupCallback(GameController* controller) { m_inputModel->setKeyCallback([this, controller](QMenu* menu, int key, bool down) { - if (menu == m_autofireMenu.get()) { + if (menu->parent() == m_autofireMenu.get()) { controller->setAutofire(key, down); } else { if (down) {