all repos — mgba @ 2493e7e5216dd14f0be1023e9c54d03173c1f5a3

mGBA Game Boy Advance Emulator

Merge branch 'feature/input-revamp' into medusa
Vicki Pfau vi@endrift.com
Tue, 11 Apr 2017 13:12:49 -0700
commit

2493e7e5216dd14f0be1023e9c54d03173c1f5a3

parent

9ff5e6c61773a393eb03962a92670850503a6324

2 files changed, 21 insertions(+), 6 deletions(-)

jump to
M src/platform/qt/InputController.cppsrc/platform/qt/InputController.cpp

@@ -110,8 +110,8 @@ m_inputMenuIndices[platform] = m_inputModel->addMenu(input, m_inputMenu.get());

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

@@ -739,7 +739,7 @@ }

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) {
M src/platform/qt/InputModel.cppsrc/platform/qt/InputModel.cpp

@@ -166,7 +166,13 @@ });

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(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; } }