src/platform/qt/GBAKeyEditor.h (view raw)
1/* Copyright (c) 2013-2014 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 <QWidget>
12
13namespace QGBA {
14
15class InputController;
16class KeyEditor;
17
18class GBAKeyEditor : public QWidget {
19Q_OBJECT
20
21public:
22 GBAKeyEditor(InputController* controller, int type, QWidget* parent = nullptr);
23
24public slots:
25 void setAll();
26
27protected:
28 virtual void resizeEvent(QResizeEvent*) override;
29 virtual void paintEvent(QPaintEvent*) override;
30
31private slots:
32 void setNext();
33 void save();
34#ifdef BUILD_SDL
35 void testGamepad();
36#endif
37
38private:
39 static const qreal DPAD_CENTER_X;
40 static const qreal DPAD_CENTER_Y;
41 static const qreal DPAD_WIDTH;
42 static const qreal DPAD_HEIGHT;
43
44 void setLocation(QWidget* widget, qreal x, qreal y);
45
46
47#ifdef BUILD_SDL
48 QTimer* m_gamepadTimer;
49#endif
50
51 QWidget* m_buttons;
52 KeyEditor* m_keyDU;
53 KeyEditor* m_keyDD;
54 KeyEditor* m_keyDL;
55 KeyEditor* m_keyDR;
56 KeyEditor* m_keySelect;
57 KeyEditor* m_keyStart;
58 KeyEditor* m_keyA;
59 KeyEditor* m_keyB;
60 KeyEditor* m_keyL;
61 KeyEditor* m_keyR;
62 QList<KeyEditor*> m_keyOrder;
63 QList<KeyEditor*>::iterator m_currentKey;
64
65 uint32_t m_type;
66 InputController* m_controller;
67
68 QPicture m_background;
69};
70
71}
72
73#endif