From 16fc02daafcfc36f7a91e4be68f5c63f96cba49d Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Mon, 22 Mar 2021 22:57:53 -0400 Subject: [PATCH] Advanced game pad button to key remapping in work. --- src/drivers/Qt/GamePadConf.cpp | 29 ++++++++++++++++++++++++----- src/drivers/Qt/GamePadConf.h | 8 +++++++- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/drivers/Qt/GamePadConf.cpp b/src/drivers/Qt/GamePadConf.cpp index 3137bcfb..b034ac7c 100644 --- a/src/drivers/Qt/GamePadConf.cpp +++ b/src/drivers/Qt/GamePadConf.cpp @@ -1561,7 +1561,7 @@ GamePadFuncConfigDialog::GamePadFuncConfigDialog( gamepad_function_key_t *fk, QW b[0] = new GamePadConfigButton_t(0); b[1] = new GamePadConfigButton_t(1); - hk = new GamePadConfigHotKey_t(); + hk = new GamePadConfigHotKey_t(k); clearButton[0] = new QPushButton( tr("Clear") ); clearButton[1] = new QPushButton( tr("Clear") ); @@ -1609,7 +1609,7 @@ GamePadFuncConfigDialog::GamePadFuncConfigDialog( gamepad_function_key_t *fk, QW connect( b[0], SIGNAL(clicked(void)), this, SLOT(changeButton0(void)) ); connect( b[1], SIGNAL(clicked(void)), this, SLOT(changeButton1(void)) ); - //connect( hk, SIGNAL(clicked(void)), this, SLOT(changeButton1(void)) ); + connect( hk, SIGNAL(clicked(void)), this, SLOT(changeKeySeq(void) ) ); } //---------------------------------------------------- GamePadFuncConfigDialog::~GamePadFuncConfigDialog(void) @@ -1707,20 +1707,39 @@ void GamePadFuncConfigDialog::changeButton1(void) changeButton(1); } //---------------------------------------------------- -GamePadConfigHotKey_t::GamePadConfigHotKey_t(void) +void GamePadFuncConfigDialog::changeKeySeq(void) +{ + hk->setCaptureState(true); + hk->setStyleSheet("background-color: green; color: white;"); +} +//---------------------------------------------------- +GamePadConfigHotKey_t::GamePadConfigHotKey_t(gamepad_function_key_t *fk) { setText("Change"); + + k = fk; + + captureState = false; } //---------------------------------------------------- void GamePadConfigHotKey_t::keyPressEvent(QKeyEvent *event) { - //printf("GamePad Button Key Press: 0x%x \n", event->key() ); + printf("GamePad Hot Key Press: 0x%x '%s'\n", event->key(), event->text().toStdString().c_str() ); //pushKeyEvent(event, 1); + + if ( captureState ) + { + k->qKey = event->key(); + k->qModifier = event->modifiers(); + } } void GamePadConfigHotKey_t::keyReleaseEvent(QKeyEvent *event) { - //printf("GamePad Button Key Release: 0x%x \n", event->key() ); + printf("GamePad Hot Key Release: 0x%x \n", event->key() ); //pushKeyEvent(event, 0); + + captureState = false; + setStyleSheet(NULL); } //---------------------------------------------------- diff --git a/src/drivers/Qt/GamePadConf.h b/src/drivers/Qt/GamePadConf.h index 0cb99216..eb52363e 100644 --- a/src/drivers/Qt/GamePadConf.h +++ b/src/drivers/Qt/GamePadConf.h @@ -36,11 +36,16 @@ protected: class GamePadConfigHotKey_t : public QPushButton { public: - GamePadConfigHotKey_t(void); + GamePadConfigHotKey_t( gamepad_function_key_t *k ); + + void setCaptureState(bool s){ captureState = s; }; protected: void keyPressEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event); + + gamepad_function_key_t *k; + bool captureState; }; class GamePadFuncConfigDialog : public QDialog @@ -73,6 +78,7 @@ private slots: void rejectCB(void); void changeButton0(void); void changeButton1(void); + void changeKeySeq(void); }; class GamePadView_t : public QWidget