Advanced game pad button to key remapping in work.

This commit is contained in:
mjbudd77 2021-03-22 22:57:53 -04:00
parent 96dfa954e1
commit 16fc02daaf
2 changed files with 31 additions and 6 deletions

View File

@ -1561,7 +1561,7 @@ GamePadFuncConfigDialog::GamePadFuncConfigDialog( gamepad_function_key_t *fk, QW
b[0] = new GamePadConfigButton_t(0); b[0] = new GamePadConfigButton_t(0);
b[1] = new GamePadConfigButton_t(1); b[1] = new GamePadConfigButton_t(1);
hk = new GamePadConfigHotKey_t(); hk = new GamePadConfigHotKey_t(k);
clearButton[0] = new QPushButton( tr("Clear") ); clearButton[0] = new QPushButton( tr("Clear") );
clearButton[1] = 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[0], SIGNAL(clicked(void)), this, SLOT(changeButton0(void)) );
connect( b[1], SIGNAL(clicked(void)), this, SLOT(changeButton1(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) GamePadFuncConfigDialog::~GamePadFuncConfigDialog(void)
@ -1707,20 +1707,39 @@ void GamePadFuncConfigDialog::changeButton1(void)
changeButton(1); 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"); setText("Change");
k = fk;
captureState = false;
} }
//---------------------------------------------------- //----------------------------------------------------
void GamePadConfigHotKey_t::keyPressEvent(QKeyEvent *event) 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); //pushKeyEvent(event, 1);
if ( captureState )
{
k->qKey = event->key();
k->qModifier = event->modifiers();
}
} }
void GamePadConfigHotKey_t::keyReleaseEvent(QKeyEvent *event) 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); //pushKeyEvent(event, 0);
captureState = false;
setStyleSheet(NULL);
} }
//---------------------------------------------------- //----------------------------------------------------

View File

@ -36,11 +36,16 @@ protected:
class GamePadConfigHotKey_t : public QPushButton class GamePadConfigHotKey_t : public QPushButton
{ {
public: public:
GamePadConfigHotKey_t(void); GamePadConfigHotKey_t( gamepad_function_key_t *k );
void setCaptureState(bool s){ captureState = s; };
protected: protected:
void keyPressEvent(QKeyEvent *event); void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event); void keyReleaseEvent(QKeyEvent *event);
gamepad_function_key_t *k;
bool captureState;
}; };
class GamePadFuncConfigDialog : public QDialog class GamePadFuncConfigDialog : public QDialog
@ -73,6 +78,7 @@ private slots:
void rejectCB(void); void rejectCB(void);
void changeButton0(void); void changeButton0(void);
void changeButton1(void); void changeButton1(void);
void changeKeySeq(void);
}; };
class GamePadView_t : public QWidget class GamePadView_t : public QWidget