all repos — mgba @ f03389bfca8e6ec52815ae2d9941ec7f0a9e691c

mGBA Game Boy Advance Emulator

src/platform/qt/input/InputProfile.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 QGBA_INPUT_PROFILE
 7#define QGBA_INPUT_PROFILE
 8
 9#include "GamepadAxisEvent.h"
10#include "InputIndex.h"
11
12#include <mgba/core/core.h>
13#include <mgba/gba/interface.h>
14
15#include <QRegExp>
16
17class QSettings;
18
19namespace QGBA {
20
21class InputController;
22
23class InputProfile {
24public:
25	constexpr static const char* const PROFILE_SECTION = "profiles";
26	constexpr static const char* const MATCH_SECTION = "match";
27	constexpr static const char* const KEY_SECTION = "keys";
28	constexpr static const char* const BUTTON_SECTION = "buttons";
29	constexpr static const char* const AXIS_SECTION = "axes";
30	constexpr static const char* const HAT_SECTION = "hats";
31
32	static const InputProfile* findProfile(const QString& name);
33	static void loadProfiles(const QString& path);
34
35	void apply(InputController*) const;
36private:
37	InputProfile(const QString&);
38
39	struct Coord {
40		int x;
41		int y;
42	};
43
44	static void loadDefaultProfiles();
45	static void loadProfile(QSettings&, const QString& name);
46
47	static QList<InputProfile> s_profiles;
48
49	QString m_profileName;
50	QList<QRegExp> m_match;
51
52	Coord m_tiltAxis = { 2, 3 };
53	Coord m_gyroAxis = { 0, 1 };
54	float m_gyroSensitivity = 2e+09f;
55	InputIndex m_inputIndex;
56};
57
58}
59
60#endif