From edb9932d201e195a753d659aa1bac88f027b5ad2 Mon Sep 17 00:00:00 2001 From: kitswas <90329875+kitswas@users.noreply.github.com> Date: Sun, 24 Mar 2024 11:12:46 +0530 Subject: [PATCH] Formatted with clang format --- src/mainwindow.cpp | 3 +- src/networking/executor.cpp | 3 +- src/networking/server.cpp | 35 ++++++++------ src/preferences.cpp | 70 +++++++++++++++++----------- src/settings.cpp | 84 +++++++++++++++++++++------------- src/settings.hpp | 28 ++++++------ src/settings_key_variables.cpp | 25 +++++----- src/simulation/mouseSim.hpp | 3 +- 8 files changed, 151 insertions(+), 100 deletions(-) diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 594da05..d27eecd 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -12,7 +12,8 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi load_key_maps(); this->p = new Preferences(this); ui->setupUi(this); - QPushButton::connect(ui->settingsButton, &QPushButton::pressed, this, [this] { this->p->show(); }); + QPushButton::connect(ui->settingsButton, &QPushButton::pressed, this, + [this] { this->p->show(); }); QPushButton::connect(ui->startButton, &QPushButton::pressed, this, &MainWindow::launch_server); } diff --git a/src/networking/executor.cpp b/src/networking/executor.cpp index 94991f4..1c65cb5 100644 --- a/src/networking/executor.cpp +++ b/src/networking/executor.cpp @@ -88,7 +88,8 @@ bool inject_gamepad_state(vgp_data_exchange_gamepad_reading reading) } // Use the right thumbstick to move the mouse - // if (abs(reading.right_thumbstick_x) > THRESHOLD || abs(reading.right_thumbstick_y) > THRESHOLD) + // if (abs(reading.right_thumbstick_x) > THRESHOLD + // || abs(reading.right_thumbstick_y) > THRESHOLD) int offsetX = reading.right_thumbstick_x * mouse_sensitivity; int offsetY = reading.right_thumbstick_y * mouse_sensitivity; int scaleX = abs(offsetX) < (THRESHOLD * mouse_sensitivity) ? 0 : 1; diff --git a/src/networking/server.cpp b/src/networking/server.cpp index 98342bd..0dded5c 100644 --- a/src/networking/server.cpp +++ b/src/networking/server.cpp @@ -91,8 +91,8 @@ void Server::initServer() { ui->IPList->addItem(tr("%1").arg(entry.toString())); QLabel *QRWidget = new QLabel(); - QRWidget->setPixmap( - QPixmap::fromImage(createQR(tr("%1:%2").arg(entry.toString()).arg(tcpServer->serverPort())))); + QRWidget->setPixmap(QPixmap::fromImage( + createQR(tr("%1:%2").arg(entry.toString()).arg(tcpServer->serverPort())))); ui->QRViewer->addWidget(QRWidget); } } @@ -104,12 +104,13 @@ void Server::initServer() ui->IPList->setFocus(Qt::OtherFocusReason); } ui->statusLabel->setText(message); - connect(ui->IPList, &QListWidget::currentItemChanged, this, [this](QListWidgetItem *current, QListWidgetItem *) { - if (current != nullptr) - { - ui->QRViewer->setCurrentIndex(ui->IPList->row(current)); - } - }); + connect(ui->IPList, &QListWidget::currentItemChanged, this, + [this](QListWidgetItem *current, QListWidgetItem *) { + if (current != nullptr) + { + ui->QRViewer->setCurrentIndex(ui->IPList->row(current)); + } + }); connect(tcpServer, &QTcpServer::newConnection, this, &Server::handleConnection); } @@ -120,16 +121,21 @@ void Server::handleConnection() QString connectionMessage; connectionMessage = tr("Connected to %1 at `%2 : %3`") - .arg(clientConnection->peerName().isEmpty() ? "Unknown device" : clientConnection->peerName(), - clientConnection->peerAddress().toString(), QString::number(clientConnection->peerPort())); + .arg(clientConnection->peerName().isEmpty() ? "Unknown device" + : clientConnection->peerName(), + clientConnection->peerAddress().toString(), + QString::number(clientConnection->peerPort())); qDebug() << connectionMessage; ui->clientLabel->setText(connectionMessage); tcpServer->pauseAccepting(); - connect(clientConnection, &QAbstractSocket::disconnected, clientConnection, &QObject::deleteLater); - connect(clientConnection, &QAbstractSocket::disconnected, this, [this]() { tcpServer->resumeAccepting(); }); + connect(clientConnection, &QAbstractSocket::disconnected, clientConnection, + &QObject::deleteLater); + connect(clientConnection, &QAbstractSocket::disconnected, this, + [this]() { tcpServer->resumeAccepting(); }); connect(clientConnection, &QAbstractSocket::disconnected, this, [this]() { ui->clientLabel->setText(tr("No device connected")); }); - connect(clientConnection, &QAbstractSocket::disconnected, this, [this]() { isGamepadConnected = false; }); + connect(clientConnection, &QAbstractSocket::disconnected, this, + [this]() { isGamepadConnected = false; }); connect(clientConnection, &QAbstractSocket::readyRead, this, &Server::serveClient); } @@ -142,7 +148,8 @@ void Server::serveClient() // vgp_data_exchange_message_unmarshal(&message, request.constData(), request.size()); // qDebug() << "Message: " << message.contents.utf8; - vgp_data_exchange_gamepad_reading gamepad_reading = parse_gamepad_state(request.constData(), request.size()); + vgp_data_exchange_gamepad_reading gamepad_reading = + parse_gamepad_state(request.constData(), request.size()); qDebug() << "Reading (Btn down): " << gamepad_reading.buttons_down; qDebug() << "Reading (Btn up): " << gamepad_reading.buttons_up; qDebug() << "Reading (Left trigger): " << gamepad_reading.left_trigger; diff --git a/src/preferences.cpp b/src/preferences.cpp index c20c89f..76d6a40 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -14,15 +14,17 @@ Preferences::Preferences(QWidget *parent) : QDialog(parent), ui(new Ui::Preferen ui->setupUi(this); install_event_filter(); ui->horizontalSlider->adjustSize(); - ui->buttonBox->connect(ui->buttonBox, &QDialogButtonBox::accepted, this, - [this] { // running the functions to change and save the new settings if the user presses ok - this->change_mouse_sensitivity(ui->horizontalSlider->value() * 100); - qDebug() << mouse_sensitivity; - save_setting(setting_keys::Mouse_sensitivity, - mouse_sensitivity / 100); // saving the new mouse sensitivity - change_key_inputs(); // changing and saving key maps - }); - ui->buttonBox->connect(ui->buttonBox, &QDialogButtonBox::rejected, this, [this] { load_keys(); }); + ui->buttonBox->connect( + ui->buttonBox, &QDialogButtonBox::accepted, this, + [this] { // running the functions to change and save the new settings if the user presses ok + this->change_mouse_sensitivity(ui->horizontalSlider->value() * 100); + qDebug() << mouse_sensitivity; + save_setting(setting_keys::Mouse_sensitivity, + mouse_sensitivity / 100); // saving the new mouse sensitivity + change_key_inputs(); // changing and saving key maps + }); + ui->buttonBox->connect(ui->buttonBox, &QDialogButtonBox::rejected, this, + [this] { load_keys(); }); ui->formLayout->setSizeConstraint(QLayout::SetMinimumSize); ui->formLayout->setHorizontalSpacing(50); ui->formLayout->setVerticalSpacing(10); @@ -68,32 +70,38 @@ void Preferences::change_key_inputs() is_mouse_button(this->temp[ui->bmap->objectName()]); save_setting(keymaps[setting_keys::keys::B], this->temp[ui->bmap->objectName()]); /*------------------------------------------------------------*/ - GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_LeftShoulder].vk = this->temp[ui->Ltmap->objectName()]; + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_LeftShoulder].vk = + this->temp[ui->Ltmap->objectName()]; GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_LeftShoulder].is_mouse_key = is_mouse_button(this->temp[ui->Ltmap->objectName()]); save_setting(keymaps[setting_keys::keys::LSHDR], this->temp[ui->Ltmap->objectName()]); /*------------------------------------------------------------*/ - GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_RightShoulder].vk = this->temp[ui->Rtmap->objectName()]; + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_RightShoulder].vk = + this->temp[ui->Rtmap->objectName()]; GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_RightShoulder].is_mouse_key = is_mouse_button(this->temp[ui->Rtmap->objectName()]); save_setting(keymaps[setting_keys::keys::RSHDR], this->temp[ui->Rtmap->objectName()]); /*------------------------------------------------------------*/ - GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadDown].vk = this->temp[ui->ddownmap->objectName()]; + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadDown].vk = + this->temp[ui->ddownmap->objectName()]; GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadDown].is_mouse_key = is_mouse_button(this->temp[ui->ddownmap->objectName()]); save_setting(keymaps[setting_keys::keys::DPADDOWN], this->temp[ui->ddownmap->objectName()]); /*------------------------------------------------------------*/ - GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadUp].vk = this->temp[ui->dupmap->objectName()]; + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadUp].vk = + this->temp[ui->dupmap->objectName()]; GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadUp].is_mouse_key = is_mouse_button(this->temp[ui->dupmap->objectName()]); save_setting(keymaps[setting_keys::keys::DPADUP], this->temp[ui->dupmap->objectName()]); /*------------------------------------------------------------*/ - GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadRight].vk = this->temp[ui->drightmap->objectName()]; + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadRight].vk = + this->temp[ui->drightmap->objectName()]; GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadRight].is_mouse_key = is_mouse_button(this->temp[ui->drightmap->objectName()]); save_setting(keymaps[setting_keys::keys::DPADRIGHT], this->temp[ui->drightmap->objectName()]); /*------------------------------------------------------------*/ - GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadLeft].vk = this->temp[ui->dleftmap->objectName()]; + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadLeft].vk = + this->temp[ui->dleftmap->objectName()]; GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadLeft].is_mouse_key = is_mouse_button(this->temp[ui->dleftmap->objectName()]); save_setting(keymaps[setting_keys::keys::DPADLEFT], this->temp[ui->dleftmap->objectName()]); @@ -155,27 +163,33 @@ void Preferences::load_keys() get_scan_code(GAMEPAD_BUTTONS[GamepadButtons_B].vk, buffer, 256); this->ui->bmap->setText(QString(buffer)); /*------------------------------------------------------------*/ - this->temp[ui->Rtmap->objectName()] = GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_RightShoulder].vk; + this->temp[ui->Rtmap->objectName()] = + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_RightShoulder].vk; get_scan_code(GAMEPAD_BUTTONS[GamepadButtons_RightShoulder].vk, buffer, 256); this->ui->Rtmap->setText(QString(buffer)); /*------------------------------------------------------------*/ - this->temp[ui->Ltmap->objectName()] = GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_LeftShoulder].vk; + this->temp[ui->Ltmap->objectName()] = + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_LeftShoulder].vk; get_scan_code(GAMEPAD_BUTTONS[GamepadButtons_LeftShoulder].vk, buffer, 256); this->ui->Ltmap->setText(QString(buffer)); /*------------------------------------------------------------*/ - this->temp[ui->ddownmap->objectName()] = GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadDown].vk; + this->temp[ui->ddownmap->objectName()] = + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadDown].vk; get_scan_code(GAMEPAD_BUTTONS[GamepadButtons_DPadDown].vk, buffer, 256); this->ui->ddownmap->setText(QString(buffer)); /*------------------------------------------------------------*/ - this->temp[ui->dupmap->objectName()] = GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadUp].vk; + this->temp[ui->dupmap->objectName()] = + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadUp].vk; get_scan_code(GAMEPAD_BUTTONS[GamepadButtons_DPadUp].vk, buffer, 256); this->ui->dupmap->setText(QString(buffer)); /*------------------------------------------------------------*/ - this->temp[ui->drightmap->objectName()] = GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadRight].vk; + this->temp[ui->drightmap->objectName()] = + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadRight].vk; get_scan_code(GAMEPAD_BUTTONS[GamepadButtons_DPadRight].vk, buffer, 256); this->ui->drightmap->setText(QString(buffer)); /*------------------------------------------------------------*/ - this->temp[ui->dleftmap->objectName()] = GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadLeft].vk; + this->temp[ui->dleftmap->objectName()] = + GAMEPAD_BUTTONS[GamepadButtons::GamepadButtons_DPadLeft].vk; get_scan_code(GAMEPAD_BUTTONS[GamepadButtons_DPadLeft].vk, buffer, 256); this->ui->dleftmap->setText(QString(buffer)); /*-----------------------------------------------------------*/ @@ -189,10 +203,10 @@ void Preferences::load_keys() } /** - * The event filter virtual function is redefined to to filter for mouse and keyboard inputs when user tries to change - * the button-key maps. Checks which object is sending the event and type of event. If event is a keyboard or - * mouse button press then map and the object is button map then get the virtual key code of the key pressed - * and store the change in a temporary variable. + * The event filter virtual function is redefined to to filter for mouse and keyboard inputs when + * user tries to change the button-key maps. Checks which object is sending the event and type of + * event. If event is a keyboard or mouse button press then map and the object is button map then + * get the virtual key code of the key pressed and store the change in a temporary variable. * @param sender * To get the address of the object that is triggering the event. * @param event @@ -244,7 +258,8 @@ bool Preferences::eventFilter(QObject *sender, QEvent *event) } else { - if ((event->type() == QEvent::KeyPress || event->type() == QEvent::MouseButtonPress) && ptr->hasFocus()) + if ((event->type() == QEvent::KeyPress || event->type() == QEvent::MouseButtonPress) && + ptr->hasFocus()) return true; } } @@ -264,7 +279,8 @@ void Preferences::keyPressEvent(QKeyEvent *e) } /** - * Install the above event filter on all the button maps to capture the key presses when they have the focus. + * Install the above event filter on all the button maps to capture the key presses when they have + * the focus. */ void Preferences::install_event_filter() { diff --git a/src/settings.cpp b/src/settings.cpp index b48abd5..c630845 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -5,19 +5,21 @@ using namespace setting_keys; const QString SETTINGS_FILE = QDir::toNativeSeparators( - QDir::homePath() + "//VirtualGamePad.ini"); // the path of the settigs file. C:\Users\\VirtualGamePad.ini + QDir::homePath() + "//VirtualGamePad.ini"); // the path of the settings file. + // C:\Users\\VirtualGamePad.ini QSettings *settings; QString setting_keys::Mouse_sensitivity = "mouse_setting/mouse_sensitivity"; -void (*load_functions[])(void) = { - load_mouse_setting, load_port_number, - load_key_maps}; // an array of pointer to functions that needs to run on startup to load settings. +void (*load_functions[])(void) = {load_mouse_setting, load_port_number, + load_key_maps}; // an array of pointer to functions that needs to + // run on startup to load settings. /** * Save a setting to the settings file * @param key - * The name of the setting in string format if you want to group settings seperate the head group using + * The name of the setting in string format if you want to group settings seperate the head group + * using * @param value * The value of the settings can be of any data type string, int, char, float, e.t.c. */ @@ -74,43 +76,63 @@ void load_key_maps() // set the key mappings to the stored values { GAMEPAD_BUTTONS[GamepadButtons_A] = Input{(WORD)settings->value(keymaps[A], GAMEPAD_BUTTONS[GamepadButtons_A].vk).toULongLong(), - is_mouse_button(settings->value(keymaps[A], GAMEPAD_BUTTONS[GamepadButtons_A].vk).toULongLong())}; + is_mouse_button( + settings->value(keymaps[A], GAMEPAD_BUTTONS[GamepadButtons_A].vk).toULongLong())}; GAMEPAD_BUTTONS[GamepadButtons_B] = Input{(WORD)settings->value(keymaps[B], GAMEPAD_BUTTONS[GamepadButtons_B].vk).toULongLong(), - is_mouse_button(settings->value(keymaps[B], GAMEPAD_BUTTONS[GamepadButtons_B].vk).toULongLong())}; + is_mouse_button( + settings->value(keymaps[B], GAMEPAD_BUTTONS[GamepadButtons_B].vk).toULongLong())}; GAMEPAD_BUTTONS[GamepadButtons_X] = Input{(WORD)settings->value(keymaps[X], GAMEPAD_BUTTONS[GamepadButtons_X].vk).toULongLong(), - is_mouse_button(settings->value(keymaps[X], GAMEPAD_BUTTONS[GamepadButtons_X].vk).toULongLong())}; + is_mouse_button( + settings->value(keymaps[X], GAMEPAD_BUTTONS[GamepadButtons_X].vk).toULongLong())}; GAMEPAD_BUTTONS[GamepadButtons_Y] = Input{(WORD)settings->value(keymaps[Y], GAMEPAD_BUTTONS[GamepadButtons_Y].vk).toULongLong(), - is_mouse_button(settings->value(keymaps[Y], GAMEPAD_BUTTONS[GamepadButtons_Y].vk).toULongLong())}; + is_mouse_button( + settings->value(keymaps[Y], GAMEPAD_BUTTONS[GamepadButtons_Y].vk).toULongLong())}; GAMEPAD_BUTTONS[GamepadButtons_LeftShoulder] = - Input{(WORD)settings->value(keymaps[LSHDR], GAMEPAD_BUTTONS[GamepadButtons_LeftShoulder].vk).toULongLong(), + Input{(WORD)settings->value(keymaps[LSHDR], GAMEPAD_BUTTONS[GamepadButtons_LeftShoulder].vk) + .toULongLong(), is_mouse_button( - settings->value(keymaps[LSHDR], GAMEPAD_BUTTONS[GamepadButtons_LeftShoulder].vk).toULongLong())}; - GAMEPAD_BUTTONS[GamepadButtons_RightShoulder] = - Input{(WORD)settings->value(keymaps[RSHDR], GAMEPAD_BUTTONS[GamepadButtons_RightShoulder].vk).toULongLong(), + settings->value(keymaps[LSHDR], GAMEPAD_BUTTONS[GamepadButtons_LeftShoulder].vk) + .toULongLong())}; + GAMEPAD_BUTTONS[GamepadButtons_RightShoulder] = Input{ + (WORD)settings->value(keymaps[RSHDR], GAMEPAD_BUTTONS[GamepadButtons_RightShoulder].vk) + .toULongLong(), + is_mouse_button( + settings->value(keymaps[RSHDR], GAMEPAD_BUTTONS[GamepadButtons_RightShoulder].vk) + .toULongLong())}; + GAMEPAD_BUTTONS[GamepadButtons_DPadDown] = + Input{(WORD)settings->value(keymaps[DPADDOWN], GAMEPAD_BUTTONS[GamepadButtons_DPadDown].vk) + .toULongLong(), is_mouse_button( - settings->value(keymaps[RSHDR], GAMEPAD_BUTTONS[GamepadButtons_RightShoulder].vk).toULongLong())}; - GAMEPAD_BUTTONS[GamepadButtons_DPadDown] = Input{ - (WORD)settings->value(keymaps[DPADDOWN], GAMEPAD_BUTTONS[GamepadButtons_DPadDown].vk).toULongLong(), - is_mouse_button(settings->value(keymaps[DPADDOWN], GAMEPAD_BUTTONS[GamepadButtons_DPadDown].vk).toULongLong())}; + settings->value(keymaps[DPADDOWN], GAMEPAD_BUTTONS[GamepadButtons_DPadDown].vk) + .toULongLong())}; GAMEPAD_BUTTONS[GamepadButtons_DPadUp] = Input{ - (WORD)settings->value(keymaps[DPADUP], GAMEPAD_BUTTONS[GamepadButtons_DPadUp].vk).toLongLong(), - is_mouse_button(settings->value(keymaps[DPADUP], GAMEPAD_BUTTONS[GamepadButtons_DPadUp].vk).toLongLong())}; - GAMEPAD_BUTTONS[GamepadButtons_DPadRight] = - Input{(WORD)settings->value(keymaps[DPADRIGHT], GAMEPAD_BUTTONS[GamepadButtons_DPadRight].vk).toLongLong(), + (WORD)settings->value(keymaps[DPADUP], GAMEPAD_BUTTONS[GamepadButtons_DPadUp].vk) + .toLongLong(), + is_mouse_button(settings->value(keymaps[DPADUP], GAMEPAD_BUTTONS[GamepadButtons_DPadUp].vk) + .toLongLong())}; + GAMEPAD_BUTTONS[GamepadButtons_DPadRight] = Input{ + (WORD)settings->value(keymaps[DPADRIGHT], GAMEPAD_BUTTONS[GamepadButtons_DPadRight].vk) + .toLongLong(), + is_mouse_button( + settings->value(keymaps[DPADRIGHT], GAMEPAD_BUTTONS[GamepadButtons_DPadRight].vk) + .toLongLong())}; + GAMEPAD_BUTTONS[GamepadButtons_DPadLeft] = + Input{(WORD)settings->value(keymaps[DPADLEFT], GAMEPAD_BUTTONS[GamepadButtons_DPadLeft].vk) + .toLongLong(), is_mouse_button( - settings->value(keymaps[DPADRIGHT], GAMEPAD_BUTTONS[GamepadButtons_DPadRight].vk).toLongLong())}; - GAMEPAD_BUTTONS[GamepadButtons_DPadLeft] = Input{ - (WORD)settings->value(keymaps[DPADLEFT], GAMEPAD_BUTTONS[GamepadButtons_DPadLeft].vk).toLongLong(), - is_mouse_button(settings->value(keymaps[DPADLEFT], GAMEPAD_BUTTONS[GamepadButtons_DPadLeft].vk).toLongLong())}; - GAMEPAD_BUTTONS[GamepadButtons_View] = - Input{(WORD)settings->value(keymaps[VIEW], GAMEPAD_BUTTONS[GamepadButtons_View].vk).toLongLong(), - is_mouse_button(settings->value(keymaps[VIEW], GAMEPAD_BUTTONS[GamepadButtons_View].vk).toLongLong())}; - GAMEPAD_BUTTONS[GamepadButtons_Menu] = - Input{(WORD)settings->value(keymaps[MENU], GAMEPAD_BUTTONS[GamepadButtons_Menu].vk).toLongLong(), - is_mouse_button(settings->value(keymaps[MENU], GAMEPAD_BUTTONS[GamepadButtons_Menu].vk).toLongLong())}; + settings->value(keymaps[DPADLEFT], GAMEPAD_BUTTONS[GamepadButtons_DPadLeft].vk) + .toLongLong())}; + GAMEPAD_BUTTONS[GamepadButtons_View] = Input{ + (WORD)settings->value(keymaps[VIEW], GAMEPAD_BUTTONS[GamepadButtons_View].vk).toLongLong(), + is_mouse_button( + settings->value(keymaps[VIEW], GAMEPAD_BUTTONS[GamepadButtons_View].vk).toLongLong())}; + GAMEPAD_BUTTONS[GamepadButtons_Menu] = Input{ + (WORD)settings->value(keymaps[MENU], GAMEPAD_BUTTONS[GamepadButtons_Menu].vk).toLongLong(), + is_mouse_button( + settings->value(keymaps[MENU], GAMEPAD_BUTTONS[GamepadButtons_Menu].vk).toLongLong())}; } /** diff --git a/src/settings.hpp b/src/settings.hpp index 333318a..fef291f 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -36,23 +36,25 @@ enum keys extern QSettings *settings; inline QList server_settings = {"port"}; -// inline QList keymaps = {"keymaps/A", "keymaps/B", "keymaps/X", "keymaps/Y", "keymaps/RT", "keymaps/LT"}; +// inline QList keymaps = +// {"keymaps/A", "keymaps/B", "keymaps/X", "keymaps/Y", "keymaps/RT", "keymaps/LT"}; /** * A Qmap to map the keys in namespace to corresponding settings name in string format. */ -const inline QMap keymaps = {{setting_keys::keys::A, "keymaps/A"}, - {setting_keys::keys::B, "keymaps/B"}, - {setting_keys::keys::X, "keymaps/X"}, - {setting_keys::keys::Y, "keymaps/Y"}, - {setting_keys::keys::RSHDR, "keymaps/RT"}, - {setting_keys::keys::LSHDR, "keymaps/LT"}, - {setting_keys::keys::DPADDOWN, "keymaps/DPADDOWN"}, - {setting_keys::keys::DPADUP, "keymaps/DPADUP"}, - {setting_keys::keys::DPADRIGHT, "keymaps/DPADRIGHT"}, - {setting_keys::keys::DPADLEFT, "keymaps/DPADLEFT"}, - {setting_keys::keys::VIEW, "keymaps/VIEW"}, - {setting_keys::keys::MENU, "keymaps/MENU"}}; +const inline QMap keymaps = { + {setting_keys::keys::A, "keymaps/A"}, + {setting_keys::keys::B, "keymaps/B"}, + {setting_keys::keys::X, "keymaps/X"}, + {setting_keys::keys::Y, "keymaps/Y"}, + {setting_keys::keys::RSHDR, "keymaps/RT"}, + {setting_keys::keys::LSHDR, "keymaps/LT"}, + {setting_keys::keys::DPADDOWN, "keymaps/DPADDOWN"}, + {setting_keys::keys::DPADUP, "keymaps/DPADUP"}, + {setting_keys::keys::DPADRIGHT, "keymaps/DPADRIGHT"}, + {setting_keys::keys::DPADLEFT, "keymaps/DPADLEFT"}, + {setting_keys::keys::VIEW, "keymaps/VIEW"}, + {setting_keys::keys::MENU, "keymaps/MENU"}}; void save_setting(const QString &key, const QVariant &value); QVariant load_setting(const QString &key); diff --git a/src/settings_key_variables.cpp b/src/settings_key_variables.cpp index dbf6c5d..5f18ad1 100644 --- a/src/settings_key_variables.cpp +++ b/src/settings_key_variables.cpp @@ -6,18 +6,19 @@ int port = 7878; // the port on which the server runs on. /** * A map for the gamepad button and the corresponding input. */ -std::map GAMEPAD_BUTTONS = {{GamepadButtons::GamepadButtons_Menu, Input{VK_MENU, 0}}, - {GamepadButtons::GamepadButtons_View, Input{VK_TAB, 0}}, - {GamepadButtons::GamepadButtons_A, Input{VK_RETURN, 0}}, - {GamepadButtons::GamepadButtons_B, Input{'B', 0}}, - {GamepadButtons::GamepadButtons_X, Input{VK_SHIFT, 0}}, - {GamepadButtons::GamepadButtons_Y, Input{VK_CONTROL, 0}}, - {GamepadButtons::GamepadButtons_DPadUp, Input{VK_UP, 0}}, - {GamepadButtons::GamepadButtons_DPadDown, Input{VK_DOWN, 0}}, - {GamepadButtons::GamepadButtons_DPadLeft, Input{VK_LEFT, 0}}, - {GamepadButtons::GamepadButtons_DPadRight, Input{VK_RIGHT, 0}}, - {GamepadButtons::GamepadButtons_LeftShoulder, Input{VK_LBUTTON, 1}}, - {GamepadButtons::GamepadButtons_RightShoulder, Input{VK_NEXT, 0}}}; +std::map GAMEPAD_BUTTONS = { + {GamepadButtons::GamepadButtons_Menu, Input{VK_MENU, 0}}, + {GamepadButtons::GamepadButtons_View, Input{VK_TAB, 0}}, + {GamepadButtons::GamepadButtons_A, Input{VK_RETURN, 0}}, + {GamepadButtons::GamepadButtons_B, Input{'B', 0}}, + {GamepadButtons::GamepadButtons_X, Input{VK_SHIFT, 0}}, + {GamepadButtons::GamepadButtons_Y, Input{VK_CONTROL, 0}}, + {GamepadButtons::GamepadButtons_DPadUp, Input{VK_UP, 0}}, + {GamepadButtons::GamepadButtons_DPadDown, Input{VK_DOWN, 0}}, + {GamepadButtons::GamepadButtons_DPadLeft, Input{VK_LEFT, 0}}, + {GamepadButtons::GamepadButtons_DPadRight, Input{VK_RIGHT, 0}}, + {GamepadButtons::GamepadButtons_LeftShoulder, Input{VK_LBUTTON, 1}}, + {GamepadButtons::GamepadButtons_RightShoulder, Input{VK_NEXT, 0}}}; /** * Maps the joystick movements. diff --git a/src/simulation/mouseSim.hpp b/src/simulation/mouseSim.hpp index 3712ff1..19b379d 100644 --- a/src/simulation/mouseSim.hpp +++ b/src/simulation/mouseSim.hpp @@ -37,7 +37,8 @@ void doubleClick(); /** * @brief Simulate a left click. - * @note Repeated calls to this function may result in a double click. Use singleClick() if you want to avoid this. + * @note Repeated calls to this function may result in a double click. + * Use singleClick() if you want to avoid this. * @see singleClick() */ void leftClick();