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