all repos — mgba @ a920eaa7f0867a7e8a887460b4daae466c3f28f5

mGBA Game Boy Advance Emulator

src/gba/input.h (view raw)

 1/* Copyright (c) 2013-2015 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#ifndef GBA_INPUT_H
 7#define GBA_INPUT_H
 8
 9#include "gba/gba.h"
10
11struct Configuration;
12
13struct GBAInputMap {
14	struct GBAInputMapImpl* maps;
15	size_t numMaps;
16};
17
18struct GBAAxis {
19	enum GBAKey highDirection;
20	enum GBAKey lowDirection;
21	int32_t deadHigh;
22	int32_t deadLow;
23};
24
25#define GBA_NO_MAPPING -1
26
27extern const char* GBAKeyNames[];
28
29void GBAInputMapInit(struct GBAInputMap*);
30void GBAInputMapDeinit(struct GBAInputMap*);
31
32enum GBAKey GBAInputMapKey(const struct GBAInputMap*, uint32_t type, int key);
33int GBAInputMapKeyBits(const struct GBAInputMap* map, uint32_t type, uint32_t bits, unsigned offset);
34void GBAInputBindKey(struct GBAInputMap*, uint32_t type, int key, enum GBAKey input);
35void GBAInputUnbindKey(struct GBAInputMap*, uint32_t type, enum GBAKey input);
36int GBAInputQueryBinding(const struct GBAInputMap*, uint32_t type, enum GBAKey input);
37
38enum GBAKey GBAInputMapAxis(const struct GBAInputMap*, uint32_t type, int axis, int value);
39int GBAInputClearAxis(const struct GBAInputMap*, uint32_t type, int axis, int keys);
40void GBAInputBindAxis(struct GBAInputMap*, uint32_t type, int axis, const struct GBAAxis* description);
41void GBAInputUnbindAxis(struct GBAInputMap*, uint32_t type, int axis);
42void GBAInputUnbindAllAxes(struct GBAInputMap*, uint32_t type);
43const struct GBAAxis* GBAInputQueryAxis(const struct GBAInputMap*, uint32_t type, int axis);
44void GBAInputEnumerateAxes(const struct GBAInputMap*, uint32_t type, void (handler(int axis, const struct GBAAxis* description, void* user)), void* user);
45
46void GBAInputMapLoad(struct GBAInputMap*, uint32_t type, const struct Configuration*);
47void GBAInputMapSave(const struct GBAInputMap*, uint32_t type, struct Configuration*);
48
49bool GBAInputProfileLoad(struct GBAInputMap*, uint32_t type, const struct Configuration*, const char* profile);
50void GBAInputProfileSave(const struct GBAInputMap*, uint32_t type, struct Configuration*, const char* profile);
51
52const char* GBAInputGetPreferredDevice(const struct Configuration*, uint32_t type, int playerId);
53void GBAInputSetPreferredDevice(struct Configuration*, uint32_t type, int playerId, const char* deviceName);
54
55const char* GBAInputGetCustomValue(const struct Configuration* config, uint32_t type, const char* key,
56                                   const char* profile);
57void GBAInputSetCustomValue(struct Configuration* config, uint32_t type, const char* key, const char* value,
58                            const char* profile);
59
60#endif