Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user editable key maps #5

Merged
merged 34 commits into from
Dec 16, 2023
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
1ef76e0
Add Mouse_pointer
franklin654 Aug 6, 2023
cc2f07c
Update executor.cpp
franklin654 Aug 6, 2023
7934960
changing the mouse_sensitivity_variable
franklin654 Aug 6, 2023
3bb24ce
updating PROJECT_SOURCES
franklin654 Aug 9, 2023
7db3439
created programmable variables
franklin654 Aug 11, 2023
921ae75
Update CMakeLists.txt
franklin654 Aug 19, 2023
590fcbc
adding icons
franklin654 Aug 23, 2023
d03e09b
button icons
franklin654 Aug 26, 2023
15a92c7
user defined key maps
franklin654 Aug 26, 2023
11ea776
fixing bugs and adding resources
franklin654 Aug 30, 2023
a2509f1
add tracking for mouse_press
franklin654 Aug 30, 2023
1e8f652
Moved resource files
kitswas Aug 30, 2023
c393a5f
Use resources instead of absolute paths
kitswas Aug 30, 2023
3cda9c7
Update src/main.cpp
franklin654 Aug 30, 2023
6da54fc
Update CMakeLists.txt
franklin654 Aug 30, 2023
6336624
fixing the suggested changes
franklin654 Aug 30, 2023
c64b9d1
Updated the preferences UI
kitswas Aug 30, 2023
d079152
added documentation
franklin654 Sep 1, 2023
31603c7
Merge branch 'User_Preferences' of https://github.com/franklin654/Vir…
franklin654 Sep 1, 2023
9a29227
fixing key sizes
franklin654 Sep 1, 2023
e328c12
Revert "fixing key sizes"
franklin654 Sep 1, 2023
1ada43d
changes to documentation and fixing sizes
franklin654 Sep 1, 2023
750c2b8
removing unccessary code
franklin654 Sep 4, 2023
cfb1cbd
changing the datatype of buttons
franklin654 Nov 16, 2023
8fc51e1
Merge branch 'kitswas:main' into User_Preferences
franklin654 Nov 16, 2023
cc5c86d
Solving sub module changes
franklin654 Nov 16, 2023
688a401
Revamped Preferences
franklin654 Dec 10, 2023
52ce451
Sound Cloud Suggestions
franklin654 Dec 10, 2023
24e3836
Documentation changes
franklin654 Dec 10, 2023
e4e009d
Merge branch 'kitswas:main' into User_Preferences
franklin654 Dec 15, 2023
fdbd020
Applying Clang-Format to the code
franklin654 Dec 15, 2023
855b5f6
Reset Preferences on Cancel
franklin654 Dec 15, 2023
b03f50f
Added the Menu Button and View Button
franklin654 Dec 15, 2023
b78da90
Fixed submodules
kitswas Dec 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ set(THIRD_PARTY_LIB_SOURCES
third-party-libs/QR-Code-generator/cpp/qrcodegen.hpp
)

add_library(QR_Code_Generator SHARED ${THIRD_PARTY_LIB_SOURCES})
add_library(QR_Code_Generator SHARED ${THIRD_PARTY_LIB_SOURCES}
)
franklin654 marked this conversation as resolved.
Show resolved Hide resolved

set(PROJECT_SOURCES
src/main.cpp
Expand All @@ -38,6 +39,13 @@ set(PROJECT_SOURCES
src/networking/executor.cpp
src/networking/executor.hpp
res/icons.qrc
src/preferences.h
src/preferences.cpp
src/preferences.ui
src/settings.h
src/settings.cpp
src/settings_key_variables.h
src/settings_key_variables.cpp
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
Expand Down
10 changes: 10 additions & 0 deletions res/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,15 @@
<file>logos/GamepadIcon.svg</file>
<file>logos/GamepadIcon_transparent.png</file>
<file>logos/SquareIcon.png</file>
<file>logos/icons8-down-30.png</file>
<file>logos/icons8-left-30.png</file>
<file>logos/icons8-right-30.png</file>
<file>logos/icons8-up-30.png</file>
<file>logos/icons8-xbox-a-30.png</file>
<file>logos/icons8-xbox-b-30.png</file>
<file>logos/icons8-xbox-lt-30.png</file>
<file>logos/icons8-xbox-rt-30.png</file>
<file>logos/icons8-xbox-x-30.png</file>
<file>logos/icons8-xbox-y-30.png</file>
</qresource>
</RCC>
Binary file added res/logos/icons8-down-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/logos/icons8-left-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/logos/icons8-right-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/logos/icons8-up-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/logos/icons8-xbox-a-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/logos/icons8-xbox-b-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/logos/icons8-xbox-lt-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/logos/icons8-xbox-rt-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/logos/icons8-xbox-x-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/logos/icons8-xbox-y-30.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "settings.h"
#include <QApplication>
#include <QSettings>
franklin654 marked this conversation as resolved.
Show resolved Hide resolved
#include <QStyleFactory>

#include "mainwindow.hpp"
Expand Down
7 changes: 7 additions & 0 deletions src/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
#include "mainwindow.hpp"
#include "networking/server.hpp"

#include "settings.h"
#include "ui_mainwindow.h"
#include <QPushButton>

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow)
{
load_settings_file(this);
load_mouse_setting();
load_key_maps();
this->p = new Preferences(this);
ui->setupUi(this);
ui->pushButton->connect(ui->pushButton, &QPushButton::pressed, this, [=] { this->p->show(); });
franklin654 marked this conversation as resolved.
Show resolved Hide resolved
}

MainWindow::~MainWindow()
Expand Down
2 changes: 2 additions & 0 deletions src/mainwindow.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma once

#include "preferences.h"
#include <QMainWindow>

QT_BEGIN_NAMESPACE
Expand All @@ -22,4 +23,5 @@ class MainWindow : public QMainWindow

private:
Ui::MainWindow *ui;
Preferences *p = nullptr;
};
9 changes: 8 additions & 1 deletion src/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton">
franklin654 marked this conversation as resolved.
Show resolved Hide resolved
<property name="text">
<string>Preferences</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QMenuBar" name="menubar">
Expand All @@ -37,7 +44,7 @@
<x>0</x>
<y>0</y>
<width>800</width>
<height>26</height>
<height>17</height>
</rect>
</property>
</widget>
Expand Down
11 changes: 6 additions & 5 deletions src/networking/executor.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#include "executor.hpp"
#include "../settings_key_variables.h"

