all repos — mgba @ 9590b484c73be4c852082a48912110695853b231

mGBA Game Boy Advance Emulator

src/platform/qt/KeyEditor.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_KEY_EDITOR
 7#define QGBA_KEY_EDITOR
 8
 9#include "GamepadAxisEvent.h"
10#include <QLineEdit>
11
12namespace QGBA {
13
14class KeyEditor : public QLineEdit {
15Q_OBJECT
16
17public:
18	KeyEditor(QWidget* parent = nullptr);
19
20	int value() const { return m_key; }
21
22	GamepadAxisEvent::Direction direction() const { return m_direction; }
23	int axis() const { return m_axis; }
24
25	virtual QSize sizeHint() const override;
26
27public slots:
28	void setValue(int key);
29	void setValueKey(int key);
30	void setValueButton(int button);
31	void setValueAxis(int axis, int32_t value);
32	void clearButton();
33	void clearAxis();
34
35signals:
36	void valueChanged(int key);
37	void axisChanged(int key, int direction);
38
39protected:
40	virtual void keyPressEvent(QKeyEvent* event) override;
41	virtual bool event(QEvent* event) override;
42
43private:
44	void updateButtonText();
45
46	int m_key;
47	int m_axis;
48	bool m_button;
49	GamepadAxisEvent::Direction m_direction;
50};
51
52}
53
54#endif