mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-06-26 04:16:18 +00:00
Fixed formatting from clang-format
This commit is contained in:
parent
429c64a51b
commit
990e349424
4 changed files with 66 additions and 77 deletions
|
@ -223,25 +223,19 @@ void ParseInputConfig(const std::string game_id = "") {
|
|||
while (std::getline(file, line)) {
|
||||
lineCount++;
|
||||
|
||||
auto line_kpmask = (line.substr(0, 2) == "kp ") ? line.begin() + 2 : line.begin();
|
||||
|
||||
// Strip the ; and whitespace
|
||||
line.erase(std::remove_if(line_kpmask, line.end(),
|
||||
line.erase(std::remove_if(line.begin(), line.end(),
|
||||
[](unsigned char c) { return std::isspace(c); }),
|
||||
line.end());
|
||||
|
||||
if (line.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Truncate lines starting at #
|
||||
std::size_t comment_pos = line.find('#');
|
||||
if (comment_pos != std::string::npos) {
|
||||
line = line.substr(0, comment_pos);
|
||||
}
|
||||
// Remove trailing semicolon
|
||||
if (!line.empty() && std::distance(line_kpmask, line.end()) != 1 && line[line.length() - 1] == ';') {
|
||||
line = line.substr(0, line.length() - 1);
|
||||
}
|
||||
if (line.empty()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -256,14 +250,18 @@ void ParseInputConfig(const std::string game_id = "") {
|
|||
|
||||
std::string output_string = line.substr(0, equal_pos);
|
||||
std::string input_string = line.substr(equal_pos + 1);
|
||||
std::size_t comma_pos = input_string.find(',');
|
||||
// Remove trailing semicolon from input_string
|
||||
if (!input_string.empty() && input_string[input_string.length() - 1] == ';') {
|
||||
if (!(input_string == ";" || input_string == "kp;")) {
|
||||
line = line.substr(0, line.length() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
std::size_t comma_pos = input_string.find(',');
|
||||
auto parseInt = [](const std::string& s) -> std::optional<int> {
|
||||
int value = 0;
|
||||
auto [ptr, ec] = std::from_chars(s.data(), s.data() + s.size(), value);
|
||||
if (ec == std::errc()) {
|
||||
return value;
|
||||
} else {
|
||||
try {
|
||||
return std::stoi(s);
|
||||
} catch (...) {
|
||||
return std::nullopt;
|
||||
}
|
||||
};
|
||||
|
@ -377,7 +375,6 @@ void ParseInputConfig(const std::string game_id = "") {
|
|||
BindingConnection connection(InputID(), nullptr);
|
||||
auto button_it = string_to_cbutton_map.find(output_string);
|
||||
auto axis_it = string_to_axis_map.find(output_string);
|
||||
|
||||
if (binding.IsEmpty()) {
|
||||
LOG_WARNING(Input, "Invalid format at line: {}, data: \"{}\", skipping line.",
|
||||
lineCount, line);
|
||||
|
@ -444,11 +441,11 @@ InputEvent InputBinding::GetInputEventFromSDLEvent(const SDL_Event& e) {
|
|||
e.type == SDL_EVENT_MOUSE_WHEEL, 0);
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_DOWN:
|
||||
case SDL_EVENT_GAMEPAD_BUTTON_UP:
|
||||
return InputEvent(InputType::Controller, static_cast<u32>(e.gbutton.button),
|
||||
e.gbutton.down, 0);
|
||||
return InputEvent(InputType::Controller, static_cast<u32>(e.gbutton.button), e.gbutton.down,
|
||||
0); // clang made me do it
|
||||
case SDL_EVENT_GAMEPAD_AXIS_MOTION:
|
||||
return InputEvent(InputType::Axis, static_cast<u32>(e.gaxis.axis),
|
||||
true, e.gaxis.value / 256);
|
||||
return InputEvent(InputType::Axis, static_cast<u32>(e.gaxis.axis), true,
|
||||
e.gaxis.value / 256); // this too
|
||||
default:
|
||||
return InputEvent();
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@
|
|||
|
||||
#define KEY_TOGGLE 0x00200000
|
||||
|
||||
|
||||
#define SDL_INVALID_ID UINT32_MAX
|
||||
|
||||
namespace Input {
|
||||
|
@ -164,7 +163,7 @@ const std::map<std::string, u32> string_to_keyboard_key_map = {
|
|||
{"7", SDLK_7},
|
||||
{"8", SDLK_8},
|
||||
{"9", SDLK_9},
|
||||
|
||||
|
||||
// symbols
|
||||
{"`", SDLK_GRAVE},
|
||||
{"~", SDLK_TILDE},
|
||||
|
@ -229,7 +228,7 @@ const std::map<std::string, u32> string_to_keyboard_key_map = {
|
|||
{"down", SDLK_DOWN},
|
||||
{"left", SDLK_LEFT},
|
||||
{"right", SDLK_RIGHT},
|
||||
|
||||
|
||||
// keypad
|
||||
{"kp0", SDLK_KP_0},
|
||||
{"kp1", SDLK_KP_1},
|
||||
|
@ -241,14 +240,14 @@ const std::map<std::string, u32> string_to_keyboard_key_map = {
|
|||
{"kp7", SDLK_KP_7},
|
||||
{"kp8", SDLK_KP_8},
|
||||
{"kp9", SDLK_KP_9},
|
||||
{"kp .", SDLK_KP_PERIOD},
|
||||
{"kp ,", SDLK_KP_COMMA},
|
||||
{"kp /", SDLK_KP_DIVIDE},
|
||||
{"kp *", SDLK_KP_MULTIPLY},
|
||||
{"kp -", SDLK_KP_MINUS},
|
||||
{"kp +", SDLK_KP_PLUS},
|
||||
{"kp =", SDLK_KP_EQUALS},
|
||||
{"kp enter", SDLK_KP_ENTER},
|
||||
{"kp.", SDLK_KP_PERIOD},
|
||||
{"kp,", SDLK_KP_COMMA},
|
||||
{"kp/", SDLK_KP_DIVIDE},
|
||||
{"kp*", SDLK_KP_MULTIPLY},
|
||||
{"kp-", SDLK_KP_MINUS},
|
||||
{"kp+", SDLK_KP_PLUS},
|
||||
{"kp=", SDLK_KP_EQUALS},
|
||||
{"kpenter", SDLK_KP_ENTER},
|
||||
|
||||
// mouse
|
||||
{"leftbutton", SDL_BUTTON_LEFT},
|
||||
|
|
|
@ -168,14 +168,14 @@ void KBMSettings::SaveKBMConfig(bool close_on_save) {
|
|||
add_mapping(ui->CircleButton->text(), "circle");
|
||||
add_mapping(ui->TriangleButton->text(), "triangle");
|
||||
add_mapping(ui->SquareButton->text(), "square");
|
||||
|
||||
|
||||
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");
|
||||
|
@ -184,26 +184,26 @@ void KBMSettings::SaveKBMConfig(bool close_on_save) {
|
|||
add_mapping(ui->R2Button->text(), "r2");
|
||||
add_mapping(ui->L3Button->text(), "l3");
|
||||
add_mapping(ui->R3Button->text(), "r3");
|
||||
|
||||
|
||||
lines.push_back("");
|
||||
|
||||
add_mapping(ui->OptionsButton->text(), "options");
|
||||
add_mapping(ui->TouchpadButton->text(), "touchpad");
|
||||
|
||||
|
||||
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");
|
||||
|
@ -225,12 +225,6 @@ void KBMSettings::SaveKBMConfig(bool close_on_save) {
|
|||
while (std::getline(file, line)) {
|
||||
lineCount++;
|
||||
|
||||
// remove whitespace from the beginning of the line
|
||||
auto line_kpmask = (line.substr(0, 2) == "kp ") ? line.begin() + 2 : line.begin();
|
||||
line.erase(std::remove_if(line_kpmask, line.end(),
|
||||
[](unsigned char c) { return std::isspace(c); }),
|
||||
line.end());
|
||||
|
||||
if (line.empty()) {
|
||||
lines.push_back(line);
|
||||
continue;
|
||||
|
@ -293,10 +287,10 @@ void KBMSettings::SaveKBMConfig(bool close_on_save) {
|
|||
}
|
||||
|
||||
void KBMSettings::SetDefault() {
|
||||
ui->CrossButton->setText("kp 2");
|
||||
ui->CircleButton->setText("kp 6");
|
||||
ui->TriangleButton->setText("kp 8");
|
||||
ui->SquareButton->setText("kp 4");
|
||||
ui->CrossButton->setText("kp2");
|
||||
ui->CircleButton->setText("kp6");
|
||||
ui->TriangleButton->setText("kp8");
|
||||
ui->SquareButton->setText("kp4");
|
||||
|
||||
ui->L1Button->setText("q");
|
||||
ui->L2Button->setText("e");
|
||||
|
@ -354,7 +348,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") {
|
||||
|
@ -532,8 +525,8 @@ void KBMSettings::SetMapping(QString input) {
|
|||
}
|
||||
|
||||
// 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 {
|
||||
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 {
|
||||
|
@ -641,36 +634,36 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
pressedKeys.insert("z");
|
||||
break;
|
||||
case Qt::Key_0:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp 0", "0"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp0", "0"));
|
||||
break;
|
||||
case Qt::Key_1:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp 1", "1"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp1", "1"));
|
||||
break;
|
||||
case Qt::Key_2:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp 2", "2"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp2", "2"));
|
||||
break;
|
||||
case Qt::Key_3:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp 3", "3"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp3", "3"));
|
||||
break;
|
||||
case Qt::Key_4:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp 4", "4"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp4", "4"));
|
||||
break;
|
||||
case Qt::Key_5:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp 5", "5"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp5", "5"));
|
||||
break;
|
||||
case Qt::Key_6:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp 6", "6"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp6", "6"));
|
||||
break;
|
||||
case Qt::Key_7:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp 7", "7"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp7", "7"));
|
||||
break;
|
||||
case Qt::Key_8:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp 8", "8"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp8", "8"));
|
||||
break;
|
||||
case Qt::Key_9:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp 9", "9"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp9", "9"));
|
||||
break;
|
||||
|
||||
|
||||
// symbols
|
||||
case Qt::Key_Exclam:
|
||||
pressedKeys.insert("!");
|
||||
|
@ -694,7 +687,7 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
pressedKeys.insert("&");
|
||||
break;
|
||||
case Qt::Key_Asterisk:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp *", "*"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp*", "*"));
|
||||
break;
|
||||
case Qt::Key_ParenLeft:
|
||||
pressedKeys.insert("(");
|
||||
|
@ -703,16 +696,16 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
pressedKeys.insert(")");
|
||||
break;
|
||||
case Qt::Key_Minus:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp -", "-"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp-", "-"));
|
||||
break;
|
||||
case Qt::Key_Underscore:
|
||||
pressedKeys.insert("_");
|
||||
break;
|
||||
case Qt::Key_Equal:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp =", "="));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp=", "="));
|
||||
break;
|
||||
case Qt::Key_Plus:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp +", "+"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp+", "+"));
|
||||
break;
|
||||
case Qt::Key_BracketLeft:
|
||||
pressedKeys.insert("[");
|
||||
|
@ -745,24 +738,24 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
pressedKeys.insert("\"");
|
||||
break;
|
||||
case Qt::Key_Comma:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp ,", ","));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp,", ","));
|
||||
break;
|
||||
case Qt::Key_Less:
|
||||
pressedKeys.insert("<");
|
||||
break;
|
||||
case Qt::Key_Period:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp .", "."));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp.", "."));
|
||||
break;
|
||||
case Qt::Key_Greater:
|
||||
pressedKeys.insert(">");
|
||||
break;
|
||||
case Qt::Key_Slash:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp /", "/"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::KeypadModifier, "kp/", "/"));
|
||||
break;
|
||||
case Qt::Key_Question:
|
||||
pressedKeys.insert("question");
|
||||
break;
|
||||
|
||||
|
||||
// special keys
|
||||
case Qt::Key_Print:
|
||||
pressedKeys.insert("printscreen");
|
||||
|
@ -804,7 +797,7 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
pressedKeys.insert("enter");
|
||||
break;
|
||||
case Qt::Key_Enter:
|
||||
pressedKeys.insert(GetModifiedButton(Qt::ShiftModifier, "kp enter", "enter"));
|
||||
pressedKeys.insert(GetModifiedButton(Qt::ShiftModifier, "kpenter", "enter"));
|
||||
break;
|
||||
case Qt::Key_Shift:
|
||||
if (keyEvent->nativeScanCode() == LSHIFT_KEY) {
|
||||
|
@ -851,12 +844,12 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
case Qt::Key_Right:
|
||||
pressedKeys.insert("right");
|
||||
break;
|
||||
|
||||
|
||||
// cancel mapping
|
||||
case Qt::Key_Escape:
|
||||
pressedKeys.insert("unmapped");
|
||||
break;
|
||||
|
||||
|
||||
// default case
|
||||
default:
|
||||
break;
|
||||
|
@ -885,7 +878,7 @@ bool KBMSettings::eventFilter(QObject* obj, QEvent* event) {
|
|||
case Qt::XButton2:
|
||||
pressedKeys.insert("sidebuttonforward");
|
||||
break;
|
||||
|
||||
|
||||
// default case
|
||||
default:
|
||||
break;
|
||||
|
@ -920,16 +913,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
|
||||
pressedKeys.insert(GetModifiedButton(Qt::AltModifier,
|
||||
"mousewheelup", "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()) {
|
||||
pressedKeys.insert(GetModifiedButton(Qt::AltModifier,
|
||||
"mousewheeldown", "mousewheelleft"));
|
||||
pressedKeys.insert(
|
||||
GetModifiedButton(Qt::AltModifier, "mousewheeldown", "mousewheelleft"));
|
||||
} else {
|
||||
QMessageBox::information(this, tr("Cannot set mapping"),
|
||||
tr("Mousewheel cannot be mapped to stick outputs"));
|
||||
|
|
|
@ -155,7 +155,7 @@ Whitespace doesn't matter, <output>=<input>; is just as valid as <output> = <inp
|
|||
result += " 'l2'\n";
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
QString special() {
|
||||
return R"(
|
||||
There are some extra bindings you can put into the config file, that don't correspond to a controller input, but rather something else.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue