diff --git a/include/mgba/core/core.h b/include/mgba/core/core.h index 385cbe58e..d1c497d8d 100644 --- a/include/mgba/core/core.h +++ b/include/mgba/core/core.h @@ -54,6 +54,7 @@ struct mCore { #endif #ifndef MINIMAL_CORE struct mInputMap inputMap; + const struct mInputPlatformInfo* inputInfo; #endif struct mCoreConfig config; struct mCoreOptions opts; diff --git a/include/mgba/internal/ds/input.h b/include/mgba/internal/ds/input.h new file mode 100644 index 000000000..59922372e --- /dev/null +++ b/include/mgba/internal/ds/input.h @@ -0,0 +1,36 @@ +/* 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 DS_INPUT_H +#define DS_INPUT_H + +#include + +CXX_GUARD_START + +#include + +extern const struct mInputPlatformInfo DSInputInfo; + +enum GBAKey { + DS_KEY_A = 0, + DS_KEY_B = 1, + DS_KEY_SELECT = 2, + DS_KEY_START = 3, + DS_KEY_RIGHT = 4, + DS_KEY_LEFT = 5, + DS_KEY_UP = 6, + DS_KEY_DOWN = 7, + DS_KEY_R = 8, + DS_KEY_L = 9, + DS_KEY_X = 10, + DS_KEY_Y = 11, + DS_KEY_MAX, + DS_KEY_NONE = -1 +}; + +CXX_GUARD_END + +#endif diff --git a/src/ds/core.c b/src/ds/core.c index 98168e031..95e1a2b0d 100644 --- a/src/ds/core.c +++ b/src/ds/core.c @@ -11,8 +11,9 @@ #include #include #include -#include #include +#include +#include #include #include #include @@ -75,7 +76,11 @@ static bool _DSCoreInit(struct mCore* core) { #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 mDirectorySetInit(&core->dirs); #endif - + +#ifndef MINIMAL_CORE + core->inputInfo = &DSInputInfo; // TODO: GBInputInfo +#endif + return true; } diff --git a/src/ds/input.c b/src/ds/input.c new file mode 100644 index 000000000..a64d4ae04 --- /dev/null +++ b/src/ds/input.c @@ -0,0 +1,31 @@ +/* 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 + +const struct mInputPlatformInfo DSInputInfo = { + .platformName = "ds", + .keyId = (const char*[]) { + "A", + "B", + "Select", + "Start", + "Right", + "Left", + "Up", + "Down", + "R", + "L", + "X", + "Y" + }, + .nKeys = DS_KEY_MAX, + .hat = { + .up = DS_KEY_UP, + .left = DS_KEY_LEFT, + .down = DS_KEY_DOWN, + .right = DS_KEY_RIGHT + } +}; diff --git a/src/gb/core.c b/src/gb/core.c index ef006d265..be1208faf 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -20,6 +20,10 @@ #include #include +#ifndef MINIMAL_CORE +#include +#endif + struct GBCore { struct mCore d; struct GBVideoSoftwareRenderer renderer; @@ -60,7 +64,11 @@ static bool _GBCoreInit(struct mCore* core) { #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 mDirectorySetInit(&core->dirs); #endif - + +#ifndef MINIMAL_CORE + core->inputInfo = &GBAInputInfo; // TODO: GBInputInfo +#endif + return true; } diff --git a/src/gba/core.c b/src/gba/core.c index fef994b0f..c35074e88 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -22,6 +22,10 @@ #include #include +#ifndef MINIMAL_CORE +#include +#endif + struct GBACore { struct mCore d; struct GBAVideoSoftwareRenderer renderer; @@ -73,6 +77,10 @@ static bool _GBACoreInit(struct mCore* core) { #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 mDirectorySetInit(&core->dirs); #endif + +#ifndef MINIMAL_CORE + core->inputInfo = &GBAInputInfo; +#endif return true; } diff --git a/src/platform/sdl/main.c b/src/platform/sdl/main.c index 9bbabedbc..87aed5ba5 100644 --- a/src/platform/sdl/main.c +++ b/src/platform/sdl/main.c @@ -97,7 +97,7 @@ int main(int argc, char** argv) { return 1; } - mInputMapInit(&renderer.core->inputMap, &GBAInputInfo); + mInputMapInit(&renderer.core->inputMap, renderer.core->inputInfo); mCoreInitConfig(renderer.core, PORT); applyArguments(&args, &subparser, &renderer.core->config);