Updated hot key to gamepad binding logic for Qt GUI.
This commit is contained in:
parent
f6f868671e
commit
49735af561
|
@ -1944,16 +1944,32 @@ void GamePadFuncConfigDialog::changeKeySeq0(void)
|
||||||
|
|
||||||
if ( ret == QDialog::Accepted )
|
if ( ret == QDialog::Accepted )
|
||||||
{
|
{
|
||||||
printf("Accepted Hot Key: %i\n", hkd.getSelHotKey() );
|
hotkey_t *hkp;
|
||||||
k->hk[0] = hkd.getSelHotKey();
|
char keyName[128];
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Rejected Hot Key\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
hk[0]->setCaptureState(true);
|
//printf("Accepted Hot Key: %i\n", hkd.getSelHotKey() );
|
||||||
hk[0]->setStyleSheet("background-color: green; color: white;");
|
k->hk[0] = hkd.getSelHotKey();
|
||||||
|
|
||||||
|
hkp = &Hotkeys[ k->hk[0] ];
|
||||||
|
|
||||||
|
hkp->getString(keyName);
|
||||||
|
|
||||||
|
k->keySeq[0].key = hkp->qkey.value;
|
||||||
|
k->keySeq[0].modifier = hkp->qkey.modifier;
|
||||||
|
k->keySeq[0].name.assign(hkp->getConfigName());
|
||||||
|
|
||||||
|
if ( keySeqLbl[0] )
|
||||||
|
{
|
||||||
|
keySeqLbl[0]->setText( tr(hkp->getConfigName()) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// printf("Rejected Hot Key\n");
|
||||||
|
//}
|
||||||
|
|
||||||
|
//hk[0]->setCaptureState(true);
|
||||||
|
//hk[0]->setStyleSheet("background-color: green; color: white;");
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void GamePadFuncConfigDialog::changeKeySeq1(void)
|
void GamePadFuncConfigDialog::changeKeySeq1(void)
|
||||||
|
@ -1965,16 +1981,32 @@ void GamePadFuncConfigDialog::changeKeySeq1(void)
|
||||||
|
|
||||||
if ( ret == QDialog::Accepted )
|
if ( ret == QDialog::Accepted )
|
||||||
{
|
{
|
||||||
printf("Accepted Hot Key: %i\n", hkd.getSelHotKey() );
|
hotkey_t *hkp;
|
||||||
k->hk[1] = hkd.getSelHotKey();
|
char keyName[128];
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("Rejected Hot Key\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
hk[1]->setCaptureState(true);
|
//printf("Accepted Hot Key: %i\n", hkd.getSelHotKey() );
|
||||||
hk[1]->setStyleSheet("background-color: green; color: white;");
|
k->hk[1] = hkd.getSelHotKey();
|
||||||
|
|
||||||
|
hkp = &Hotkeys[ k->hk[1] ];
|
||||||
|
|
||||||
|
hkp->getString(keyName);
|
||||||
|
|
||||||
|
k->keySeq[1].key = hkp->qkey.value;
|
||||||
|
k->keySeq[1].modifier = hkp->qkey.modifier;
|
||||||
|
k->keySeq[1].name.assign(keyName);
|
||||||
|
|
||||||
|
if ( keySeqLbl[1] )
|
||||||
|
{
|
||||||
|
keySeqLbl[1]->setText( tr(hkp->getConfigName()) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// printf("Rejected Hot Key\n");
|
||||||
|
//}
|
||||||
|
|
||||||
|
//hk[1]->setCaptureState(true);
|
||||||
|
//hk[1]->setStyleSheet("background-color: green; color: white;");
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
void GamePadFuncConfigDialog::clearButton0(void)
|
void GamePadFuncConfigDialog::clearButton0(void)
|
||||||
|
|
|
@ -200,6 +200,8 @@ hotkey_t::hotkey_t(void)
|
||||||
{
|
{
|
||||||
sdl.value = 0;
|
sdl.value = 0;
|
||||||
sdl.modifier = 0;
|
sdl.modifier = 0;
|
||||||
|
qkey.value = 0;
|
||||||
|
qkey.modifier = 0;
|
||||||
prevState = 0;
|
prevState = 0;
|
||||||
shortcut = nullptr;
|
shortcut = nullptr;
|
||||||
act = nullptr;
|
act = nullptr;
|
||||||
|
@ -253,6 +255,9 @@ void hotkey_t::conv2SDL(void)
|
||||||
if (shortcut == nullptr)
|
if (shortcut == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
qkey.value = (Qt::Key)(shortcut->key()[0] & 0x01FFFFFF);
|
||||||
|
qkey.modifier = (Qt::KeyboardModifier)(shortcut->key()[0] & 0xFE000000);
|
||||||
|
|
||||||
SDL_Keycode k = convQtKey2SDLKeyCode((Qt::Key)(shortcut->key()[0] & 0x01FFFFFF));
|
SDL_Keycode k = convQtKey2SDLKeyCode((Qt::Key)(shortcut->key()[0] & 0x01FFFFFF));
|
||||||
SDL_Keymod m = convQtKey2SDLModifier((Qt::KeyboardModifier)(shortcut->key()[0] & 0xFE000000));
|
SDL_Keymod m = convQtKey2SDLModifier((Qt::KeyboardModifier)(shortcut->key()[0] & 0xFE000000));
|
||||||
|
|
||||||
|
@ -477,7 +482,7 @@ void gamepad_function_key_t::sendKeyPressEvent(int idx)
|
||||||
{
|
{
|
||||||
QShortcut *s = Hotkeys[ hk[idx] ].getShortcut();
|
QShortcut *s = Hotkeys[ hk[idx] ].getShortcut();
|
||||||
|
|
||||||
if ( s )
|
if ( s && s->isEnabled() )
|
||||||
{
|
{
|
||||||
emit s->activated();
|
emit s->activated();
|
||||||
hasShortcut = true;
|
hasShortcut = true;
|
||||||
|
|
|
@ -61,6 +61,8 @@ class hotkey_t
|
||||||
const char *getConfigName(void);
|
const char *getConfigName(void);
|
||||||
QShortcut *getShortcut(void);
|
QShortcut *getShortcut(void);
|
||||||
|
|
||||||
|
QKeySequence getKeySeq(void){ return keySeq; };
|
||||||
|
|
||||||
// Member variables
|
// Member variables
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
@ -68,6 +70,12 @@ class hotkey_t
|
||||||
int modifier;
|
int modifier;
|
||||||
} sdl;
|
} sdl;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
int value;
|
||||||
|
int modifier;
|
||||||
|
} qkey;
|
||||||
|
|
||||||
char prevState;
|
char prevState;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue