Qt: Fix keys being mapped incorrectly when loading configuration file (fixes #212)
Jeffrey Pfau jeffrey@endrift.com
Sat, 23 Jan 2016 20:14:46 -0800
3 files changed,
12 insertions(+),
6 deletions(-)
M
CHANGES
→
CHANGES
@@ -34,6 +34,7 @@ - Libretro: Fix aspect ratio
- Qt: Fix some potential crashes with the gamepad mapping - Debugger: Fix watchpoints in gdb - ARM7: Fix decoding of some ARM ALU instructions with shifters + - Qt: Fix keys being mapped incorrectly when loading configuration file Misc: - Qt: Window size command line options are now supported - Qt: Increase usability of key mapper
M
src/platform/qt/ShortcutController.cpp
→
src/platform/qt/ShortcutController.cpp
@@ -137,10 +137,13 @@ beginInsertRows(parent, smenu->items().count(), smenu->items().count());
smenu->addFunctions(qMakePair(press, release), shortcut, visibleName, name); endInsertRows(); ShortcutItem* item = &smenu->items().last(); + bool loadedShortcut = false; if (m_config) { - loadShortcuts(item); + loadedShortcut = loadShortcuts(item); + } + if (!loadedShortcut && !m_heldKeys.contains(shortcut)) { + m_heldKeys[shortcut] = item; } - m_heldKeys[shortcut] = item; emit dataChanged(createIndex(smenu->items().count() - 1, 0, item), createIndex(smenu->items().count() - 1, 2, item)); }@@ -387,10 +390,11 @@ }
return false; } -void ShortcutController::loadShortcuts(ShortcutItem* item) { +bool ShortcutController::loadShortcuts(ShortcutItem* item) { if (item->name().isNull()) { - return; + return false; } + loadGamepadShortcuts(item); QVariant shortcut = m_config->getQtOption(item->name(), KEY_SECTION); if (!shortcut.isNull()) { if (shortcut.toString().endsWith("+")) {@@ -398,8 +402,9 @@ updateKey(item, toModifierShortcut(shortcut.toString()));
} else { updateKey(item, QKeySequence(shortcut.toString())[0]); } + return true; } - loadGamepadShortcuts(item); + return false; } void ShortcutController::loadGamepadShortcuts(ShortcutItem* item) {
M
src/platform/qt/ShortcutController.h
→
src/platform/qt/ShortcutController.h
@@ -128,7 +128,7 @@
private: ShortcutItem* itemAt(const QModelIndex& index); const ShortcutItem* itemAt(const QModelIndex& index) const; - void loadShortcuts(ShortcutItem*); + bool loadShortcuts(ShortcutItem*); void loadGamepadShortcuts(ShortcutItem*); void onSubitems(ShortcutItem*, std::function<void(ShortcutItem*)> func); void updateKey(ShortcutItem* item, int keySequence);