From adaf8d6224ba52d6dbb8210601c52daef7b0b469 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 4 Apr 2017 18:41:43 -0700 Subject: [PATCH] Qt: Add default keybindings for GB and DS --- src/platform/qt/InputController.cpp | 66 ++++++++++++++++++++++++----- 1 file changed, 56 insertions(+), 10 deletions(-) diff --git a/src/platform/qt/InputController.cpp b/src/platform/qt/InputController.cpp index bc287cec9..7bbf51cd1 100644 --- a/src/platform/qt/InputController.cpp +++ b/src/platform/qt/InputController.cpp @@ -21,6 +21,16 @@ #include #include +#ifdef M_CORE_GBA +#include +#endif +#ifdef M_CORE_GB +#include +#endif +#ifdef M_CORE_DS +#include +#endif + using namespace QGBA; #ifdef BUILD_SDL @@ -107,16 +117,52 @@ void InputController::addPlatform(mPlatform platform, const QString& visibleName #ifdef BUILD_SDL mSDLInitBindingsGBA(inputMap); #endif - mInputBindKey(inputMap, KEYBOARD, Qt::Key_X, GBA_KEY_A); - mInputBindKey(inputMap, KEYBOARD, Qt::Key_Z, GBA_KEY_B); - mInputBindKey(inputMap, KEYBOARD, Qt::Key_A, GBA_KEY_L); - mInputBindKey(inputMap, KEYBOARD, Qt::Key_S, GBA_KEY_R); - mInputBindKey(inputMap, KEYBOARD, Qt::Key_Return, GBA_KEY_START); - mInputBindKey(inputMap, KEYBOARD, Qt::Key_Backspace, GBA_KEY_SELECT); - mInputBindKey(inputMap, KEYBOARD, Qt::Key_Up, GBA_KEY_UP); - mInputBindKey(inputMap, KEYBOARD, Qt::Key_Down, GBA_KEY_DOWN); - mInputBindKey(inputMap, KEYBOARD, Qt::Key_Left, GBA_KEY_LEFT); - mInputBindKey(inputMap, KEYBOARD, Qt::Key_Right, GBA_KEY_RIGHT); + switch (platform) { +#ifdef M_CORE_GBA + case PLATFORM_GBA: + mInputBindKey(inputMap, KEYBOARD, Qt::Key_X, GBA_KEY_A); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Z, GBA_KEY_B); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_A, GBA_KEY_L); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_S, GBA_KEY_R); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Return, GBA_KEY_START); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Backspace, GBA_KEY_SELECT); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Up, GBA_KEY_UP); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Down, GBA_KEY_DOWN); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Left, GBA_KEY_LEFT); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Right, GBA_KEY_RIGHT); + break; +#endif +#ifdef M_CORE_GB + case PLATFORM_GB: + mInputBindKey(inputMap, KEYBOARD, Qt::Key_X, GB_KEY_A); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Z, GB_KEY_B); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Return, GB_KEY_START); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Backspace, GB_KEY_SELECT); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Up, GB_KEY_UP); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Down, GB_KEY_DOWN); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Left, GB_KEY_LEFT); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Right, GB_KEY_RIGHT); + break; +#endif +#ifdef M_CORE_DS + case PLATFORM_DS: + mInputBindKey(inputMap, KEYBOARD, Qt::Key_X, DS_KEY_A); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Z, DS_KEY_B); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_A, DS_KEY_X); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_S, DS_KEY_Y); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Q, DS_KEY_L); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_W, DS_KEY_R); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Return, DS_KEY_START); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Backspace, DS_KEY_SELECT); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Up, DS_KEY_UP); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Down, DS_KEY_DOWN); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Left, DS_KEY_LEFT); + mInputBindKey(inputMap, KEYBOARD, Qt::Key_Right, DS_KEY_RIGHT); + break; +#endif + default: + break; + } } void InputController::setPlatform(mPlatform platform) {