all repos — mgba @ 9a19aaed5933859fb8b0ed8910a93ab96e117f51

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
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_clear;
70	QWidget* m_buttons;
71	KeyEditor* m_keyDU;
72	KeyEditor* m_keyDD;
73	KeyEditor* m_keyDL;
74	KeyEditor* m_keyDR;
75	KeyEditor* m_keySelect;
76	KeyEditor* m_keyStart;
77	KeyEditor* m_keyA;
78	KeyEditor* m_keyB;
79	KeyEditor* m_keyL;
80	KeyEditor* m_keyR;
81	QList<KeyEditor*> m_keyOrder;
82	QList<KeyEditor*>::iterator m_currentKey;
83
84	uint32_t m_type;
85	QString m_profile;
86	InputController* m_controller;
87
88	QPicture m_background;
89};
90
91}
92
93#endif