mirror of https://github.com/mgba-emu/mgba.git
GBA Input: Add GBAInputMapKeyBits for packed key information
This commit is contained in:
parent
036784e49f
commit
33b66e5d44
|
@ -348,6 +348,20 @@ enum GBAKey GBAInputMapKey(const struct GBAInputMap* map, uint32_t type, int key
|
||||||
return GBA_KEY_NONE;
|
return GBA_KEY_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int GBAInputMapKeyBits(const struct GBAInputMap* map, uint32_t type, uint32_t bits, unsigned offset) {
|
||||||
|
int keys = 0;
|
||||||
|
for (; bits; bits >>= 1, ++offset) {
|
||||||
|
if (bits & 1) {
|
||||||
|
enum GBAKey key = GBAInputMapKey(map, type, offset);
|
||||||
|
if (key == GBA_KEY_NONE) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
keys |= 1 << key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
void GBAInputBindKey(struct GBAInputMap* map, uint32_t type, int key, enum GBAKey input) {
|
void GBAInputBindKey(struct GBAInputMap* map, uint32_t type, int key, enum GBAKey input) {
|
||||||
struct GBAInputMapImpl* impl = _guaranteeMap(map, type);
|
struct GBAInputMapImpl* impl = _guaranteeMap(map, type);
|
||||||
GBAInputUnbindKey(map, type, input);
|
GBAInputUnbindKey(map, type, input);
|
||||||
|
|
|
@ -30,6 +30,7 @@ void GBAInputMapInit(struct GBAInputMap*);
|
||||||
void GBAInputMapDeinit(struct GBAInputMap*);
|
void GBAInputMapDeinit(struct GBAInputMap*);
|
||||||
|
|
||||||
enum GBAKey GBAInputMapKey(const struct GBAInputMap*, uint32_t type, int key);
|
enum GBAKey GBAInputMapKey(const struct GBAInputMap*, uint32_t type, int key);
|
||||||
|
int GBAInputMapKeyBits(const struct GBAInputMap* map, uint32_t type, uint32_t bits, unsigned offset);
|
||||||
void GBAInputBindKey(struct GBAInputMap*, uint32_t type, int key, enum GBAKey input);
|
void GBAInputBindKey(struct GBAInputMap*, uint32_t type, int key, enum GBAKey input);
|
||||||
void GBAInputUnbindKey(struct GBAInputMap*, uint32_t type, enum GBAKey input);
|
void GBAInputUnbindKey(struct GBAInputMap*, uint32_t type, enum GBAKey input);
|
||||||
int GBAInputQueryBinding(const struct GBAInputMap*, uint32_t type, enum GBAKey input);
|
int GBAInputQueryBinding(const struct GBAInputMap*, uint32_t type, enum GBAKey input);
|
||||||
|
|
Loading…
Reference in New Issue