all repos — mgba @ ab5d40e45152948f30e72f7f11cb57a5dab56ed7

mGBA Game Boy Advance Emulator

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