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
41private slots:
42 void setNext();
43 void save();
44 void refresh();
45#ifdef BUILD_SDL
46 void setAxisValue(int axis, int32_t value);
47#endif
48
49private:
50 static const qreal DPAD_CENTER_X;
51 static const qreal DPAD_CENTER_Y;
52 static const qreal DPAD_WIDTH;
53 static const qreal DPAD_HEIGHT;
54
55 void setLocation(QWidget* widget, qreal x, qreal y);
56
57 void lookupBinding(const GBAInputMap*, KeyEditor*, GBAKey);
58 void bindKey(const KeyEditor*, GBAKey);
59
60 bool findFocus();
61
62#ifdef BUILD_SDL
63 void lookupAxes(const GBAInputMap*);
64#endif
65
66 KeyEditor* keyById(GBAKey);
67
68 QComboBox* m_profileSelect;
69 QWidget* m_buttons;
70 KeyEditor* m_keyDU;
71 KeyEditor* m_keyDD;
72 KeyEditor* m_keyDL;
73 KeyEditor* m_keyDR;
74 KeyEditor* m_keySelect;
75 KeyEditor* m_keyStart;
76 KeyEditor* m_keyA;
77 KeyEditor* m_keyB;
78 KeyEditor* m_keyL;
79 KeyEditor* m_keyR;
80 QList<KeyEditor*> m_keyOrder;
81 QList<KeyEditor*>::iterator m_currentKey;
82
83 uint32_t m_type;
84 QString m_profile;
85 InputController* m_controller;
86
87 QPicture m_background;
88};
89
90}
91
92#endif