include/mgba/core/input.h (view raw)
1/* Copyright (c) 2013-2016 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 M_INPUT_H
7#define M_INPUT_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13struct Configuration;
14
15struct mInputPlatformInfo {
16 const char* platformName;
17 const char** keyId;
18 size_t nKeys;
19};
20
21struct mInputMap {
22 struct mInputMapImpl* maps;
23 size_t numMaps;
24 const struct mInputPlatformInfo* info;
25};
26
27struct mInputAxis {
28 int highDirection;
29 int lowDirection;
30 int32_t deadHigh;
31 int32_t deadLow;
32};
33
34void mInputMapInit(struct mInputMap*, const struct mInputPlatformInfo* info);
35void mInputMapDeinit(struct mInputMap*);
36
37int mInputMapKey(const struct mInputMap*, uint32_t type, int key);
38int mInputMapKeyBits(const struct mInputMap* map, uint32_t type, uint32_t bits, unsigned offset);
39void mInputBindKey(struct mInputMap*, uint32_t type, int key, int input);
40int mInputQueryBinding(const struct mInputMap*, uint32_t type, int input);
41void mInputUnbindKey(struct mInputMap*, uint32_t type, int input);
42
43int mInputMapAxis(const struct mInputMap*, uint32_t type, int axis, int value);
44int mInputClearAxis(const struct mInputMap*, uint32_t type, int axis, int keys);
45void mInputBindAxis(struct mInputMap*, uint32_t type, int axis, const struct mInputAxis* description);
46void mInputUnbindAxis(struct mInputMap*, uint32_t type, int axis);
47void mInputUnbindAllAxes(struct mInputMap*, uint32_t type);
48const struct mInputAxis* mInputQueryAxis(const struct mInputMap*, uint32_t type, int axis);
49void mInputEnumerateAxes(const struct mInputMap*, uint32_t type, void (handler(int axis, const struct mInputAxis* description, void* user)), void* user);
50
51void mInputMapLoad(struct mInputMap*, uint32_t type, const struct Configuration*);
52void mInputMapSave(const struct mInputMap*, uint32_t type, struct Configuration*);
53
54bool mInputProfileLoad(struct mInputMap*, uint32_t type, const struct Configuration*, const char* profile);
55void mInputProfileSave(const struct mInputMap*, uint32_t type, struct Configuration*, const char* profile);
56
57const char* mInputGetPreferredDevice(const struct Configuration*, const char* platformName, uint32_t type, int playerId);
58void mInputSetPreferredDevice(struct Configuration*, const char* platformName, uint32_t type, int playerId, const char* deviceName);
59
60const char* mInputGetCustomValue(const struct Configuration* config, const char* platformName, uint32_t type, const char* key,
61 const char* profile);
62void mInputSetCustomValue(struct Configuration* config, const char* platformName, uint32_t type, const char* key, const char* value,
63 const char* profile);
64
65CXX_GUARD_END
66
67#endif