Qt: Implement control config dialog.
This commit is contained in:
parent
83ebb04cc2
commit
d16070ecb4
|
@ -74,6 +74,7 @@ SOURCES += main.cpp\
|
||||||
ds.cpp \
|
ds.cpp \
|
||||||
video.cpp \
|
video.cpp \
|
||||||
ui/controlconfigdialog.cpp \
|
ui/controlconfigdialog.cpp \
|
||||||
|
ui/controlitemconfigdialog.cpp \
|
||||||
ds_input.cpp \
|
ds_input.cpp \
|
||||||
keyboardinput.cpp
|
keyboardinput.cpp
|
||||||
|
|
||||||
|
@ -84,6 +85,7 @@ HEADERS += ui/mainwindow.h \
|
||||||
ds.h \
|
ds.h \
|
||||||
video.h \
|
video.h \
|
||||||
ui/controlconfigdialog.h \
|
ui/controlconfigdialog.h \
|
||||||
|
ui/controlitemconfigdialog.h \
|
||||||
keyboardinput.h \
|
keyboardinput.h \
|
||||||
ds_input.h
|
ds_input.h
|
||||||
|
|
||||||
|
@ -91,7 +93,8 @@ RESOURCES += \
|
||||||
resources/resources.qrc
|
resources/resources.qrc
|
||||||
|
|
||||||
FORMS += ui/mainwindow.ui \
|
FORMS += ui/mainwindow.ui \
|
||||||
ui/controlconfigdialog.ui
|
ui/controlconfigdialog.ui \
|
||||||
|
ui/controlitemconfigdialog.ui
|
||||||
|
|
||||||
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../core/release/ -ldesmume
|
win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../core/release/ -ldesmume
|
||||||
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../core/debug/ -ldesmume
|
else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../core/debug/ -ldesmume
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
#include "ds.h"
|
#include "ds.h"
|
||||||
#include "keyboardinput.h"
|
#include "keyboardinput.h"
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
|
#include <QKeySequence>
|
||||||
|
|
||||||
namespace desmume {
|
namespace desmume {
|
||||||
namespace qt {
|
namespace qt {
|
||||||
|
@ -43,9 +46,32 @@ KeyboardInput::KeyboardInput() {
|
||||||
mKeyAssignment[ds::KEY_LID] = Qt::Key_Backspace;
|
mKeyAssignment[ds::KEY_LID] = Qt::Key_Backspace;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyboardInput::keyPress(int key) {
|
int KeyboardInput::getAssignedKey(ds::KeysEnum key) const {
|
||||||
|
if (key >= 0 && key < ds::KEY_COUNT) {
|
||||||
|
return mKeyAssignment[key];
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KeyboardInput::isKeyAssigned(int keyboardKey) const {
|
||||||
for (int i = 0; i < ds::KEY_COUNT; i++) {
|
for (int i = 0; i < ds::KEY_COUNT; i++) {
|
||||||
if (mKeyAssignment[i] == key) {
|
if (mKeyAssignment[i] == keyboardKey) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void KeyboardInput::setAssignedKey(ds::KeysEnum key, int keyboardKey) {
|
||||||
|
if (key >= 0 && key < ds::KEY_COUNT) {
|
||||||
|
mKeyAssignment[key] = keyboardKey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool KeyboardInput::keyPress(int keyboardKey) {
|
||||||
|
for (int i = 0; i < ds::KEY_COUNT; i++) {
|
||||||
|
if (mKeyAssignment[i] == keyboardKey) {
|
||||||
ds::input.keyPress((ds::KeysEnum)i);
|
ds::input.keyPress((ds::KeysEnum)i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -53,9 +79,9 @@ bool KeyboardInput::keyPress(int key) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeyboardInput::keyRelease(int key) {
|
bool KeyboardInput::keyRelease(int keyboardKey) {
|
||||||
for (int i = 0; i < ds::KEY_COUNT; i++) {
|
for (int i = 0; i < ds::KEY_COUNT; i++) {
|
||||||
if (mKeyAssignment[i] == key) {
|
if (mKeyAssignment[i] == keyboardKey) {
|
||||||
ds::input.keyRelease((ds::KeysEnum)i);
|
ds::input.keyRelease((ds::KeysEnum)i);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -63,5 +89,43 @@ bool KeyboardInput::keyRelease(int key) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KeyboardInput::from(const KeyboardInput& other){
|
||||||
|
::memcpy(mKeyAssignment, other.mKeyAssignment, ds::KEY_COUNT * sizeof(mKeyAssignment[0]));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString KeyboardInput::getKeyDisplayText(int key) {
|
||||||
|
Qt::Key k = (Qt::Key)key;
|
||||||
|
QString str;
|
||||||
|
switch (k) {
|
||||||
|
case Qt::Key_Shift:
|
||||||
|
str = QKeySequence(Qt::ShiftModifier).toString();
|
||||||
|
if (str.endsWith('+')) {
|
||||||
|
str.chop(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Qt::Key_Control:
|
||||||
|
str = QKeySequence(Qt::ControlModifier).toString();
|
||||||
|
if (str.endsWith('+')) {
|
||||||
|
str.chop(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Qt::Key_Meta:
|
||||||
|
str = QKeySequence(Qt::MetaModifier).toString();
|
||||||
|
if (str.endsWith('+')) {
|
||||||
|
str.chop(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Qt::Key_Alt:
|
||||||
|
str = QKeySequence(Qt::AltModifier).toString();
|
||||||
|
if (str.endsWith('+')) {
|
||||||
|
str.chop(1);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
str = QKeySequence(k).toString();
|
||||||
|
}
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
} /* namespace qt */
|
} /* namespace qt */
|
||||||
} /* namespace desmume */
|
} /* namespace desmume */
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#define DESMUME_QT_KEYBOARDINPUT_H
|
#define DESMUME_QT_KEYBOARDINPUT_H
|
||||||
|
|
||||||
#include "ds_input.h"
|
#include "ds_input.h"
|
||||||
|
#include <QString>
|
||||||
|
|
||||||
namespace desmume {
|
namespace desmume {
|
||||||
namespace qt {
|
namespace qt {
|
||||||
|
@ -28,8 +29,14 @@ class KeyboardInput {
|
||||||
int mKeyAssignment[ds::KEY_COUNT];
|
int mKeyAssignment[ds::KEY_COUNT];
|
||||||
public:
|
public:
|
||||||
KeyboardInput();
|
KeyboardInput();
|
||||||
bool keyPress(int key);
|
int getAssignedKey(ds::KeysEnum key) const;
|
||||||
bool keyRelease(int key);
|
bool isKeyAssigned(int keyboardKey) const;
|
||||||
|
void setAssignedKey(ds::KeysEnum key, int keyboardKey);
|
||||||
|
bool keyPress(int keyboardKey);
|
||||||
|
bool keyRelease(int keyboardKey);
|
||||||
|
void from(const KeyboardInput& other);
|
||||||
|
|
||||||
|
static QString getKeyDisplayText(int key);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern KeyboardInput keyboard;
|
extern KeyboardInput keyboard;
|
||||||
|
|
|
@ -16,23 +16,208 @@
|
||||||
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "ds.h"
|
||||||
|
#include "keyboardinput.h"
|
||||||
|
|
||||||
#include "controlconfigdialog.h"
|
#include "controlconfigdialog.h"
|
||||||
#include "ui_controlconfigdialog.h"
|
#include "ui_controlconfigdialog.h"
|
||||||
#include <QDebug>
|
#include "controlitemconfigdialog.h"
|
||||||
|
|
||||||
namespace desmume {
|
namespace desmume {
|
||||||
namespace qt {
|
namespace qt {
|
||||||
|
|
||||||
ControlConfigDialog::ControlConfigDialog(QWidget *parent) :
|
ControlConfigDialog::ControlConfigDialog(QWidget* parent)
|
||||||
QDialog(parent),
|
: QDialog(parent)
|
||||||
ui(new Ui::ControlConfigDialog)
|
, ui(new Ui::ControlConfigDialog)
|
||||||
|
, mKeyboard(keyboard)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
this->updateButtonText();
|
||||||
}
|
}
|
||||||
|
|
||||||
ControlConfigDialog::~ControlConfigDialog() {
|
ControlConfigDialog::~ControlConfigDialog() {
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
} /* namespace qt */
|
void ControlConfigDialog::updateButtonText() {
|
||||||
|
ui->buttonControlA->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_A)));
|
||||||
|
ui->buttonControlB->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_B)));
|
||||||
|
ui->buttonControlX->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_X)));
|
||||||
|
ui->buttonControlY->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_Y)));
|
||||||
|
ui->buttonControlUp->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_UP)));
|
||||||
|
ui->buttonControlDown->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_DOWN)));
|
||||||
|
ui->buttonControlLeft->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_LEFT)));
|
||||||
|
ui->buttonControlRight->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_RIGHT)));
|
||||||
|
ui->buttonControlL->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_L)));
|
||||||
|
ui->buttonControlR->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_R)));
|
||||||
|
ui->buttonControlStart->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_START)));
|
||||||
|
ui->buttonControlSelect->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_SELECT)));
|
||||||
|
ui->buttonControlLid->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_LID)));
|
||||||
|
ui->buttonControlDebug->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_DEBUG)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlUp_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_UP, key);
|
||||||
|
ui->buttonControlUp->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_UP)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlDown_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_DOWN, key);
|
||||||
|
ui->buttonControlDown->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_DOWN)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlLeft_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_LEFT, key);
|
||||||
|
ui->buttonControlLeft->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_LEFT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlRight_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_RIGHT, key);
|
||||||
|
ui->buttonControlRight->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_RIGHT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlA_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_A, key);
|
||||||
|
ui->buttonControlA->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_A)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlB_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_B, key);
|
||||||
|
ui->buttonControlB->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_B)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlX_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_X, key);
|
||||||
|
ui->buttonControlX->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_X)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlY_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_Y, key);
|
||||||
|
ui->buttonControlY->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_Y)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlL_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_L, key);
|
||||||
|
ui->buttonControlL->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_L)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlR_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_R, key);
|
||||||
|
ui->buttonControlR->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_R)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlStart_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_START, key);
|
||||||
|
ui->buttonControlStart->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_START)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlSelect_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_SELECT, key);
|
||||||
|
ui->buttonControlSelect->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_SELECT)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlLid_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_LID, key);
|
||||||
|
ui->buttonControlLid->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_LID)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonControlDebug_clicked() {
|
||||||
|
ControlItemConfigDialog dlg;
|
||||||
|
int res = dlg.exec();
|
||||||
|
if (res == QDialog::Accepted) {
|
||||||
|
int key = dlg.key();
|
||||||
|
mKeyboard.setAssignedKey(ds::KEY_DEBUG, key);
|
||||||
|
ui->buttonControlDebug->setText(KeyboardInput::getKeyDisplayText(mKeyboard.getAssignedKey(ds::KEY_DEBUG)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonBox_accepted() {
|
||||||
|
keyboard.from(mKeyboard);
|
||||||
|
this->accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonBox_rejected() {
|
||||||
|
this->reject();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlConfigDialog::on_buttonBox_clicked(QAbstractButton* button) {
|
||||||
|
switch (ui->buttonBox->buttonRole(button)) {
|
||||||
|
case QDialogButtonBox::DestructiveRole:
|
||||||
|
this->reject();
|
||||||
|
break;
|
||||||
|
case QDialogButtonBox::ResetRole:
|
||||||
|
mKeyboard.from(KeyboardInput());
|
||||||
|
this->updateButtonText();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace ui */
|
||||||
} /* namespace desmume */
|
} /* namespace desmume */
|
||||||
|
|
|
@ -19,7 +19,10 @@
|
||||||
#ifndef DESMUME_QT_CONTROLCONFIGDIALOG_H
|
#ifndef DESMUME_QT_CONTROLCONFIGDIALOG_H
|
||||||
#define DESMUME_QT_CONTROLCONFIGDIALOG_H
|
#define DESMUME_QT_CONTROLCONFIGDIALOG_H
|
||||||
|
|
||||||
|
#include "keyboardinput.h"
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QAbstractButton>
|
||||||
|
|
||||||
namespace desmume {
|
namespace desmume {
|
||||||
namespace qt {
|
namespace qt {
|
||||||
|
@ -30,15 +33,33 @@ class ControlConfigDialog;
|
||||||
|
|
||||||
class ControlConfigDialog : public QDialog {
|
class ControlConfigDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
KeyboardInput mKeyboard;
|
||||||
|
void updateButtonText();
|
||||||
public:
|
public:
|
||||||
explicit ControlConfigDialog(QWidget* parent = 0);
|
explicit ControlConfigDialog(QWidget* parent = 0);
|
||||||
~ControlConfigDialog();
|
~ControlConfigDialog();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void on_buttonControlUp_clicked();
|
||||||
|
void on_buttonControlDown_clicked();
|
||||||
|
void on_buttonControlLeft_clicked();
|
||||||
|
void on_buttonControlRight_clicked();
|
||||||
|
void on_buttonControlA_clicked();
|
||||||
|
void on_buttonControlB_clicked();
|
||||||
|
void on_buttonControlX_clicked();
|
||||||
|
void on_buttonControlY_clicked();
|
||||||
|
void on_buttonControlL_clicked();
|
||||||
|
void on_buttonControlR_clicked();
|
||||||
|
void on_buttonControlStart_clicked();
|
||||||
|
void on_buttonControlSelect_clicked();
|
||||||
|
void on_buttonControlLid_clicked();
|
||||||
|
void on_buttonControlDebug_clicked();
|
||||||
|
void on_buttonBox_accepted();
|
||||||
|
void on_buttonBox_rejected();
|
||||||
|
void on_buttonBox_clicked(QAbstractButton* button);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::ControlConfigDialog* ui;
|
Ui::ControlConfigDialog* ui;
|
||||||
|
|
||||||
private slots:
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,63 +6,207 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>450</width>
|
||||||
<height>300</height>
|
<height>323</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Configure Controls</string>
|
<string>Configure Controls</string>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<property name="geometry">
|
<item>
|
||||||
<rect>
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<x>290</x>
|
<property name="currentIndex">
|
||||||
<y>20</y>
|
<number>0</number>
|
||||||
<width>81</width>
|
|
||||||
<height>241</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
</property>
|
||||||
|
<widget class="QWidget" name="tabDS">
|
||||||
|
<attribute name="title">
|
||||||
|
<string>DS Buttons</string>
|
||||||
|
</attribute>
|
||||||
|
<layout class="QGridLayout" name="gridLayout" rowstretch="0,0,0,0,0,0,0,0,1" columnstretch="0,1,0,0,1" columnminimumwidth="0,0,6,0,0">
|
||||||
|
<item row="4" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonControlA">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="4">
|
||||||
|
<widget class="QPushButton" name="buttonControlLid">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="4">
|
||||||
|
<widget class="QPushButton" name="buttonControlL">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>Left</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Up</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0">
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="text">
|
||||||
|
<string>A</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0">
|
||||||
|
<widget class="QLabel" name="label_7">
|
||||||
|
<property name="text">
|
||||||
|
<string>X</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="text">
|
||||||
|
<string>Down</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="0">
|
||||||
|
<widget class="QLabel" name="label_8">
|
||||||
|
<property name="text">
|
||||||
|
<string>Y</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="3">
|
||||||
|
<widget class="QLabel" name="label_14">
|
||||||
|
<property name="text">
|
||||||
|
<string>Debug</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="3">
|
||||||
|
<widget class="QLabel" name="label_12">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="label_4">
|
||||||
|
<property name="text">
|
||||||
|
<string>Right</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="3">
|
||||||
|
<widget class="QLabel" name="label_13">
|
||||||
|
<property name="text">
|
||||||
|
<string>Lid</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="3">
|
||||||
|
<widget class="QLabel" name="label_11">
|
||||||
|
<property name="text">
|
||||||
|
<string>Start</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonControlUp">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="0">
|
||||||
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="text">
|
||||||
|
<string>B</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<widget class="QLabel" name="label_9">
|
||||||
|
<property name="text">
|
||||||
|
<string>L</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="3">
|
||||||
|
<widget class="QLabel" name="label_10">
|
||||||
|
<property name="text">
|
||||||
|
<string>R</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonControlDown">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="4">
|
||||||
|
<widget class="QPushButton" name="buttonControlStart">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonControlLeft">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="4">
|
||||||
|
<widget class="QPushButton" name="buttonControlR">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonControlRight">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="7" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonControlY">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonControlB">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="1">
|
||||||
|
<widget class="QPushButton" name="buttonControlX">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="5" column="4">
|
||||||
|
<widget class="QPushButton" name="buttonControlDebug">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="4">
|
||||||
|
<widget class="QPushButton" name="buttonControlSelect">
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="8" column="1">
|
||||||
|
<spacer name="spacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>0</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Discard|QDialogButtonBox::RestoreDefaults|QDialogButtonBox::Save</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>desmume::qt::ControlConfigDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>desmume::qt::ControlConfigDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2014 DeSmuME team
|
||||||
|
Copyright (C) 2014 Alvin Wong
|
||||||
|
|
||||||
|
This file is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This file is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "keyboardinput.h"
|
||||||
|
|
||||||
|
#include "controlitemconfigdialog.h"
|
||||||
|
#include "ui_controlitemconfigdialog.h"
|
||||||
|
#include <QKeyEvent>
|
||||||
|
|
||||||
|
namespace desmume {
|
||||||
|
namespace qt {
|
||||||
|
|
||||||
|
ControlItemConfigDialog::ControlItemConfigDialog(QWidget* parent)
|
||||||
|
: QDialog(parent)
|
||||||
|
, ui(new Ui::ControlItemConfigDialog)
|
||||||
|
, mKey(0)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlItemConfigDialog::~ControlItemConfigDialog() {
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ControlItemConfigDialog::keyPressEvent(QKeyEvent* event) {
|
||||||
|
if (mKey == 0) {
|
||||||
|
this->mKey = event->key();
|
||||||
|
ui->label->setText(KeyboardInput::getKeyDisplayText(this->mKey));
|
||||||
|
ui->buttonBox->setEnabled(true);
|
||||||
|
} else {
|
||||||
|
QDialog::keyPressEvent(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int ControlItemConfigDialog::key() {
|
||||||
|
return this->mKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
} /* namespace qt */
|
||||||
|
} /* namespace desmume */
|
|
@ -0,0 +1,48 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2014 DeSmuME team
|
||||||
|
Copyright (C) 2014 Alvin Wong
|
||||||
|
|
||||||
|
This file is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 2 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This file is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with the this software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef DESMUME_QT_CONTROLITEMCONFIGDIALOG_H
|
||||||
|
#define DESMUME_QT_CONTROLITEMCONFIGDIALOG_H
|
||||||
|
|
||||||
|
#include <QDialog>
|
||||||
|
|
||||||
|
namespace desmume {
|
||||||
|
namespace qt {
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class ControlItemConfigDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
class ControlItemConfigDialog : public QDialog {
|
||||||
|
Q_OBJECT
|
||||||
|
int mKey;
|
||||||
|
protected:
|
||||||
|
void keyPressEvent(QKeyEvent* event);
|
||||||
|
public:
|
||||||
|
explicit ControlItemConfigDialog(QWidget *parent = 0);
|
||||||
|
~ControlItemConfigDialog();
|
||||||
|
int key();
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::ControlItemConfigDialog *ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} /* namespace qt */
|
||||||
|
} /* namespace desmume */
|
||||||
|
#endif /* DESMUME_QT_CONTROLITEMCONFIGDIALOG_H */
|
|
@ -0,0 +1,78 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>desmume::qt::ControlItemConfigDialog</class>
|
||||||
|
<widget class="QDialog" name="desmume::qt::ControlItemConfigDialog">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>Configure Control</string>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="text">
|
||||||
|
<string>Press a key...</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
<property name="centerButtons">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>accepted()</signal>
|
||||||
|
<receiver>desmume::qt::ControlItemConfigDialog</receiver>
|
||||||
|
<slot>accept()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>164</x>
|
||||||
|
<y>41</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>157</x>
|
||||||
|
<y>58</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>buttonBox</sender>
|
||||||
|
<signal>rejected()</signal>
|
||||||
|
<receiver>desmume::qt::ControlItemConfigDialog</receiver>
|
||||||
|
<slot>reject()</slot>
|
||||||
|
<hints>
|
||||||
|
<hint type="sourcelabel">
|
||||||
|
<x>164</x>
|
||||||
|
<y>47</y>
|
||||||
|
</hint>
|
||||||
|
<hint type="destinationlabel">
|
||||||
|
<x>173</x>
|
||||||
|
<y>58</y>
|
||||||
|
</hint>
|
||||||
|
</hints>
|
||||||
|
</connection>
|
||||||
|
</connections>
|
||||||
|
</ui>
|
|
@ -72,9 +72,6 @@
|
||||||
<addaction name="menuVideoFilter"/>
|
<addaction name="menuVideoFilter"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QMenu" name="menuConfig">
|
<widget class="QMenu" name="menuConfig">
|
||||||
<property name="enabled">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>&Config</string>
|
<string>&Config</string>
|
||||||
</property>
|
</property>
|
||||||
|
|
Loading…
Reference in New Issue