#include <QApplication>

#define THRESHOLD 0.5
#define MOUSE_SENSITIVITY 1000


vgp_data_exchange_gamepad_reading parse_gamepad_state(const char *data, size_t len)
{
Expand Down Expand Up @@ -72,10 +73,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_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;
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;

qDebug() << "Moving mouse by" << offsetX << ", " << offsetY;
for (int count = 1; count <= std::max(abs(offsetX), abs(offsetY)); ++count)
Expand Down
38 changes: 2 additions & 36 deletions src/networking/executor.hpp
Original file line number Diff line number Diff line change
@@ -1,44 +1,10 @@
#pragma once

#include "../../VGP_Data_Exchange/C/Colfer.h"
#include "../../VGP_Data_Exchange/C/GameButtons.h"
#include "../simulation/simulate.hpp"

#include <map>

vgp_data_exchange_gamepad_reading parse_gamepad_state(const char *data, size_t len);
bool inject_gamepad_state(vgp_data_exchange_gamepad_reading reading);

// Map of gamepad buttons to keyboard keys
const std::map<GamepadButtons, WORD> GAMEPAD_BUTTONS = {{GamepadButtons::GamepadButtons_Menu, VK_MENU},
{GamepadButtons::GamepadButtons_View, VK_TAB},
{GamepadButtons::GamepadButtons_A, VK_RETURN},
{GamepadButtons::GamepadButtons_B, VK_ESCAPE},
{GamepadButtons::GamepadButtons_X, VK_SHIFT},
{GamepadButtons::GamepadButtons_Y, VK_CONTROL},
{GamepadButtons::GamepadButtons_DPadUp, VK_UP},
{GamepadButtons::GamepadButtons_DPadDown, VK_DOWN},
{GamepadButtons::GamepadButtons_DPadLeft, VK_LEFT},
{GamepadButtons::GamepadButtons_DPadRight, VK_RIGHT},
{GamepadButtons::GamepadButtons_LeftShoulder, 'E'},
{GamepadButtons::GamepadButtons_RightShoulder, VK_SPACE},
{GamepadButtons::GamepadButtons_LeftThumbstick, VK_PRIOR},
{GamepadButtons::GamepadButtons_RightThumbstick, VK_NEXT}};

enum Thumbstick
{
LeftThumbstickUp,
LeftThumbstickDown,
LeftThumbstickLeft,
LeftThumbstickRight,
RightThumbstickUp,
RightThumbstickDown,
RightThumbstickLeft,
RightThumbstickRight
};

const std::map<Thumbstick, WORD> THUMBSTICK_KEYS = {
{Thumbstick::LeftThumbstickUp, 'W'}, {Thumbstick::LeftThumbstickDown, 'S'},
{Thumbstick::LeftThumbstickLeft, 'A'}, {Thumbstick::LeftThumbstickRight, 'D'},
{Thumbstick::RightThumbstickUp, VK_UP}, {Thumbstick::RightThumbstickDown, VK_DOWN},
{Thumbstick::RightThumbstickLeft, VK_LEFT}, {Thumbstick::RightThumbstickRight, VK_RIGHT}};
vgp_data_exchange_gamepad_reading parse_gamepad_state(const char *data, size_t len);
bool inject_gamepad_state(vgp_data_exchange_gamepad_reading reading);
3 changes: 2 additions & 1 deletion src/networking/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "../../VGP_Data_Exchange/C/Colfer.h"
#include "../../third-party-libs/QR-Code-generator/cpp/qrcodegen.hpp"
#include "../settings_key_variables.h"

#include <QByteArray>
#include <QDataStream>
Expand Down Expand Up @@ -73,7 +74,7 @@ Server::~Server()
void Server::initServer()
{
tcpServer->setListenBacklogSize(0);
if (!tcpServer->listen(QHostAddress::AnyIPv4, 7878))
if (!tcpServer->listen(QHostAddress::AnyIPv4, port))
{
QMessageBox::critical(this, tr("VGamepad Server"),
tr("Unable to start the server: %1.").arg(tcpServer->errorString()));
Expand Down
Loading