mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-13 13:15:59 +00:00
KBM Input Bug Fixes / Added Binds v2 (#3109)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / linux-sdl-gcc (push) Blocked by required conditions
Build and Release / linux-qt-gcc (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions
* fixed nonload issues with background music (#3094)
* Fixing my pull request branch
* Pull request change part 2
* Continued changes to project and altered kbm_help_dialog.h text to QStringLiterals
* Finalized commit and changed kbm_help_dialog.h
* KBM Input Bug Fixes / Added Binds
Fixed input issues where some inputs would not bind when pressing (side mouse buttons, some symbols, etc). Also, fixed up code formatting in altered files (removed C-style casts and replaced with C++ <static_casts>, added a few macros and one member functions).
This is v2 of my commit, addressing all issues brought up by @kalaposfos
* Updated C-style casts in kbm_gui.cpp
* Fixed formatting from clang-format
* Updated expendable sections location and changed order of appearance
* Merged PR #3098 into kbm_gui.cpp
* Updates from running clang-format
* Potential MacOS error fix
Changes std::string to std::string_view, which prevented MacOS from building
* Undid MacOS commit for new PR
* Revert "Undid MacOS commit for new PR"
This reverts commit fc376c5e1f
.
* Updated SDL_INVALID_ID=UINT32_MAX macro to SDL_UNMAPPED=UINT32_MAX-1
* Update from merge conflicts
Updated SDL_INVALID_ID=UINT32_MAX macro to SDL_UNMAPPED=UINT32_MAX-1
* FIxed memory.cpp errors from testing PR #3117 (MacOS fixes)
* Removed "kp;"
* Fixed help dialogue from kalaposfos' changes
Fixed 3 edits made by kalaposfos from a recent commit.
---------
Co-authored-by: georgemoralis <giorgosmrls@gmail.com>
This commit is contained in:
parent
7b0249d9ca
commit
8dcd9cc0f9
6 changed files with 585 additions and 630 deletions
|
@ -164,198 +164,73 @@ void KBMSettings::EnableMappingButtons() {
|
|||
}
|
||||
}
|
||||
|
||||
void KBMSettings::SaveKBMConfig(bool CloseOnSave) {
|
||||
void KBMSettings::SaveKBMConfig(bool close_on_save) {
|
||||
std::string output_string = "", input_string = "";
|
||||
std::vector<std::string> lines, inputs;
|
||||
|
||||
// Comment lines for config file
|
||||
lines.push_back("#Feeling lost? Check out the Help section!");
|
||||
lines.push_back("");
|
||||
lines.push_back("#Keyboard bindings");
|
||||
lines.push_back("");
|
||||
|
||||
input_string = ui->CrossButton->text().toStdString();
|
||||
output_string = "cross";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->CircleButton->text().toStdString();
|
||||
output_string = "circle";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->TriangleButton->text().toStdString();
|
||||
output_string = "triangle";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->SquareButton->text().toStdString();
|
||||
output_string = "square";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
input_string = ui->DpadUpButton->text().toStdString();
|
||||
output_string = "pad_up";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->DpadDownButton->text().toStdString();
|
||||
output_string = "pad_down";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->DpadLeftButton->text().toStdString();
|
||||
output_string = "pad_left";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->DpadRightButton->text().toStdString();
|
||||
output_string = "pad_right";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
input_string = ui->L1Button->text().toStdString();
|
||||
output_string = "l1";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->R1Button->text().toStdString();
|
||||
output_string = "r1";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->L2Button->text().toStdString();
|
||||
output_string = "l2";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->R2Button->text().toStdString();
|
||||
output_string = "r2";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->L3Button->text().toStdString();
|
||||
output_string = "l3";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->R3Button->text().toStdString();
|
||||
output_string = "r3";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
input_string = ui->OptionsButton->text().toStdString();
|
||||
output_string = "options";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->TouchpadLeftButton->text().toStdString();
|
||||
output_string = "touchpad_left";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->TouchpadCenterButton->text().toStdString();
|
||||
output_string = "touchpad_center";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->TouchpadRightButton->text().toStdString();
|
||||
output_string = "touchpad_right";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
lines.push_back("");
|
||||
|
||||
input_string = ui->LStickUpButton->text().toStdString();
|
||||
output_string = "axis_left_y_minus";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->LStickDownButton->text().toStdString();
|
||||
output_string = "axis_left_y_plus";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->LStickLeftButton->text().toStdString();
|
||||
output_string = "axis_left_x_minus";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->LStickRightButton->text().toStdString();
|
||||
output_string = "axis_left_x_plus";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
input_string = ui->RStickUpButton->text().toStdString();
|
||||
output_string = "axis_right_y_minus";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->RStickDownButton->text().toStdString();
|
||||
output_string = "axis_right_y_plus";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->RStickLeftButton->text().toStdString();
|
||||
output_string = "axis_right_x_minus";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
input_string = ui->RStickRightButton->text().toStdString();
|
||||
output_string = "axis_right_x_plus";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
input_string = ui->MouseJoystickBox->currentText().toStdString();
|
||||
output_string = "mouse_to_joystick";
|
||||
if (input_string != "unmapped")
|
||||
// Lambda to reduce repetitive code for mapping buttons to config lines
|
||||
auto add_mapping = [&](const QString& buttonText, const std::string& output_name) {
|
||||
input_string = buttonText.toStdString();
|
||||
output_string = output_name;
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped") {
|
||||
inputs.push_back(input_string);
|
||||
}
|
||||
};
|
||||
|
||||
input_string = ui->LHalfButton->text().toStdString();
|
||||
output_string = "leftjoystick_halfmode";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
add_mapping(ui->CrossButton->text(), "cross");
|
||||
add_mapping(ui->CircleButton->text(), "circle");
|
||||
add_mapping(ui->TriangleButton->text(), "triangle");
|
||||
add_mapping(ui->SquareButton->text(), "square");
|
||||
|
||||
input_string = ui->RHalfButton->text().toStdString();
|
||||
output_string = "rightjoystick_halfmode";
|
||||
lines.push_back(output_string + " = " + input_string);
|
||||
if (input_string != "unmapped")
|
||||
inputs.push_back(input_string);
|
||||
lines.push_back("");
|
||||
|
||||
add_mapping(ui->DpadUpButton->text(), "pad_up");
|
||||
add_mapping(ui->DpadDownButton->text(), "pad_down");
|
||||
add_mapping(ui->DpadLeftButton->text(), "pad_left");
|
||||
add_mapping(ui->DpadRightButton->text(), "pad_right");
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
add_mapping(ui->L1Button->text(), "l1");
|
||||
add_mapping(ui->R1Button->text(), "r1");
|
||||
add_mapping(ui->L2Button->text(), "l2");
|
||||
add_mapping(ui->R2Button->text(), "r2");
|
||||
add_mapping(ui->L3Button->text(), "l3");
|
||||
add_mapping(ui->R3Button->text(), "r3");
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
add_mapping(ui->TouchpadLeftButton->text(), "touchpad_left");
|
||||
add_mapping(ui->TouchpadCenterButton->text(), "touchpad_center");
|
||||
add_mapping(ui->TouchpadRightButton->text(), "touchpad_right");
|
||||
add_mapping(ui->OptionsButton->text(), "options");
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
add_mapping(ui->LStickUpButton->text(), "axis_left_y_minus");
|
||||
add_mapping(ui->LStickDownButton->text(), "axis_left_y_plus");
|
||||
add_mapping(ui->LStickLeftButton->text(), "axis_left_x_minus");
|
||||
add_mapping(ui->LStickRightButton->text(), "axis_left_x_plus");
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
add_mapping(ui->RStickUpButton->text(), "axis_right_y_minus");
|
||||
add_mapping(ui->RStickDownButton->text(), "axis_right_y_plus");
|
||||
add_mapping(ui->RStickLeftButton->text(), "axis_right_x_minus");
|
||||
add_mapping(ui->RStickRightButton->text(), "axis_right_x_plus");
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
add_mapping(ui->MouseJoystickBox->currentText(), "mouse_to_joystick");
|
||||
add_mapping(ui->LHalfButton->text(), "leftjoystick_halfmode");
|
||||
add_mapping(ui->RHalfButton->text(), "rightjoystick_halfmode");
|
||||
|
||||
std::string DOString = std::format("{:.2f}", (ui->DeadzoneOffsetSlider->value() / 100.f));
|
||||
std::string SMString = std::format("{:.1f}", (ui->SpeedMultiplierSlider->value() / 10.f));
|
||||
|
@ -405,6 +280,7 @@ void KBMSettings::SaveKBMConfig(bool CloseOnSave) {
|
|||
// Prevent duplicate inputs for KBM as this breaks the engine
|
||||
bool duplicateFound = false;
|
||||
QSet<QString> duplicateMappings;
|
||||
|
||||
for (auto it = inputs.begin(); it != inputs.end(); ++it) {
|
||||
if (std::find(it + 1, inputs.end(), *it) != inputs.end()) {
|
||||
duplicateFound = true;
|
||||
|
@ -446,7 +322,7 @@ QString(tr("Cannot bind any unique input more than once. Duplicate inputs mapped
|
|||
Config::SetUseUnifiedInputConfig(!ui->PerGameCheckBox->isChecked());
|
||||
Config::save(Common::FS::GetUserPath(Common::FS::PathType::UserDir) / "config.toml");
|
||||
|
||||
if (CloseOnSave)
|
||||
if (close_on_save)
|
||||
QWidget::close();
|
||||
}
|
||||
|
||||
|
@ -514,7 +390,6 @@ void KBMSettings::SetUIValuestoMappings(std::string config_id) {
|
|||
|
||||
if (std::find(ControllerInputs.begin(), ControllerInputs.end(), input_string) ==
|
||||
ControllerInputs.end()) {
|
||||
|
||||
if (output_string == "cross") {
|
||||
ui->CrossButton->setText(QString::fromStdString(input_string));
|
||||
} else if (output_string == "circle") {
|
||||
|
@ -578,7 +453,7 @@ void KBMSettings::SetUIValuestoMappings(std::string config_id) {
|
|||
if (comma_pos != std::string::npos) {
|
||||
std::string DOstring = line.substr(equal_pos + 1, comma_pos);
|
||||
float DOffsetValue = std::stof(DOstring) * 100.0;
|
||||
int DOffsetInt = int(DOffsetValue);
|
||||
int DOffsetInt = static_cast<int>(DOffsetValue);
|
||||
ui->DeadzoneOffsetSlider->setValue(DOffsetInt);
|
||||
QString LabelValue = QString::number(DOffsetInt / 100.0, 'f', 2);
|
||||
QString LabelString = tr("Deadzone Offset (def 0.50):") + " " + LabelValue;
|
||||
|
@ -588,12 +463,8 @@ void KBMSettings::SetUIValuestoMappings(std::string config_id) {
|
|||
std::size_t comma_pos2 = SMSOstring.find(',');
|
||||
if (comma_pos2 != std::string::npos) {
|
||||
std::string SMstring = SMSOstring.substr(0, comma_pos2);
|
||||
float SpeedMultValue = std::stof(SMstring) * 10.0;
|
||||
int SpeedMultInt = int(SpeedMultValue);
|
||||
if (SpeedMultInt < 1)
|
||||
SpeedMultInt = 1;
|
||||
if (SpeedMultInt > 50)
|
||||
SpeedMultInt = 50;
|
||||
float SpeedMultValue = std::clamp(std::stof(SMstring) * 10.0f, 1.0f, 50.0f);
|
||||
int SpeedMultInt = static_cast<int>(SpeedMultValue);
|
||||
ui->SpeedMultiplierSlider->setValue(SpeedMultInt);
|
||||
LabelValue = QString::number(SpeedMultInt / 10.0, 'f', 1);
|
||||
LabelString = tr("Speed Multiplier (def 1.0):") + " " + LabelValue;
|
||||
|
@ -601,7 +472,7 @@ void KBMSettings::SetUIValuestoMappings(std::string config_id) {
|
|||
|
||||
std::string SOstring = SMSOstring.substr(comma_pos2 + 1);
|
||||
float SOffsetValue = std::stof(SOstring) * 1000.0;
|
||||
int SOffsetInt = int(SOffsetValue);
|
||||
int SOffsetInt = static_cast<int>(SOffsetValue);
|
||||
ui->SpeedOffsetSlider->setValue(SOffsetInt);
|
||||
LabelValue = QString::number(SOffsetInt / 1000.0, 'f', 3);
|
||||
LabelString = tr("Speed Offset (def 0.125):") + " " + LabelValue;
|
||||
|
@ -699,6 +570,16 @@ void KBMSettings::SetMapping(QString input) {
|
|||
MappingCompleted = true;
|
||||
}
|
||||
|
||||
// Helper lambda to get the modified button text based on the current keyboard modifiers
|
||||
auto GetModifiedButton = [](Qt::KeyboardModifiers modifier, const std::string& m_button,
|
||||
const std::string& n_button) -> QString {
|
||||
if (QApplication::keyboardModifiers() & modifier) {
|
||||
return QString::fromStdString(m_button);
|
||||
} else {
|
||||
return QString::fromStdString(n_button);
|
||||
}
|
||||
};
|
||||
|
||||
bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
||||
if (event->type() == QEvent::Close) {
|
||||
if (HelpWindowOpen) {
|
||||
|
@ -719,213 +600,7 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
}
|
||||
|
||||
switch (keyEvent->key()) {
|
||||
case Qt::Key_Space:
|
||||
pressedKeys.insert("space");
|
||||
break;
|
||||
case Qt::Key_Comma:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kpcomma");
|
||||
} else {
|
||||
pressedKeys.insert("comma");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Period:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kpperiod");
|
||||
} else {
|
||||
pressedKeys.insert("period");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Slash:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers())
|
||||
pressedKeys.insert("kpdivide");
|
||||
break;
|
||||
case Qt::Key_Asterisk:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers())
|
||||
pressedKeys.insert("kpmultiply");
|
||||
break;
|
||||
case Qt::Key_Question:
|
||||
pressedKeys.insert("question");
|
||||
break;
|
||||
case Qt::Key_Semicolon:
|
||||
pressedKeys.insert("semicolon");
|
||||
break;
|
||||
case Qt::Key_Minus:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kpminus");
|
||||
} else {
|
||||
pressedKeys.insert("minus");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Plus:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kpplus");
|
||||
} else {
|
||||
pressedKeys.insert("plus");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_ParenLeft:
|
||||
pressedKeys.insert("lparenthesis");
|
||||
break;
|
||||
case Qt::Key_ParenRight:
|
||||
pressedKeys.insert("rparenthesis");
|
||||
break;
|
||||
case Qt::Key_BracketLeft:
|
||||
pressedKeys.insert("lbracket");
|
||||
break;
|
||||
case Qt::Key_BracketRight:
|
||||
pressedKeys.insert("rbracket");
|
||||
break;
|
||||
case Qt::Key_BraceLeft:
|
||||
pressedKeys.insert("lbrace");
|
||||
break;
|
||||
case Qt::Key_BraceRight:
|
||||
pressedKeys.insert("rbrace");
|
||||
break;
|
||||
case Qt::Key_Backslash:
|
||||
pressedKeys.insert("backslash");
|
||||
break;
|
||||
case Qt::Key_Tab:
|
||||
pressedKeys.insert("tab");
|
||||
break;
|
||||
case Qt::Key_Backspace:
|
||||
pressedKeys.insert("backspace");
|
||||
break;
|
||||
case Qt::Key_Return:
|
||||
pressedKeys.insert("enter");
|
||||
break;
|
||||
case Qt::Key_Enter:
|
||||
pressedKeys.insert("kpenter");
|
||||
break;
|
||||
case Qt::Key_Home:
|
||||
pressedKeys.insert("home");
|
||||
break;
|
||||
case Qt::Key_End:
|
||||
pressedKeys.insert("end");
|
||||
break;
|
||||
case Qt::Key_PageDown:
|
||||
pressedKeys.insert("pgdown");
|
||||
break;
|
||||
case Qt::Key_PageUp:
|
||||
pressedKeys.insert("pgup");
|
||||
break;
|
||||
case Qt::Key_CapsLock:
|
||||
pressedKeys.insert("capslock");
|
||||
break;
|
||||
case Qt::Key_Escape:
|
||||
pressedKeys.insert("unmapped");
|
||||
break;
|
||||
case Qt::Key_Shift:
|
||||
if (keyEvent->nativeScanCode() == rshift) {
|
||||
pressedKeys.insert("rshift");
|
||||
} else {
|
||||
pressedKeys.insert("lshift");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Alt:
|
||||
if (keyEvent->nativeScanCode() == ralt) {
|
||||
pressedKeys.insert("ralt");
|
||||
} else {
|
||||
pressedKeys.insert("lalt");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Control:
|
||||
if (keyEvent->nativeScanCode() == rctrl) {
|
||||
pressedKeys.insert("rctrl");
|
||||
} else {
|
||||
pressedKeys.insert("lctrl");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Meta:
|
||||
activateWindow();
|
||||
#ifdef _WIN32
|
||||
pressedKeys.insert("lwin");
|
||||
#else
|
||||
pressedKeys.insert("lmeta");
|
||||
#endif
|
||||
case Qt::Key_1:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kp1");
|
||||
} else {
|
||||
pressedKeys.insert("1");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_2:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kp2");
|
||||
} else {
|
||||
pressedKeys.insert("2");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_3:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kp3");
|
||||
} else {
|
||||
pressedKeys.insert("3");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_4:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kp4");
|
||||
} else {
|
||||
pressedKeys.insert("4");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_5:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kp5");
|
||||
} else {
|
||||
pressedKeys.insert("5");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_6:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kp6");
|
||||
} else {
|
||||
pressedKeys.insert("6");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_7:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kp7");
|
||||
} else {
|
||||
pressedKeys.insert("7");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_8:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kp8");
|
||||
} else {
|
||||
pressedKeys.insert("8");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_9:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kp9");
|
||||
} else {
|
||||
pressedKeys.insert("9");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_0:
|
||||
if (Qt::KeypadModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("kp0");
|
||||
} else {
|
||||
pressedKeys.insert("0");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
activateWindow();
|
||||
pressedKeys.insert("up");
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
pressedKeys.insert("down");
|
||||
break;
|
||||
case Qt::Key_Left:
|
||||
pressedKeys.insert("left");
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
pressedKeys.insert("right");
|
||||
break;
|
||||
// alphanumeric
|
||||
case Qt::Key_A:
|
||||
pressedKeys.insert("a");
|
||||
break;
|
||||
|
@ -999,13 +674,232 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
pressedKeys.insert("x");
|
||||
break;
|
||||
case Qt::Key_Y:
|
||||
pressedKeys.insert("Y");
|
||||
pressedKeys.insert("y");
|
||||
break;
|
||||
case Qt::Key_Z:
|
||||
pressedKeys.insert("z");
|
||||
break;
|
||||
case Qt::Key_0:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp0", "0"));
|
||||
break;
|
||||
case Qt::Key_1:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp1", "1"));
|
||||
break;
|
||||
case Qt::Key_2:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp2", "2"));
|
||||
break;
|
||||
case Qt::Key_3:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp3", "3"));
|
||||
break;
|
||||
case Qt::Key_4:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp4", "4"));
|
||||
break;
|
||||
case Qt::Key_5:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp5", "5"));
|
||||
break;
|
||||
case Qt::Key_6:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp6", "6"));
|
||||
break;
|
||||
case Qt::Key_7:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp7", "7"));
|
||||
break;
|
||||
case Qt::Key_8:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp8", "8"));
|
||||
break;
|
||||
case Qt::Key_9:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp9", "9"));
|
||||
break;
|
||||
|
||||
// symbols
|
||||
case Qt::Key_Exclam:
|
||||
pressedKeys.insert("!");
|
||||
break;
|
||||
case Qt::Key_At:
|
||||
pressedKeys.insert("@");
|
||||
break;
|
||||
case Qt::Key_NumberSign:
|
||||
pressedKeys.insert("#");
|
||||
break;
|
||||
case Qt::Key_Dollar:
|
||||
pressedKeys.insert("$");
|
||||
break;
|
||||
case Qt::Key_Percent:
|
||||
pressedKeys.insert("%");
|
||||
break;
|
||||
case Qt::Key_AsciiCircum:
|
||||
pressedKeys.insert("^");
|
||||
break;
|
||||
case Qt::Key_Ampersand:
|
||||
pressedKeys.insert("&");
|
||||
break;
|
||||
case Qt::Key_Asterisk:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp*", "*"));
|
||||
break;
|
||||
case Qt::Key_ParenLeft:
|
||||
pressedKeys.insert("(");
|
||||
break;
|
||||
case Qt::Key_ParenRight:
|
||||
pressedKeys.insert(")");
|
||||
break;
|
||||
case Qt::Key_Minus:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp-", "-"));
|
||||
break;
|
||||
case Qt::Key_Underscore:
|
||||
pressedKeys.insert("_");
|
||||
break;
|
||||
case Qt::Key_Equal:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp=", "="));
|
||||
break;
|
||||
case Qt::Key_Plus:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp+", "+"));
|
||||
break;
|
||||
case Qt::Key_BracketLeft:
|
||||
pressedKeys.insert("[");
|
||||
break;
|
||||
case Qt::Key_BracketRight:
|
||||
pressedKeys.insert("]");
|
||||
break;
|
||||
case Qt::Key_BraceLeft:
|
||||
pressedKeys.insert("{");
|
||||
break;
|
||||
case Qt::Key_BraceRight:
|
||||
pressedKeys.insert("}");
|
||||
break;
|
||||
case Qt::Key_Backslash:
|
||||
pressedKeys.insert("\\");
|
||||
break;
|
||||
case Qt::Key_Bar:
|
||||
pressedKeys.insert("|");
|
||||
break;
|
||||
case Qt::Key_Semicolon:
|
||||
pressedKeys.insert(";");
|
||||
break;
|
||||
case Qt::Key_Colon:
|
||||
pressedKeys.insert(":");
|
||||
break;
|
||||
case Qt::Key_Apostrophe:
|
||||
pressedKeys.insert("'");
|
||||
break;
|
||||
case Qt::Key_QuoteDbl:
|
||||
pressedKeys.insert("\"");
|
||||
break;
|
||||
case Qt::Key_Comma:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp,", ","));
|
||||
break;
|
||||
case Qt::Key_Less:
|
||||
pressedKeys.insert("<");
|
||||
break;
|
||||
case Qt::Key_Period:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp.", "."));
|
||||
break;
|
||||
case Qt::Key_Greater:
|
||||
pressedKeys.insert(">");
|
||||
break;
|
||||
case Qt::Key_Slash:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp/", "/"));
|
||||
break;
|
||||
case Qt::Key_Question:
|
||||
pressedKeys.insert("question");
|
||||
break;
|
||||
|
||||
// special keys
|
||||
case Qt::Key_Print:
|
||||
pressedKeys.insert("printscreen");
|
||||
break;
|
||||
case Qt::Key_ScrollLock:
|
||||
pressedKeys.insert("scrolllock");
|
||||
break;
|
||||
case Qt::Key_Pause:
|
||||
pressedKeys.insert("pausebreak");
|
||||
break;
|
||||
case Qt::Key_Backspace:
|
||||
pressedKeys.insert("backspace");
|
||||
break;
|
||||
case Qt::Key_Insert:
|
||||
pressedKeys.insert("insert");
|
||||
break;
|
||||
case Qt::Key_Delete:
|
||||
pressedKeys.insert("delete");
|
||||
break;
|
||||
case Qt::Key_Home:
|
||||
pressedKeys.insert("home");
|
||||
break;
|
||||
case Qt::Key_End:
|
||||
pressedKeys.insert("end");
|
||||
break;
|
||||
case Qt::Key_PageUp:
|
||||
pressedKeys.insert("pgup");
|
||||
break;
|
||||
case Qt::Key_PageDown:
|
||||
pressedKeys.insert("pgdown");
|
||||
break;
|
||||
case Qt::Key_Tab:
|
||||
pressedKeys.insert("tab");
|
||||
break;
|
||||
case Qt::Key_CapsLock:
|
||||
pressedKeys.insert("capslock");
|
||||
break;
|
||||
case Qt::Key_Return:
|
||||
pressedKeys.insert("enter");
|
||||
break;
|
||||
case Qt::Key_Enter:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::ShiftModifier, "kpenter", "enter"));
|
||||
break;
|
||||
case Qt::Key_Shift:
|
||||
if (keyEvent->nativeScanCode() == LSHIFT_KEY) {
|
||||
pressedKeys.insert("lshift");
|
||||
} else {
|
||||
pressedKeys.insert("rshift");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Alt:
|
||||
if (keyEvent->nativeScanCode() == LALT_KEY) {
|
||||
pressedKeys.insert("lalt");
|
||||
} else {
|
||||
pressedKeys.insert("ralt");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Control:
|
||||
if (keyEvent->nativeScanCode() == LCTRL_KEY) {
|
||||
pressedKeys.insert("lctrl");
|
||||
} else {
|
||||
pressedKeys.insert("rctrl");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_Meta:
|
||||
activateWindow();
|
||||
#ifdef _WIN32
|
||||
pressedKeys.insert("lwin");
|
||||
#else
|
||||
pressedKeys.insert("lmeta");
|
||||
#endif
|
||||
break;
|
||||
case Qt::Key_Space:
|
||||
pressedKeys.insert("space");
|
||||
break;
|
||||
case Qt::Key_Up:
|
||||
activateWindow();
|
||||
pressedKeys.insert("up");
|
||||
break;
|
||||
case Qt::Key_Down:
|
||||
pressedKeys.insert("down");
|
||||
break;
|
||||
case Qt::Key_Left:
|
||||
pressedKeys.insert("left");
|
||||
break;
|
||||
case Qt::Key_Right:
|
||||
pressedKeys.insert("right");
|
||||
break;
|
||||
|
||||
// cancel mapping
|
||||
case Qt::Key_Escape:
|
||||
pressedKeys.insert("unmapped");
|
||||
break;
|
||||
|
||||
// default case
|
||||
default:
|
||||
break;
|
||||
// bottom text
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1024,8 +918,17 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
case Qt::MiddleButton:
|
||||
pressedKeys.insert("middlebutton");
|
||||
break;
|
||||
case Qt::XButton1:
|
||||
pressedKeys.insert("sidebuttonback");
|
||||
break;
|
||||
case Qt::XButton2:
|
||||
pressedKeys.insert("sidebuttonforward");
|
||||
break;
|
||||
|
||||
// default case
|
||||
default:
|
||||
break;
|
||||
// bottom text
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1056,22 +959,16 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
if (wheelEvent->angleDelta().x() > 5) {
|
||||
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) {
|
||||
// QT changes scrolling to horizontal for all widgets with the alt modifier
|
||||
if (Qt::AltModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("mousewheelup");
|
||||
} else {
|
||||
pressedKeys.insert("mousewheelright");
|
||||
}
|
||||
pressedKeys.insert(
|
||||
GetModifiedButton(Qt::AltModifier, "mousewheelup", "mousewheelright"));
|
||||
} else {
|
||||
QMessageBox::information(this, tr("Cannot set mapping"),
|
||||
tr("Mousewheel cannot be mapped to stick outputs"));
|
||||
}
|
||||
} else if (wheelEvent->angleDelta().x() < -5) {
|
||||
if (std::find(AxisList.begin(), AxisList.end(), MappingButton) == AxisList.end()) {
|
||||
if (Qt::AltModifier & QApplication::keyboardModifiers()) {
|
||||
pressedKeys.insert("mousewheeldown");
|
||||
} else {
|
||||
pressedKeys.insert("mousewheelleft");
|
||||
}
|
||||
pressedKeys.insert(
|
||||
GetModifiedButton(Qt::AltModifier, "mousewheeldown", "mousewheelleft"));
|
||||
} else {
|
||||
QMessageBox::information(this, tr("Cannot set mapping"),
|
||||
tr("Mousewheel cannot be mapped to stick outputs"));
|
||||
|
@ -1083,4 +980,4 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
return QDialog::eventFilter(obj, event);
|
||||
}
|
||||
|
||||
KBMSettings::~KBMSettings() {}
|
||||
KBMSettings::~KBMSettings() {}
|
Loading…
Add table
Add a link
Reference in a new issue