all repos — mgba @ 908b0a425ec5e33391b47ac674e7cef9de01e8bc

mGBA Game Boy Advance Emulator

Core: Have per-core input information
Vicki Pfau vi@endrift.com
Thu, 02 Mar 2017 01:07:09 -0800
commit

908b0a425ec5e33391b47ac674e7cef9de01e8bc

parent

aaeef69d968f45352a8bfcdb1807da284a76fe89

M include/mgba/core/core.hinclude/mgba/core/core.h

@@ -54,6 +54,7 @@ struct mDirectorySet dirs;

#endif #ifndef MINIMAL_CORE struct mInputMap inputMap; + const struct mInputPlatformInfo* inputInfo; #endif struct mCoreConfig config; struct mCoreOptions opts;
A 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 <mgba-util/common.h> + +CXX_GUARD_START + +#include <mgba/core/input.h> + +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
M src/ds/core.csrc/ds/core.c

@@ -11,8 +11,9 @@ #include <mgba/core/log.h>

#include <mgba/internal/arm/debugger/debugger.h> #include <mgba/internal/ds/ds.h> #include <mgba/internal/ds/extra/cli.h> +#include <mgba/internal/ds/gx/software.h> +#include <mgba/internal/ds/input.h> #include <mgba/internal/ds/renderers/software.h> -#include <mgba/internal/ds/gx/software.h> #include <mgba-util/memory.h> #include <mgba-util/patch.h> #include <mgba-util/vfs.h>

@@ -75,7 +76,11 @@

#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 mDirectorySetInit(&core->dirs); #endif - + +#ifndef MINIMAL_CORE + core->inputInfo = &DSInputInfo; // TODO: GBInputInfo +#endif + return true; }
A 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 <mgba/internal/ds/input.h> + +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 + } +};
M src/gb/core.csrc/gb/core.c

@@ -20,6 +20,10 @@ #include <mgba-util/memory.h>

#include <mgba-util/patch.h> #include <mgba-util/vfs.h> +#ifndef MINIMAL_CORE +#include <mgba/internal/gba/input.h> +#endif + struct GBCore { struct mCore d; struct GBVideoSoftwareRenderer renderer;

@@ -60,7 +64,11 @@

#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 mDirectorySetInit(&core->dirs); #endif - + +#ifndef MINIMAL_CORE + core->inputInfo = &GBAInputInfo; // TODO: GBInputInfo +#endif + return true; }
M src/gba/core.csrc/gba/core.c

@@ -22,6 +22,10 @@ #include <mgba-util/memory.h>

#include <mgba-util/patch.h> #include <mgba-util/vfs.h> +#ifndef MINIMAL_CORE +#include <mgba/internal/gba/input.h> +#endif + struct GBACore { struct mCore d; struct GBAVideoSoftwareRenderer renderer;

@@ -72,6 +76,10 @@ gba->keySource = &gbacore->keys;

#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 mDirectorySetInit(&core->dirs); +#endif + +#ifndef MINIMAL_CORE + core->inputInfo = &GBAInputInfo; #endif return true;
M src/platform/sdl/main.csrc/platform/sdl/main.c

@@ -97,7 +97,7 @@ freeArguments(&args);

return 1; } - mInputMapInit(&renderer.core->inputMap, &GBAInputInfo); + mInputMapInit(&renderer.core->inputMap, renderer.core->inputInfo); mCoreInitConfig(renderer.core, PORT); applyArguments(&args, &subparser, &renderer.core->config);