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
15enum mInputHat {
16 M_INPUT_HAT_NEUTRAL = 0,
17 M_INPUT_HAT_UP = 1,
18 M_INPUT_HAT_RIGHT = 2,
19 M_INPUT_HAT_DOWN = 4,
20 M_INPUT_HAT_LEFT = 8
21};
22
23struct mInputHatBindings {
24 int up;
25 int right;
26 int down;
27 int left;
28};
29
30struct mInputPlatformInfo {
31 const char* platformName;
32 const char** keyId;
33 size_t nKeys;
34 struct mInputHatBindings hat;
35};
36
37struct mInputMap {
38 struct mInputMapImpl* maps;
39 size_t numMaps;
40 const struct mInputPlatformInfo* info;
41};
42
43struct mInputAxis {
44 int highDirection;
45 int lowDirection;
46 int32_t deadHigh;
47 int32_t deadLow;
48};
49
50void mInputMapInit(struct mInputMap*, const struct mInputPlatformInfo* info);
51void mInputMapDeinit(struct mInputMap*);
52
53int mInputMapKey(const struct mInputMap*, uint32_t type, int key);
54int mInputMapKeyBits(const struct mInputMap* map, uint32_t type, uint32_t bits, unsigned offset);
55void mInputBindKey(struct mInputMap*, uint32_t type, int key, int input);
56int mInputQueryBinding(const struct mInputMap*, uint32_t type, int input);
57void mInputUnbindKey(struct mInputMap*, uint32_t type, int input);
58
59int mInputMapAxis(const struct mInputMap*, uint32_t type, int axis, int value);
60int mInputClearAxis(const struct mInputMap*, uint32_t type, int axis, int keys);
61void mInputBindAxis(struct mInputMap*, uint32_t type, int axis, const struct mInputAxis* description);
62void mInputUnbindAxis(struct mInputMap*, uint32_t type, int axis);
63void mInputUnbindAllAxes(struct mInputMap*, uint32_t type);
64const struct mInputAxis* mInputQueryAxis(const struct mInputMap*, uint32_t type, int axis);
65void mInputEnumerateAxes(const struct mInputMap*, uint32_t type, void (handler(int axis, const struct mInputAxis* description, void* user)), void* user);
66
67int mInputMapHat(const struct mInputMap*, uint32_t type, int id, int direction);
68void mInputBindHat(struct mInputMap*, uint32_t type, int id, const struct mInputHatBindings* bindings);
69void mInputUnbindHat(struct mInputMap*, uint32_t type, int id);
70void mInputUnbindAllHats(struct mInputMap*, uint32_t type);
71
72void mInputMapLoad(struct mInputMap*, uint32_t type, const struct Configuration*);
73void mInputMapSave(const struct mInputMap*, uint32_t type, struct Configuration*);
74
75bool mInputProfileLoad(struct mInputMap*, uint32_t type, const struct Configuration*, const char* profile);
76void mInputProfileSave(const struct mInputMap*, uint32_t type, struct Configuration*, const char* profile);
77
78const char* mInputGetPreferredDevice(const struct Configuration*, const char* platformName, uint32_t type, int playerId);
79void mInputSetPreferredDevice(struct Configuration*, const char* platformName, uint32_t type, int playerId, const char* deviceName);
80
81const char* mInputGetCustomValue(const struct Configuration* config, const char* platformName, uint32_t type, const char* key,
82 const char* profile);
83void mInputSetCustomValue(struct Configuration* config, const char* platformName, uint32_t type, const char* key, const char* value,
84 const char* profile);
85
86CXX_GUARD_END
87
88#endif