GBA Input: Consolidate GBA_KEY_NONE and GBA_NO_MAPPING
Jeffrey Pfau jeffrey@endrift.com
Thu, 07 Jan 2016 23:50:01 -0800
4 files changed,
20 insertions(+),
9 deletions(-)
M
CHANGES
→
CHANGES
@@ -53,6 +53,7 @@ - Libretro: Add install target for libretro core
- 3DS: Update to new ctrulib API - GBA RR: Add preliminary SRAM support for VBM loading - GBA RR: Add support for resets in movies + - GBA Input: Consolidate GBA_KEY_NONE and GBA_NO_MAPPING 0.3.2: (2015-12-16) Bugfixes:
M
src/gba/input.c
→
src/gba/input.c
@@ -95,7 +95,11 @@ map->maps = malloc(sizeof(*map->maps));
map->numMaps = 1; impl = &map->maps[0]; 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); } else { impl = _lookupMap(map, type);@@ -110,7 +114,11 @@ }
} if (impl) { 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 { map->maps = realloc(map->maps, sizeof(*map->maps) * map->numMaps * 2); for (m = map->numMaps * 2 - 1; m > map->numMaps; --m) {@@ -120,7 +128,11 @@ }
map->numMaps *= 2; impl = &map->maps[m]; 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); }@@ -378,18 +390,18 @@ if (input < 0 || input >= GBA_KEY_MAX) {
return; } 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) { if (input >= GBA_KEY_MAX) { - return 0; + return GBA_KEY_NONE; } const struct GBAInputMapImpl* impl = _lookupMapConst(map, type); if (!impl || !impl->map) { - return 0; + return GBA_KEY_NONE; } return impl->map[input];
M
src/gba/input.h
→
src/gba/input.h
@@ -22,8 +22,6 @@ int32_t deadHigh;
int32_t deadLow; }; -#define GBA_NO_MAPPING -1 - extern const char* GBAKeyNames[]; void GBAInputMapInit(struct GBAInputMap*);
M
src/platform/qt/GBAKeyEditor.cpp
→
src/platform/qt/GBAKeyEditor.cpp
@@ -249,7 +249,7 @@ void GBAKeyEditor::lookupBinding(const GBAInputMap* map, KeyEditor* keyEditor, GBAKey key) {
#ifdef BUILD_SDL if (m_type == SDL_BINDING_BUTTON) { int value = GBAInputQueryBinding(map, m_type, key); - if (value != GBA_NO_MAPPING) { + if (value != GBA_KEY_NONE) { keyEditor->setValueButton(value); } return;