Qt: Fix some button binding bugs

This commit is contained in:
Jeffrey Pfau 2015-05-31 13:38:40 -07:00
parent 67e13114ef
commit 24b1fb7b30
2 changed files with 6 additions and 2 deletions

View File

@ -224,11 +224,11 @@ void ShortcutController::updateButton(const QModelIndex& index, int button) {
}
ShortcutItem* item = itemAt(index);
int oldButton = item->button();
item->setButton(button);
if (oldButton >= 0) {
m_buttons.take(oldButton);
}
updateAxis(index, -1, GamepadAxisEvent::NEUTRAL);
item->setButton(button);
if (button >= 0) {
m_buttons[button] = item;
}
@ -249,7 +249,6 @@ void ShortcutController::updateAxis(const QModelIndex& index, int axis, GamepadA
ShortcutItem* item = itemAt(index);
int oldAxis = item->axis();
GamepadAxisEvent::Direction oldDirection = item->direction();
item->setAxis(axis, direction);
if (oldAxis >= 0) {
m_axes.take(qMakePair(oldAxis, oldDirection));
}
@ -257,6 +256,7 @@ void ShortcutController::updateAxis(const QModelIndex& index, int axis, GamepadA
updateButton(index, -1);
m_axes[qMakePair(axis, direction)] = item;
}
item->setAxis(axis, direction);
if (m_config) {
char d = '\0';
if (direction == GamepadAxisEvent::POSITIVE) {

View File

@ -61,11 +61,15 @@ void ShortcutView::load(const QModelIndex& index) {
m_ui.gamepadButton->click();
}
if (m_ui.gamepadButton->isChecked()) {
bool blockSignals = m_ui.keyEdit->blockSignals(true);
m_ui.keyEdit->setFocus();
m_ui.keyEdit->setValueButton(-1); // There are no default bindings
m_ui.keyEdit->blockSignals(blockSignals);
} else {
bool blockSignals = m_ui.keySequenceEdit->blockSignals(true);
m_ui.keySequenceEdit->setFocus();
m_ui.keySequenceEdit->setKeySequence(sequence);
m_ui.keySequenceEdit->blockSignals(blockSignals);
}
}