Core: Have per-core input information

This commit is contained in:
Vicki Pfau 2017-03-02 01:07:09 -08:00
parent aaeef69d96
commit 908b0a425e
7 changed files with 93 additions and 4 deletions

View File

@ -54,6 +54,7 @@ struct mCore {
#endif
#ifndef MINIMAL_CORE
struct mInputMap inputMap;
const struct mInputPlatformInfo* inputInfo;
#endif
struct mCoreConfig config;
struct mCoreOptions opts;

View File

@ -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

View File

@ -11,8 +11,9 @@
#include <mgba/internal/arm/debugger/debugger.h>
#include <mgba/internal/ds/ds.h>
#include <mgba/internal/ds/extra/cli.h>
#include <mgba/internal/ds/renderers/software.h>
#include <mgba/internal/ds/gx/software.h>
#include <mgba/internal/ds/input.h>
#include <mgba/internal/ds/renderers/software.h>
#include <mgba-util/memory.h>
#include <mgba-util/patch.h>
#include <mgba-util/vfs.h>
@ -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;
}

31
src/ds/input.c Normal file
View File

@ -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
}
};

View File

@ -20,6 +20,10 @@
#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 @@ 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;
}

View File

@ -22,6 +22,10 @@
#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;
@ -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;
}

View File

@ -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);