all repos — mgba @ c732ea6a71d410b234ecf76e86c5e4d8bbd98e44

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
25extern const char* GBAKeyNames[];
26
27void GBAInputMapInit(struct GBAInputMap*);
28void GBAInputMapDeinit(struct GBAInputMap*);
29
30enum GBAKey GBAInputMapKey(const struct GBAInputMap*, uint32_t type, int key);
31int GBAInputMapKeyBits(const struct GBAInputMap* map, uint32_t type, uint32_t bits, unsigned offset);
32void GBAInputBindKey(struct GBAInputMap*, uint32_t type, int key, enum GBAKey input);
33void GBAInputUnbindKey(struct GBAInputMap*, uint32_t type, enum GBAKey input);
34int GBAInputQueryBinding(const struct GBAInputMap*, uint32_t type, enum GBAKey input);
35
36enum GBAKey GBAInputMapAxis(const struct GBAInputMap*, uint32_t type, int axis, int value);
37int GBAInputClearAxis(const struct GBAInputMap*, uint32_t type, int axis, int keys);
38void GBAInputBindAxis(struct GBAInputMap*, uint32_t type, int axis, const struct GBAAxis* description);
39void GBAInputUnbindAxis(struct GBAInputMap*, uint32_t type, int axis);
40void GBAInputUnbindAllAxes(struct GBAInputMap*, uint32_t type);
41const struct GBAAxis* GBAInputQueryAxis(const struct GBAInputMap*, uint32_t type, int axis);
42void GBAInputEnumerateAxes(const struct GBAInputMap*, uint32_t type, void (handler(int axis, const struct GBAAxis* description, void* user)), void* user);
43
44void GBAInputMapLoad(struct GBAInputMap*, uint32_t type, const struct Configuration*);
45void GBAInputMapSave(const struct GBAInputMap*, uint32_t type, struct Configuration*);
46
47bool GBAInputProfileLoad(struct GBAInputMap*, uint32_t type, const struct Configuration*, const char* profile);
48void GBAInputProfileSave(const struct GBAInputMap*, uint32_t type, struct Configuration*, const char* profile);
49
50const char* GBAInputGetPreferredDevice(const struct Configuration*, uint32_t type, int playerId);
51void GBAInputSetPreferredDevice(struct Configuration*, uint32_t type, int playerId, const char* deviceName);
52
53const char* GBAInputGetCustomValue(const struct Configuration* config, uint32_t type, const char* key,
54                                   const char* profile);
55void GBAInputSetCustomValue(struct Configuration* config, uint32_t type, const char* key, const char* value,
56                            const char* profile);
57
58#endif