mirror of https://github.com/mgba-emu/mgba.git
GBA Input: Consolidate GBA_KEY_NONE and GBA_NO_MAPPING
This commit is contained in:
parent
a920eaa7f0
commit
c732ea6a71
1
CHANGES
1
CHANGES
|
@ -53,6 +53,7 @@ Misc:
|
||||||
- 3DS: Update to new ctrulib API
|
- 3DS: Update to new ctrulib API
|
||||||
- GBA RR: Add preliminary SRAM support for VBM loading
|
- GBA RR: Add preliminary SRAM support for VBM loading
|
||||||
- GBA RR: Add support for resets in movies
|
- GBA RR: Add support for resets in movies
|
||||||
|
- GBA Input: Consolidate GBA_KEY_NONE and GBA_NO_MAPPING
|
||||||
|
|
||||||
0.3.2: (2015-12-16)
|
0.3.2: (2015-12-16)
|
||||||
Bugfixes:
|
Bugfixes:
|
||||||
|
|
|
@ -95,7 +95,11 @@ static struct GBAInputMapImpl* _guaranteeMap(struct GBAInputMap* map, uint32_t t
|
||||||
map->numMaps = 1;
|
map->numMaps = 1;
|
||||||
impl = &map->maps[0];
|
impl = &map->maps[0];
|
||||||
impl->type = type;
|
impl->type = type;
|
||||||
impl->map = calloc(GBA_KEY_MAX, sizeof(int));
|
impl->map = malloc(GBA_KEY_MAX * sizeof(int));
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < GBA_KEY_MAX; ++i) {
|
||||||
|
impl->map[i] = GBA_KEY_NONE;
|
||||||
|
}
|
||||||
TableInit(&impl->axes, 2, free);
|
TableInit(&impl->axes, 2, free);
|
||||||
} else {
|
} else {
|
||||||
impl = _lookupMap(map, type);
|
impl = _lookupMap(map, type);
|
||||||
|
@ -110,7 +114,11 @@ static struct GBAInputMapImpl* _guaranteeMap(struct GBAInputMap* map, uint32_t t
|
||||||
}
|
}
|
||||||
if (impl) {
|
if (impl) {
|
||||||
impl->type = type;
|
impl->type = type;
|
||||||
impl->map = calloc(GBA_KEY_MAX, sizeof(int));
|
impl->map = malloc(GBA_KEY_MAX * sizeof(int));
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < GBA_KEY_MAX; ++i) {
|
||||||
|
impl->map[i] = GBA_KEY_NONE;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
map->maps = realloc(map->maps, sizeof(*map->maps) * map->numMaps * 2);
|
map->maps = realloc(map->maps, sizeof(*map->maps) * map->numMaps * 2);
|
||||||
for (m = map->numMaps * 2 - 1; m > map->numMaps; --m) {
|
for (m = map->numMaps * 2 - 1; m > map->numMaps; --m) {
|
||||||
|
@ -120,7 +128,11 @@ static struct GBAInputMapImpl* _guaranteeMap(struct GBAInputMap* map, uint32_t t
|
||||||
map->numMaps *= 2;
|
map->numMaps *= 2;
|
||||||
impl = &map->maps[m];
|
impl = &map->maps[m];
|
||||||
impl->type = type;
|
impl->type = type;
|
||||||
impl->map = calloc(GBA_KEY_MAX, sizeof(int));
|
impl->map = malloc(GBA_KEY_MAX * sizeof(int));
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < GBA_KEY_MAX; ++i) {
|
||||||
|
impl->map[i] = GBA_KEY_NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
TableInit(&impl->axes, 2, free);
|
TableInit(&impl->axes, 2, free);
|
||||||
}
|
}
|
||||||
|
@ -378,18 +390,18 @@ void GBAInputUnbindKey(struct GBAInputMap* map, uint32_t type, enum GBAKey input
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (impl) {
|
if (impl) {
|
||||||
impl->map[input] = GBA_NO_MAPPING;
|
impl->map[input] = GBA_KEY_NONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int GBAInputQueryBinding(const struct GBAInputMap* map, uint32_t type, enum GBAKey input) {
|
int GBAInputQueryBinding(const struct GBAInputMap* map, uint32_t type, enum GBAKey input) {
|
||||||
if (input >= GBA_KEY_MAX) {
|
if (input >= GBA_KEY_MAX) {
|
||||||
return 0;
|
return GBA_KEY_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct GBAInputMapImpl* impl = _lookupMapConst(map, type);
|
const struct GBAInputMapImpl* impl = _lookupMapConst(map, type);
|
||||||
if (!impl || !impl->map) {
|
if (!impl || !impl->map) {
|
||||||
return 0;
|
return GBA_KEY_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return impl->map[input];
|
return impl->map[input];
|
||||||
|
|
|
@ -22,8 +22,6 @@ struct GBAAxis {
|
||||||
int32_t deadLow;
|
int32_t deadLow;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GBA_NO_MAPPING -1
|
|
||||||
|
|
||||||
extern const char* GBAKeyNames[];
|
extern const char* GBAKeyNames[];
|
||||||
|
|
||||||
void GBAInputMapInit(struct GBAInputMap*);
|
void GBAInputMapInit(struct GBAInputMap*);
|
||||||
|
|
|
@ -249,7 +249,7 @@ void GBAKeyEditor::lookupBinding(const GBAInputMap* map, KeyEditor* keyEditor, G
|
||||||
#ifdef BUILD_SDL
|
#ifdef BUILD_SDL
|
||||||
if (m_type == SDL_BINDING_BUTTON) {
|
if (m_type == SDL_BINDING_BUTTON) {
|
||||||
int value = GBAInputQueryBinding(map, m_type, key);
|
int value = GBAInputQueryBinding(map, m_type, key);
|
||||||
if (value != GBA_NO_MAPPING) {
|
if (value != GBA_KEY_NONE) {
|
||||||
keyEditor->setValueButton(value);
|
keyEditor->setValueButton(value);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue