From fb9df7270d1f5174fd9031b2647d9af9c62af7b9 Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Sun, 26 Mar 2017 23:39:03 -0700 Subject: [PATCH] GB: Add input information --- include/mgba/internal/gb/input.h | 32 ++++++++++++++++++++++++++++++++ src/gb/core.c | 3 ++- src/gb/input.c | 29 +++++++++++++++++++++++++++++ src/platform/qt/Window.cpp | 3 ++- 4 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 include/mgba/internal/gb/input.h create mode 100644 src/gb/input.c diff --git a/include/mgba/internal/gb/input.h b/include/mgba/internal/gb/input.h new file mode 100644 index 000000000..4e507ddc3 --- /dev/null +++ b/include/mgba/internal/gb/input.h @@ -0,0 +1,32 @@ +/* Copyright (c) 2013-2017 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#ifndef GB_INPUT_H +#define GB_INPUT_H + +#include + +CXX_GUARD_START + +#include + +extern const struct mInputPlatformInfo GBInputInfo; + +enum GBKey { + GB_KEY_A = 0, + GB_KEY_B = 1, + GB_KEY_SELECT = 2, + GB_KEY_START = 3, + GB_KEY_RIGHT = 4, + GB_KEY_LEFT = 5, + GB_KEY_UP = 6, + GB_KEY_DOWN = 7, + GB_KEY_MAX, + GB_KEY_NONE = -1 +}; + +CXX_GUARD_END + +#endif diff --git a/src/gb/core.c b/src/gb/core.c index 1ad3a39c8..749ea19f2 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -68,7 +69,7 @@ static bool _GBCoreInit(struct mCore* core) { #endif #ifndef MINIMAL_CORE - core->inputInfo = &GBAInputInfo; // TODO: GBInputInfo + core->inputInfo = &GBInputInfo; #endif return true; diff --git a/src/gb/input.c b/src/gb/input.c new file mode 100644 index 000000000..6dcceb50e --- /dev/null +++ b/src/gb/input.c @@ -0,0 +1,29 @@ +/* Copyright (c) 2013-2017 Jeffrey Pfau + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include + +#include + +const struct mInputPlatformInfo GBInputInfo = { + .platformName = "gb", + .keyId = (const char*[]) { + "A", + "B", + "Select", + "Start", + "Right", + "Left", + "Up", + "Down" + }, + .nKeys = GB_KEY_MAX, + .hat = { + .up = GB_KEY_UP, + .left = GB_KEY_LEFT, + .down = GB_KEY_DOWN, + .right = GB_KEY_RIGHT + } +}; diff --git a/src/platform/qt/Window.cpp b/src/platform/qt/Window.cpp index 11003001e..b092c17b1 100644 --- a/src/platform/qt/Window.cpp +++ b/src/platform/qt/Window.cpp @@ -47,6 +47,7 @@ #include #ifdef M_CORE_GB #include +#include #include #endif #ifdef M_CORE_GBA @@ -207,7 +208,7 @@ Window::Window(ConfigController* config, int playerId, QWidget* parent) m_inputController.addPlatform(PLATFORM_GBA, tr("Game Boy Advance"), &GBAInputInfo); #endif #ifdef M_CORE_GB - m_inputController.addPlatform(PLATFORM_GB, tr("Game Boy"), &GBAInputInfo); + m_inputController.addPlatform(PLATFORM_GB, tr("Game Boy"), &GBInputInfo); #endif m_inputController.setupCallback(m_controller); }