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