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 QTimer;
19
20namespace QGBA {
21
22class InputController;
23class KeyEditor;
24
25class GBAKeyEditor : public QWidget {
26Q_OBJECT
27
28public:
29 GBAKeyEditor(InputController* controller, int type, QWidget* parent = nullptr);
30
31public slots:
32 void setAll();
33
34protected:
35 virtual void resizeEvent(QResizeEvent*) override;
36 virtual void paintEvent(QPaintEvent*) override;
37
38private slots:
39 void setNext();
40 void save();
41#ifdef BUILD_SDL
42 void setAxisValue(int axis, int32_t value);
43#endif
44
45private:
46 static const qreal DPAD_CENTER_X;
47 static const qreal DPAD_CENTER_Y;
48 static const qreal DPAD_WIDTH;
49 static const qreal DPAD_HEIGHT;
50
51 void setLocation(QWidget* widget, qreal x, qreal y);
52
53 void lookupBinding(const GBAInputMap*, KeyEditor*, GBAKey);
54 void bindKey(const KeyEditor*, GBAKey);
55
56 bool findFocus();
57
58#ifdef BUILD_SDL
59 void lookupAxes(const GBAInputMap*);
60#endif
61
62 KeyEditor* keyById(GBAKey);
63
64 QWidget* m_buttons;
65 KeyEditor* m_keyDU;
66 KeyEditor* m_keyDD;
67 KeyEditor* m_keyDL;
68 KeyEditor* m_keyDR;
69 KeyEditor* m_keySelect;
70 KeyEditor* m_keyStart;
71 KeyEditor* m_keyA;
72 KeyEditor* m_keyB;
73 KeyEditor* m_keyL;
74 KeyEditor* m_keyR;
75 QList<KeyEditor*> m_keyOrder;
76 QList<KeyEditor*>::iterator m_currentKey;
77
78 uint32_t m_type;
79 InputController* m_controller;
80
81 QPicture m_background;
82};
83
84}
85
86#endif