diff --git a/CMakeLists.txt b/CMakeLists.txt index fdd39e7..e52159d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,7 @@ set(THIRD_PARTY_LIB_SOURCES add_library(QR_Code_Generator SHARED ${THIRD_PARTY_LIB_SOURCES}) set(PROJECT_SOURCES + res/icons.qrc src/main.cpp src/mainwindow.cpp src/mainwindow.hpp @@ -37,7 +38,6 @@ set(PROJECT_SOURCES src/networking/server.ui src/networking/executor.cpp src/networking/executor.hpp - res/icons.qrc src/preferences.h src/preferences.cpp src/preferences.ui diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 70a65e2..0bfe3fa 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); - ui->settingsButton->connect(ui->settingsButton, &QPushButton::pressed, this, [=] { this->p->show(); }); + QPushButton::connect(ui->settingsButton, &QPushButton::pressed, this, [=] { this->p->show(); }); + QPushButton::connect(ui->startButton, &QPushButton::pressed, this, &MainWindow::launch_server); } MainWindow::~MainWindow() @@ -20,7 +21,7 @@ MainWindow::~MainWindow() delete ui; } -void MainWindow::on_startButton_clicked() +void MainWindow::launch_server() { Server server(this); server.exec(); diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp index 86eaf75..a748c61 100644 --- a/src/mainwindow.hpp +++ b/src/mainwindow.hpp @@ -10,16 +10,16 @@ class MainWindow; } QT_END_NAMESPACE -class MainWindow : public QMainWindow +class MainWindow final : public QMainWindow { Q_OBJECT public: - MainWindow(QWidget *parent = nullptr); - ~MainWindow(); + explicit MainWindow(QWidget *parent = nullptr); + ~MainWindow() override; private slots: - void on_startButton_clicked(); + void launch_server(); private: Ui::MainWindow *ui; diff --git a/src/networking/executor.cpp b/src/networking/executor.cpp index 0b97b14..1151387 100644 --- a/src/networking/executor.cpp +++ b/src/networking/executor.cpp @@ -89,10 +89,10 @@ 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) - int offsetX = reading.right_thumbstick_x * mouse_sensivity; - int offsetY = reading.right_thumbstick_y * mouse_sensivity; - int scaleX = abs(offsetX) < (THRESHOLD * mouse_sensivity) ? 0 : 1; - int scaleY = abs(offsetY) < (THRESHOLD * mouse_sensivity) ? 0 : 1; + 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; + int scaleY = abs(offsetY) < (THRESHOLD * mouse_sensitivity) ? 0 : 1; qDebug() << "Moving mouse by" << offsetX << ", " << offsetY; for (int count = 1; count <= std::max(abs(offsetX), abs(offsetY)); ++count) diff --git a/src/networking/server.cpp b/src/networking/server.cpp index 5f068b4..1b824a4 100644 --- a/src/networking/server.cpp +++ b/src/networking/server.cpp @@ -3,7 +3,6 @@ #include "ui_server.h" -#include "../../VGP_Data_Exchange/C/Colfer.h" #include "../../third-party-libs/QR-Code-generator/cpp/qrcodegen.hpp" #include "../settings_key_variables.h" diff --git a/src/networking/server.hpp b/src/networking/server.hpp index db0ad15..6733704 100644 --- a/src/networking/server.hpp +++ b/src/networking/server.hpp @@ -15,7 +15,7 @@ class Server : public QDialog public: explicit Server(QWidget *parent = nullptr); - ~Server(); + ~Server() override; QTcpServer *tcpServer = nullptr; private slots: diff --git a/src/preferences.cpp b/src/preferences.cpp index 6d4b015..3dae34c 100644 --- a/src/preferences.cpp +++ b/src/preferences.cpp @@ -3,13 +3,9 @@ #include "settings_key_variables.h" #include "ui_preferences.h" #include "winuser.h" -#include #include -#include #include #include -#include -#include #include #include @@ -21,32 +17,30 @@ Preferences::Preferences(QWidget *parent) : QDialog(parent), ui(new Ui::Preferen ui->buttonBox->connect(ui->buttonBox, &QDialogButtonBox::accepted, 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_sensivity; - save_setting(setting_keys::Mouse_sensivity, - mouse_sensivity / 100); // saving the new mouse sensivity - change_key_inputs(); // changing and saving key maps + 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, [=] { load_keys(); }); ui->formLayout->setSizeConstraint(QLayout::SetMinimumSize); ui->formLayout->setHorizontalSpacing(50); ui->formLayout->setVerticalSpacing(10); - ui->horizontalSlider->setValue(mouse_sensivity / 100); + ui->horizontalSlider->setValue(mouse_sensitivity / 100); Preferences::load_keys(); } /** - * @brief Preferences::change_mouse_sensitivity - * Changes the mouse sensivity or the cursor speed + * Changes the mouse sensitivity or the cursor speed * @param value - * The amount of mouse sensivity you want to set. + * The amount of mouse sensitivity you want to set. */ void Preferences::change_mouse_sensitivity(int value) { - mouse_sensivity = value; + mouse_sensitivity = value; } /** - * @brief Preferences::change_key_inputs * This changes the keyboard maps and saves those changes in the config file. * This function is executed if the user presses ok button. */ @@ -116,8 +110,7 @@ void Preferences::change_key_inputs() } /** - * @brief Preferences::get_scan_code - * Copies the name of the of corrosponding key or virutal key code to the provided buffer. + * Copies the name of the of corresponding key or virtual key code to the provided buffer. * @param vk * The virtual key code of the key you want to get. * @param a @@ -140,7 +133,6 @@ void Preferences::get_scan_code(WORD vk, char *a, int size) } /** - * @brief Preferences::load_keys * Displays the key to which each button is mapped to. * Saves the initial key maps in variables that can be changed later if user wants to. */ @@ -197,11 +189,10 @@ void Preferences::load_keys() } /** - * @brief Preferences::eventFilter * 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 - * mousebutton press than map and the object is buttonmap than get the virtual key code of the key pressed and store the - * change in a temporary variable. + * 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 @@ -245,7 +236,7 @@ bool Preferences::eventFilter(QObject *sender, QEvent *event) valid = true; break; default: - qDebug() << "[!] Error Occured No Legal Mouse Button Found"; + qDebug() << "[!] Error Occurred. No Legal Mouse Button Found"; } if (valid) ptr->setText(QString(buffer)); @@ -261,7 +252,6 @@ bool Preferences::eventFilter(QObject *sender, QEvent *event) } /** - * @brief Preferences::keyPressEvent * Make the Qdialog box ignores the enter key and escape key presses when the focus is on button map * @param e * Capture the key_press event @@ -274,7 +264,6 @@ void Preferences::keyPressEvent(QKeyEvent *e) } /** - * @brief Preferences::install_event_filter * 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/preferences.h b/src/preferences.h index 26e5549..4e13594 100644 --- a/src/preferences.h +++ b/src/preferences.h @@ -10,18 +10,18 @@ namespace Ui class Preferences; } -class Preferences : public QDialog +class Preferences final : public QDialog { Q_OBJECT public: explicit Preferences(QWidget *parent = nullptr); void load_keys(); - ~Preferences(); + ~Preferences() override; protected: - bool eventFilter(QObject *sender, QEvent *event); - void keyPressEvent(QKeyEvent *e); + bool eventFilter(QObject *sender, QEvent *event) override; + void keyPressEvent(QKeyEvent *e) override; private: Ui::Preferences *ui; diff --git a/src/settings.cpp b/src/settings.cpp index ea92e7e..0e7d1cd 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -8,21 +8,20 @@ const QString SETTINGS_FILE = QDir::toNativeSeparators( QDir::homePath() + "//VirtualGamePad.ini"); // the path of the settigs file. C:\Users\\VirtualGamePad.ini QSettings *settings; -QString setting_keys::Mouse_sensivity = "mouse_setting/mouse_sensivity"; +QString setting_keys::Mouse_sensitivity = "mouse_setting/mouse_sensitivity"; -void (*load_functions[3])(void) = { +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. /** - * @brief save_setting * 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 * @param value * The value of the settings can be of any data type string, int, char, float, e.t.c. */ -void save_setting(QString key, QVariant value) +void save_setting(const QString &key, const QVariant &value) { settings->setValue(key, value); settings->sync(); @@ -31,29 +30,26 @@ void save_setting(QString key, QVariant value) } /** - * @brief load_setting * Get the value of a setting. * @param key * The fullname including the groups of the setting in string format * @return The setting as QVariant can be converted into almost all data types. */ -QVariant load_setting(QString key) +QVariant load_setting(const QString &key) { QVariant value = settings->value(key); return value; } /** - * @brief load_mouse_setting - * Loads and sets the mouse sensivity. + * Loads and sets the mouse sensitivity. */ void load_mouse_setting() { - mouse_sensivity = settings->value(setting_keys::Mouse_sensivity).toInt() * 100; + mouse_sensitivity = settings->value(setting_keys::Mouse_sensitivity).toInt() * 100; } /** - * @brief load_settings_file * Loads the settings file for the current application. * @param parent * The parent object either a widget or Qt Application e.t.c @@ -64,7 +60,6 @@ void load_settings_file(QObject *parent = nullptr) } /** - * @brief load_port_number * Load and set the port number */ void load_port_number() // set the port number as user_defined @@ -73,66 +68,63 @@ void load_port_number() // set the port number as user_defined } /** - * @brief load_key_maps * Load the key maps from the settings file. */ void load_key_maps() // set the key mappings to the stored values { GAMEPAD_BUTTONS[GamepadButtons_A] = - TRIAL{(WORD)settings->value(keymaps[A], GAMEPAD_BUTTONS[GamepadButtons_A].vk).toULongLong(), + 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())}; GAMEPAD_BUTTONS[GamepadButtons_B] = - TRIAL{(WORD)settings->value(keymaps[B], GAMEPAD_BUTTONS[GamepadButtons_B].vk).toULongLong(), + 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())}; GAMEPAD_BUTTONS[GamepadButtons_X] = - TRIAL{(WORD)settings->value(keymaps[X], GAMEPAD_BUTTONS[GamepadButtons_X].vk).toULongLong(), + 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())}; GAMEPAD_BUTTONS[GamepadButtons_Y] = - TRIAL{(WORD)settings->value(keymaps[Y], GAMEPAD_BUTTONS[GamepadButtons_Y].vk).toULongLong(), + 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())}; GAMEPAD_BUTTONS[GamepadButtons_LeftShoulder] = - TRIAL{(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] = - TRIAL{(WORD)settings->value(keymaps[RSHDR], GAMEPAD_BUTTONS[GamepadButtons_RightShoulder].vk).toULongLong(), + 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] = TRIAL{ + 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())}; - GAMEPAD_BUTTONS[GamepadButtons_DPadUp] = TRIAL{ + 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] = - TRIAL{(WORD)settings->value(keymaps[DPADRIGHT], GAMEPAD_BUTTONS[GamepadButtons_DPadRight].vk).toLongLong(), + 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] = TRIAL{ + 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] = - TRIAL{(WORD)settings->value(keymaps[VIEW], GAMEPAD_BUTTONS[GamepadButtons_View].vk).toLongLong(), + 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] = - TRIAL{(WORD)settings->value(keymaps[MENU], GAMEPAD_BUTTONS[GamepadButtons_Menu].vk).toLongLong(), + 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())}; } /** - * @brief load_all_settings * Run the functions using the function array to load all the necessary settings. */ void load_all_settings() { - for (int i = 0; i < 3; i++) + for (auto &load_function : load_functions) { - (*load_functions[i])(); + (*load_function)(); } } /** - * @brief is_mouse_button * Function to find out if the user mapped a keyboard key or mouse button * @param vk * Virtual key code of the key or mouse button pressed diff --git a/src/settings.h b/src/settings.h index 7abaae6..333318a 100644 --- a/src/settings.h +++ b/src/settings.h @@ -14,7 +14,7 @@ enum server_keys Port }; -extern QString Mouse_sensivity; +extern QString Mouse_sensitivity; enum keys { @@ -37,27 +37,27 @@ 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"}; + /** - * @brief keymaps - * a Qmap to map the keys in namespace to corresponding settings name in string format. + * A Qmap to map the keys in namespace to corresponding settings name in string format. */ -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(QString key, QVariant value); -QVariant load_setting(QString key); +void save_setting(const QString &key, const QVariant &value); +QVariant load_setting(const QString &key); void load_mouse_setting(); -void set_mouse_sensivity(); +void set_mouse_sensitivity(); void load_settings_file(QObject *parent); void load_port_number(); void load_key_maps(); diff --git a/src/settings_key_variables.cpp b/src/settings_key_variables.cpp index a70169d..76722ca 100644 --- a/src/settings_key_variables.cpp +++ b/src/settings_key_variables.cpp @@ -1,29 +1,25 @@ #include "settings_key_variables.h" -int mouse_sensivity = 1000; // the mouse_sensivity or the cursor speed. -int port = 7878; // the port on which the server runs on. +int mouse_sensitivity = 1000; // the mouse_sensitivity or the cursor speed. +int port = 7878; // the port on which the server runs on. /** - * @brief GAMEPAD_BUTTONS * A map for the gamepad button and the corresponding input. */ -std::map GAMEPAD_BUTTONS = {{GamepadButtons::GamepadButtons_Menu, TRIAL{VK_MENU, 0}}, - {GamepadButtons::GamepadButtons_View, TRIAL{VK_TAB, 0}}, - {GamepadButtons::GamepadButtons_A, TRIAL{VK_RETURN, 0}}, - {GamepadButtons::GamepadButtons_B, TRIAL{'B', 0}}, - {GamepadButtons::GamepadButtons_X, TRIAL{VK_SHIFT, 0}}, - {GamepadButtons::GamepadButtons_Y, TRIAL{VK_CONTROL, 0}}, - {GamepadButtons::GamepadButtons_DPadUp, TRIAL{VK_UP, 0}}, - {GamepadButtons::GamepadButtons_DPadDown, TRIAL{VK_DOWN, 0}}, - {GamepadButtons::GamepadButtons_DPadLeft, TRIAL{VK_LEFT, 0}}, - {GamepadButtons::GamepadButtons_DPadRight, TRIAL{VK_RIGHT, 0}}, - {GamepadButtons::GamepadButtons_LeftShoulder, TRIAL{VK_LBUTTON, 1}}, - {GamepadButtons::GamepadButtons_RightShoulder, TRIAL{VK_NEXT, 0}}}; -// {GamepadButtons::GamepadButtons_LeftThumbstick, TRIAL{VK_LBUTTON, 1}}, -// {GamepadButtons::GamepadButtons_RightThumbstick, TRIAL{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}}}; /** - * @brief THUMBSTICK_KEYS * Maps the joystick movements. */ std::map THUMBSTICK_KEYS = { @@ -33,38 +29,36 @@ std::map THUMBSTICK_KEYS = { {Thumbstick::RightThumbstickLeft, VK_LEFT}, {Thumbstick::RightThumbstickRight, VK_RIGHT}}; /** - * @brief vk_maps * A std::map to map the virtual key codes to corresponding key names */ -std::map vk_maps = {{VK_LBUTTON, "LMButton"}, - {VK_RBUTTON, "RMButton"}, - {VK_MBUTTON, "MMButton"}, - {VK_BACK, "BACKSPACE"}, - {VK_TAB, "TAB"}, - {VK_RETURN, "ENTER"}, - {VK_SHIFT, "SHIFT"}, - {VK_CONTROL, "CTRL"}, - {VK_CAPITAL, "CAPITAL"}, - {VK_ESCAPE, "ESCAPE"}, - {VK_SPACE, "SPACE"}, - {VK_PRIOR, "PageUP"}, - {VK_NEXT, "PageDOWN"}, - {VK_END, "END"}, - {VK_HOME, "HOME"}, - {VK_LEFT, "LEFT"}, - {VK_UP, "UP"}, - {VK_RIGHT, "RIGHT"}, - {VK_DOWN, "DOWN"}, - {VK_INSERT, "INS"}, - {VK_DELETE, "DEL"}, - {VK_OEM_PERIOD, "."}, - {VK_OEM_COMMA, ","}, - {VK_OEM_MINUS, "-"}, - {VK_OEM_PLUS, "+"}, - {VK_MENU, "MENU"}}; +const std::map vk_maps = {{VK_LBUTTON, "LMButton"}, + {VK_RBUTTON, "RMButton"}, + {VK_MBUTTON, "MMButton"}, + {VK_BACK, "BACKSPACE"}, + {VK_TAB, "TAB"}, + {VK_RETURN, "ENTER"}, + {VK_SHIFT, "SHIFT"}, + {VK_CONTROL, "CTRL"}, + {VK_CAPITAL, "CAPITAL"}, + {VK_ESCAPE, "ESCAPE"}, + {VK_SPACE, "SPACE"}, + {VK_PRIOR, "PageUP"}, + {VK_NEXT, "PageDOWN"}, + {VK_END, "END"}, + {VK_HOME, "HOME"}, + {VK_LEFT, "LEFT"}, + {VK_UP, "UP"}, + {VK_RIGHT, "RIGHT"}, + {VK_DOWN, "DOWN"}, + {VK_INSERT, "INS"}, + {VK_DELETE, "DEL"}, + {VK_OEM_PERIOD, "."}, + {VK_OEM_COMMA, ","}, + {VK_OEM_MINUS, "-"}, + {VK_OEM_PLUS, "+"}, + {VK_MENU, "MENU"}}; /** - * @brief MOUSE_BUTTONS * A list containing the Mouse Buttons. */ const QList MOUSE_BUTTONS = {VK_LBUTTON, VK_RBUTTON, VK_MBUTTON}; diff --git a/src/settings_key_variables.h b/src/settings_key_variables.h index 273879c..6623da9 100644 --- a/src/settings_key_variables.h +++ b/src/settings_key_variables.h @@ -8,18 +8,17 @@ #include /** - * @brief The TRIAL Struct * A structure to hold the button mappings. */ -struct TRIAL +struct Input { - WORD vk; + WORD vk{}; uint is_mouse_key = 0; }; -extern int mouse_sensivity; +extern int mouse_sensitivity; extern int port; -extern std::map GAMEPAD_BUTTONS; +extern std::map GAMEPAD_BUTTONS; enum Thumbstick {