all repos — mgba @ 97b82ae6cdd2202e41d3c91df07979048d46a79f

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
33signals:
34	void valueChanged(int key);
35	void axisChanged(int key, int direction);
36
37protected:
38	virtual void keyPressEvent(QKeyEvent* event) override;
39	virtual bool event(QEvent* event) override;
40
41private:
42	void updateButtonText();
43
44	int m_key;
45	int m_axis;
46	bool m_button;
47	GamepadAxisEvent::Direction m_direction;
48};
49
50}
51
52#endif