Added vcpkg and fixed Windows build.

This commit is contained in:
Arron David Nelson 2024-02-05 21:06:48 -08:00
parent 6b2f3e7247
commit 94ce3146c5
19 changed files with 93 additions and 50 deletions

View File

@ -23,7 +23,7 @@ jobs:
- name: Building/Compiling/Installing Project
run: |
cd ${{ gitea.workspace }}
cmake -DCMAKE_BUILD_TYPE=Release -DLINUX_WINDOW_SYSTEM:STRING=XCB .
cmake -A x64 -DCMAKE_BUILD_TYPE=Release -DLINUX_WINDOW_SYSTEM:STRING=XCB .
cmake --build . --config Release
cmake --install .
@ -65,7 +65,7 @@ jobs:
- name: Building/Compiling/Installing Project
run: |
cd ${{ gitea.workspace }}
cmake -DCMAKE_BUILD_TYPE=Release -DLINUX_WINDOW_SYSTEM:STRING=XCB .
cmake -A x64 -DCMAKE_BUILD_TYPE=Release -DLINUX_WINDOW_SYSTEM:STRING=XCB .
cmake --build . --config Release
cmake --install .

View File

@ -171,7 +171,6 @@ if (IS_OS_WINDOWS)
src/system/Mutex_W32.cpp include/ehs/system/Mutex_W32.h
src/system/Open_W32.cpp include/ehs/system/Open_W32.h
src/io/audio/audioDevice_W32.cpp include/ehs/io/audio/audioDevice_W32.h
src/io/MsgBox.cpp include/ehs/io/MsgBox.h
src/io/File_W32.cpp include/ehs/io/File_W32.h
src/io/FileMonitor_W32.cpp include/ehs/io/FileMonitor_W32.h
src/io/Window_W32.cpp include/ehs/io/Window_W32.h

12
CMakePresets.json Normal file
View File

@ -0,0 +1,12 @@
{
"version": 3,
"configurePresets": [
{
"name": "default",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}

View File

@ -13,7 +13,7 @@ namespace ehs
public:
Keyboard();
Keyboard(Str_8 name, const UInt_64 id);
Keyboard(Str_8 name, UInt_64 id);
Keyboard(Keyboard&& hid) noexcept = default;
@ -114,8 +114,8 @@ namespace ehs
static const Button Up;
static const Button Down;
static Button TranslateScanCode(const UInt_32 code);
static Button TranslateScanCode(UInt_32 code);
static Char_8 TranslateToEnglish_8(const bool shifted, const Button& button);
static Char_8 TranslateToEnglish_8(bool shifted, const Button& button);
};
}

View File

@ -22,7 +22,7 @@ namespace ehs
/// Default members initialization.
TCP();
TCP(const AddrType addrType);
TCP(AddrType addrType);
TCP(TCP&& tcp) noexcept;

View File

@ -41,7 +41,7 @@ namespace ehs
/// @param [in] address The local IPv4 or IPv6 address to bind to. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
/// @param [in] port The port to bind to.
/// @note Requires the port given to be forwarded if this is called.
void Bind(const Str_8& address, const UInt_16 port) override;
void Bind(AddrType type, const Str_8& address, UInt_16 port) override;
/// Sends data using a C-style byte array.
/// @param [in] addr The remote Ipv4 or Ipv6 address to send to. Resolves domain names. The given address can be empty, "127.0.0.1", or "localhost" to automatically find the appropriate device.
@ -49,7 +49,7 @@ namespace ehs
/// @param [in] data The C-style byte array to send.
/// @param [in] size The size of the C-style byte array.
/// @note The size of data to be sent cannot exceed "UDP::maxPayloadIpv4" or "UDP::maxPayloadIpv6".
UInt_64 Send(const Str_8& addr, const UInt_16 port, const Byte* const data, const UInt_64 size) override;
UInt_64 Send(AddrType type, const Str_8& addr, UInt_16 port, const Byte* data, UInt_64 size) override;
/// Receives data using the packet helper class.
/// @param [out] addr The Ipv4 or Ipv6 address of the sender.
@ -58,11 +58,11 @@ namespace ehs
/// @param [in] size The size of the pre-allocated C-style byte array.
/// @returns The size of the data received.
/// @warning The provided C-style byte array must be freed when finished using.
UInt_64 Receive(Str_8* const addr, UInt_16* const port, Byte* const data, const UInt_64 size) override;
UInt_64 Receive(AddrType* type, Str_8* addr, UInt_16* port, Byte* data, UInt_64 size) override;
/// Sets whether or not receiving data blocks the next task.
/// @param [in] blocking Whether or not to block.
void SetBlocking(const bool blocking) override;
void SetBlocking(bool blocking) override;
/// Retrieves whether or not this socket will block when receiving data.
/// @returns The result.
@ -71,12 +71,12 @@ namespace ehs
bool IsValid() const override;
private:
void Bind_v6(const Str_8& address, const UInt_16 port);
void Bind_v6(const Str_8& address, UInt_16 port);
void Bind_v4(const Str_8& address, const UInt_16 port);
void Bind_v4(const Str_8& address, UInt_16 port);
UInt_64 Send_v6(const Str_8& addr, const UInt_16 port, const Byte* const data, const UInt_64 size);
UInt_64 Send_v6(const Str_8& addr, UInt_16 port, const Byte* data, UInt_64 size);
UInt_64 Send_v4(const Str_8& addr, const UInt_16 port, const Byte* const data, const UInt_64 size);
UInt_64 Send_v4(const Str_8& addr, UInt_16 port, const Byte* data, UInt_64 size);
};
}

