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