src/platform/qt/GBAKeyEditor.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#pragma once
7
8#include <QList>
9#include <QPicture>
10#include <QSet>
11#include <QWidget>
12
13#include <mgba/internal/gba/input.h>
14
15class QComboBox;
16class QTimer;
17
18namespace QGBA {
19
20class InputController;
21class KeyEditor;
22
23class GBAKeyEditor : public QWidget {
24Q_OBJECT
25
26public:
27 GBAKeyEditor(InputController* controller, int type, const QString& profile = QString(), QWidget* parent = nullptr);
28 virtual ~GBAKeyEditor();
29
30public slots:
31 void setAll();
32 void save();
33
34protected:
35 virtual void resizeEvent(QResizeEvent*) override;
36 virtual void paintEvent(QPaintEvent*) override;
37 virtual bool event(QEvent*) override;
38 virtual void closeEvent(QCloseEvent*) override;
39 virtual bool eventFilter(QObject* obj, QEvent* event) override;
40
41private slots:
42 void setNext();
43 void refresh();
44#ifdef BUILD_SDL
45 void setAxisValue(int axis, int32_t value);
46 void selectGamepad(int index);
47 void updateJoysticks();
48#endif
49
50private:
51 static const qreal DPAD_CENTER_X;
52 static const qreal DPAD_CENTER_Y;
53 static const qreal DPAD_WIDTH;
54 static const qreal DPAD_HEIGHT;
55
56 void setLocation(QWidget* widget, qreal x, qreal y);
57
58 void lookupBinding(const mInputMap*, KeyEditor*, GBAKey);
59 void bindKey(const KeyEditor*, GBAKey);
60
61 bool findFocus(KeyEditor* needle = nullptr);
62
63#ifdef BUILD_SDL
64 void lookupAxes(const mInputMap*);
65 void lookupHats(const mInputMap*);
66#endif
67
68 KeyEditor* keyById(GBAKey);
69
70 QComboBox* m_profileSelect = nullptr;
71 QWidget* m_clear = nullptr;
72 QWidget* m_buttons;
73 KeyEditor* m_keyDU;
74 KeyEditor* m_keyDD;
75 KeyEditor* m_keyDL;
76 KeyEditor* m_keyDR;
77 KeyEditor* m_keySelect;
78 KeyEditor* m_keyStart;
79 KeyEditor* m_keyA;
80 KeyEditor* m_keyB;
81 KeyEditor* m_keyL;
82 KeyEditor* m_keyR;
83 QList<KeyEditor*> m_keyOrder;
84 QList<KeyEditor*>::iterator m_currentKey;
85
86 uint32_t m_type;
87 QString m_profile;
88 InputController* m_controller;
89
90 QPicture m_background;
91};
92
93}