all repos — mgba @ 2f2e5398719f9d6a78ae84fc241945b46839b01c

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
24	virtual QSize sizeHint() const override;
25
26public slots:
27	void setValue(int key);
28	void setValueKey(int key);
29	void setValueButton(int button);
30	void setValueAxis(int axis, int32_t value);
31
32signals:
33	void valueChanged(int key);
34	void axisChanged(int key, int direction);
35
36protected:
37	virtual void keyPressEvent(QKeyEvent* event) override;
38	virtual bool event(QEvent* event) override;
39
40private:
41	int m_key;
42	bool m_button;
43	GamepadAxisEvent::Direction m_direction;
44};
45
46}
47
48#endif