src/platform/qt/InputController.h (view raw)
1/* Copyright (c) 2013-2014 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_CONTROLLER_H
7#define QGBA_INPUT_CONTROLLER_H
8
9extern "C" {
10#include "gba-input.h"
11
12#ifdef BUILD_SDL
13#include "platform/sdl/sdl-events.h"
14#endif
15}
16
17#include <QSet>
18
19namespace QGBA {
20
21class ConfigController;
22
23class InputController {
24public:
25 static const uint32_t KEYBOARD = 0x51545F4B;
26
27 InputController();
28 ~InputController();
29
30 void setConfiguration(ConfigController* config);
31 void loadConfiguration(uint32_t type);
32 void saveConfiguration(uint32_t type = KEYBOARD);
33
34 GBAKey mapKeyboard(int key) const;
35
36 void bindKey(uint32_t type, int key, GBAKey);
37
38 const GBAInputMap* map() const { return &m_inputMap; }
39
40#ifdef BUILD_SDL
41 static const int32_t AXIS_THRESHOLD = 0x3000;
42 enum Direction {
43 NEUTRAL = 0,
44 POSITIVE = 1,
45 NEGATIVE = -1
46 };
47
48 int testSDLEvents();
49 QSet<int> activeGamepadButtons();
50 QSet<QPair<int, int32_t>> activeGamepadAxes();
51
52 void bindAxis(uint32_t type, int axis, Direction, GBAKey);
53#endif
54
55private:
56 GBAInputMap m_inputMap;
57 ConfigController* m_config;
58
59#ifdef BUILD_SDL
60 GBASDLEvents m_sdlEvents;
61#endif
62};
63
64}
65
66#endif