all repos — mgba @ bc1a094bead8ffa1d9d03beebfa8676511d7ac0b

mGBA Game Boy Advance Emulator

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	virtual ~GBAKeyEditor();
32
33public slots:
34	void setAll();
35
36protected:
37	virtual void resizeEvent(QResizeEvent*) override;
38	virtual void paintEvent(QPaintEvent*) override;
39	virtual bool event(QEvent*) override;
40	virtual void closeEvent(QCloseEvent*) override;
41	virtual bool eventFilter(QObject* obj, QEvent* event) override;
42
43private slots:
44	void setNext();
45	void save();
46	void refresh();
47#ifdef BUILD_SDL
48	void setAxisValue(int axis, int32_t value);
49	void selectGamepad(int index);
50#endif
51
52private:
53	static const qreal DPAD_CENTER_X;
54	static const qreal DPAD_CENTER_Y;
55	static const qreal DPAD_WIDTH;
56	static const qreal DPAD_HEIGHT;
57
58	void setLocation(QWidget* widget, qreal x, qreal y);
59
60	void lookupBinding(const GBAInputMap*, KeyEditor*, GBAKey);
61	void bindKey(const KeyEditor*, GBAKey);
62
63	bool findFocus(KeyEditor* needle = nullptr);
64
65#ifdef BUILD_SDL
66	void lookupAxes(const GBAInputMap*);
67#endif
68
69	KeyEditor* keyById(GBAKey);
70
71	QComboBox* m_profileSelect;
72	QWidget* m_clear;
73	QWidget* m_buttons;
74	KeyEditor* m_keyDU;
75	KeyEditor* m_keyDD;
76	KeyEditor* m_keyDL;
77	KeyEditor* m_keyDR;
78	KeyEditor* m_keySelect;
79	KeyEditor* m_keyStart;
80	KeyEditor* m_keyA;
81	KeyEditor* m_keyB;
82	KeyEditor* m_keyL;
83	KeyEditor* m_keyR;
84	QList<KeyEditor*> m_keyOrder;
85	QList<KeyEditor*>::iterator m_currentKey;
86
87	uint32_t m_type;
88	QString m_profile;
89	InputController* m_controller;
90
91	QPicture m_background;
92};
93
94}
95
96#endif