View File

@ -1,4 +1,4 @@
#include "io/COM.h"
#include "ehs/io/COM.h"
#include "ehs/Str.h"
#include "ehs/Log.h"

View File

@ -1,4 +1,4 @@
#include "io/FileMonitor_W32.h"
#include "ehs/io/FileMonitor_W32.h"
#include "ehs/Log.h"
#include "ehs/UTF.h"

View File

@ -1,4 +1,4 @@
#include "io/File_W32.h"
#include "ehs/io/File_W32.h"
namespace ehs
{

View File

@ -1,7 +1,7 @@
#include "io/Window_W32.h"
#include "io/hid/Keyboard.h"
#include "io/hid/Mouse.h"
#include "system/Thread.h"
#include "ehs/io/Window_W32.h"
#include "ehs/io/hid/Keyboard.h"
#include "ehs/io/hid/Mouse.h"
#include "ehs/system/Thread.h"
#include <hidusage.h>
@ -108,16 +108,16 @@ namespace ehs
if (!keyboard)
{
UInt_32 bufferSize;
GetRawInputDeviceInfo(hDevice, RIDI_DEVICENAME, NULL, &bufferSize);
GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICENAME, NULL, &bufferSize);
Char_16* deviceName = new Char_16[bufferSize];
if (GetRawInputDeviceInfo(hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
if (GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
{
EHS_LOG_INT("Error, 0, "Failed to retrieve device name.");
return;
EHS_LOG_INT("Error", 0, "Failed to retrieve device name.");
return 0;
}
keyboard = new Keyboard(UTF::To_8(deviceName, bufferSize), (UInt_64)raw->header.hDevice);
keyboard = new Keyboard(UTF::To_8(deviceName, (UInt_64)bufferSize), (UInt_64)raw->header.hDevice);
win->ih.AddDevice(keyboard);
}
@ -134,16 +134,16 @@ namespace ehs
if (!mouse)
{
UInt_32 bufferSize;
GetRawInputDeviceInfo(hDevice, RIDI_DEVICENAME, NULL, &bufferSize);
GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICENAME, nullptr, &bufferSize);
Char_16* deviceName = new Char_16[bufferSize];
if (GetRawInputDeviceInfo(hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
if (GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
{
EHS_LOG_INT("Error, 1, "Failed to retrieve device name.");
return;
EHS_LOG_INT("Error", 1, "Failed to retrieve device name.");
return 0;
}
mouse = new Mouse(UTF::To_8(deviceName, bufferSize), (UInt_64)raw->header.hDevice);
mouse = new Mouse(UTF::To_8(deviceName, (UInt_64)bufferSize), (UInt_64)raw->header.hDevice);
win->ih.AddDevice(mouse);
}
@ -172,9 +172,19 @@ namespace ehs
else if (code == RI_MOUSE_BUTTON_5_UP)
mouse->ButtonUp(Mouse::Five);
else if (code == RI_MOUSE_WHEEL)
mouse->SetScroll({mouse->GetScroll().x, (SInt_8)raw->data.mouse.usButtonData});
{
if (raw->data.mouse.usButtonData < 0)
mouse->ButtonDown(Mouse::ScrollDown);
else if (raw->data.mouse.usButtonData > 0)
mouse->ButtonDown(Mouse::ScrollUp);
}
else if (code == RI_MOUSE_HWHEEL)
mouse->SetScroll({(SInt_8)raw->data.mouse.usButtonData, mouse->GetScroll().y});
{
if (raw->data.mouse.usButtonData < 0)
mouse->ButtonDown(Mouse::ScrollLeft);
else if (raw->data.mouse.usButtonData > 0)
mouse->ButtonDown(Mouse::ScrollRight);
}
}
delete[] data;

View File

@ -1,4 +1,4 @@
#include "io/audio/AudioDevice_W32.h"
#include "ehs/io/audio/AudioDevice_W32.h"
#include "ehs/Log.h"
namespace ehs

View File

@ -1,5 +1,5 @@
#include "io/socket/TCP_W32.h"
#include "io/socket/DNS.h"
#include "ehs/io/socket/TCP_W32.h"
#include "ehs/io/socket/DNS.h"
#include <WinSock2.h>
#include <WS2tcpip.h>
@ -242,7 +242,7 @@ namespace ehs
return;
remoteHostName = address;
remoteAddr = DNS::Resolve(addrType, address);
remoteAddr = DNS::Resolve(address);
remotePort = port;
if (addrType == AddrType::IPV6)

View File

@ -1,4 +1,4 @@
#include "io/socket/UDP_W32.h"
#include "ehs/io/socket/UDP_W32.h"
#include "ehs/Log.h"
#include <WinSock2.h>
@ -110,14 +110,14 @@ namespace ehs
bound = false;
}
void UDP::Bind(const Str_8& address, const UInt_16 port)
void UDP::Bind(const AddrType type, const Str_8& address, const UInt_16 port)
{
if (!IsValid() || bound)
return;
if (addrType == AddrType::IPV6)
if (type == AddrType::IPV6)
Bind_v6(address, port);
else if (addrType == AddrType::IPV4)
else if (type == AddrType::IPV4)
Bind_v4(address, port);
this->address = address;
@ -126,17 +126,17 @@ namespace ehs
bound = true;
}
UInt_64 UDP::Send(const Str_8& address, const UInt_16 port, const Byte *const data, const UInt_64 size)
UInt_64 UDP::Send(const AddrType type, const Str_8& address, const UInt_16 port, const Byte *const data, const UInt_64 size)
{
if (addrType == AddrType::IPV6)
if (type == AddrType::IPV6)
return Send_v6(address, port, data, size);
else if (addrType == AddrType::IPV4)
else if (type == AddrType::IPV4)
return Send_v4(address, port, data, size);
return 0;
}
UInt_64 UDP::Receive(Str_8* const address, UInt_16* const port, Byte* const data, const UInt_64 size)
UInt_64 UDP::Receive(AddrType* type, Str_8* const address, UInt_16* const port, Byte* const data, const UInt_64 size)
{
if (!IsValid())
{
@ -174,6 +174,7 @@ namespace ehs
return received;
}
*type = AddrType::IPV6;
*address = tmpAddr;
*port = ntohs(remote.sin6_port);
}
@ -190,6 +191,7 @@ namespace ehs
return received;
}
*type = AddrType::IPV4;
*address = tmpAddr;
*port = ntohs(((sockaddr_in*)&remote)->sin_port);
}

View File

@ -1,4 +1,4 @@
#include "system/Mutex_W32.h"
#include "ehs/system/Mutex_W32.h"
#include "ehs/Str.h"
#include "ehs/Log.h"

View File

@ -1,4 +1,4 @@
#include "system/Open_W32.h"
#include "ehs/system/Open_W32.h"
namespace ehs
{

View File

@ -1,4 +1,4 @@
#include "system/Semaphore_W32.h"
#include "ehs/system/Semaphore_W32.h"
#include "ehs/UTF.h"
#include "ehs/Log.h"

View File

@ -1,4 +1,4 @@
#include "system/System_W32.h"
#include "ehs/system/System_W32.h"
#include <shellapi.h>

14
vcpkg-configuration.json Normal file
View File

@ -0,0 +1,14 @@
{
"default-registry": {
"kind": "git",
"baseline": "42bb0d9e8d4cf33485afb9ee2229150f79f61a1f",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
"name": "microsoft"
}
]
}

6
vcpkg.json Normal file
View File

@ -0,0 +1,6 @@
{
"dependencies": [
"openssl",
"zlib"
]
}