Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
64e1555d56 | |||
a65c8d64b5 | |||
fa2b801690 | |||
4e887b1ac2 | |||
126fc92fae | |||
2ef28273b0 | |||
04bf7d43ff | |||
fb86dca332 | |||
7e380efd7d | |||
b5e05864b6 | |||
e2e5a1b8db | |||
2a2296685e |
@@ -122,7 +122,7 @@ set(EHS_SOURCES
|
||||
|
||||
src/io/socket/Request.cpp include/ehs/io/socket/Request.h
|
||||
src/io/socket/Response.cpp include/ehs/io/socket/Response.h
|
||||
src/io/socket/DNS.cpp include/ehs/io/socket/DNS.h
|
||||
src/io/socket/BaseDNS.cpp include/ehs/io/socket/BaseDNS.h
|
||||
src/io/socket/BaseUDP.cpp include/ehs/io/socket/BaseUDP.h
|
||||
src/io/socket/BaseTCP.cpp include/ehs/io/socket/BaseTCP.h
|
||||
src/io/socket/SSL.cpp include/ehs/io/socket/SSL.h
|
||||
@@ -133,6 +133,7 @@ set(EHS_SOURCES
|
||||
include/ehs/io/socket/Socket.h
|
||||
include/ehs/io/socket/TCP.h
|
||||
include/ehs/io/socket/UDP.h
|
||||
include/ehs/io/socket/DNS.h
|
||||
|
||||
src/io/audio/Audio.cpp include/ehs/io/audio/Audio.h
|
||||
src/io/audio/BaseAudioDevice.cpp include/ehs/io/audio/BaseAudioDevice.h
|
||||
@@ -164,8 +165,6 @@ set(EHS_SOURCES
|
||||
include/ehs/io/mdl/MdlCodec.h
|
||||
include/ehs/io/UsbBase.h
|
||||
src/io/UsbBase.cpp
|
||||
include/ehs/io/Usb_LNX.h
|
||||
src/io/Usb_LNX.cpp
|
||||
include/ehs/db/DbTable.h
|
||||
include/ehs/db/DbObject.h
|
||||
include/ehs/db/DbVar.h
|
||||
@@ -177,8 +176,6 @@ set(EHS_SOURCES
|
||||
src/db/DbTable.cpp
|
||||
include/ehs/io/BaseDirectory.h
|
||||
src/io/BaseDirectory.cpp
|
||||
include/ehs/io/Directory_LNX.h
|
||||
src/io/Directory_LNX.cpp
|
||||
include/ehs/io/Directory.h
|
||||
)
|
||||
|
||||
@@ -186,6 +183,7 @@ if (IS_OS_WINDOWS)
|
||||
list(APPEND EHS_SOURCES
|
||||
src/io/socket/UDP_W32.cpp include/ehs/io/socket/UDP_W32.h
|
||||
src/io/socket/TCP_W32.cpp include/ehs/io/socket/TCP_W32.h
|
||||
src/io/socket/DNS_W32.cpp include/ehs/io/socket/DNS_W32.h
|
||||
src/system/Semaphore_W32.cpp include/ehs/system/Semaphore_W32.h
|
||||
src/system/System_W32.cpp include/ehs/system/System_W32.h
|
||||
src/system/Mutex_W32.cpp include/ehs/system/Mutex_W32.h
|
||||
@@ -196,11 +194,13 @@ if (IS_OS_WINDOWS)
|
||||
src/io/Window_W32.cpp include/ehs/io/Window_W32.h
|
||||
src/io/COM.cpp include/ehs/io/COM.h
|
||||
src/system/CPU_MSVC_AMD64.asm src/HRNG_MSVC.asm src/Math_MSVC_AMD64.asm
|
||||
src/io/Directory_W32.cpp include/ehs/io/Directory_W32.h
|
||||
)
|
||||
elseif (IS_OS_LINUX)
|
||||
list(APPEND EHS_SOURCES
|
||||
src/io/socket/UDP_BSD.cpp include/ehs/io/socket/UDP_BSD.h
|
||||
src/io/socket/TCP_BSD.cpp include/ehs/io/socket/TCP_BSD.h
|
||||
src/io/socket/DNS_LNX.cpp include/ehs/io/socket/DNS_LNX.h
|
||||
src/system/Semaphore_P.cpp include/ehs/system/Semaphore_P.h
|
||||
src/system/System_LNX.cpp include/ehs/system/System_LNX.h
|
||||
src/system/Open_UNX.cpp include/ehs/system/Open_UNX.h
|
||||
@@ -210,13 +210,18 @@ elseif (IS_OS_LINUX)
|
||||
src/io/audio/AudioDevice_ALSA.cpp include/ehs/io/audio/AudioDevice_ALSA.h
|
||||
src/system/FileSystem.cpp include/ehs/system/FileSystem.h
|
||||
src/system/User.cpp include/ehs/system/User.h
|
||||
src/io/Directory_LNX.cpp include/ehs/io/Directory_LNX.h
|
||||
src/io/Usb_LNX.cpp include/ehs/io/Usb_LNX.h
|
||||
)
|
||||
|
||||
set(LINUX_WINDOW_SYSTEM "Wayland" CACHE STRING "Linux Window System")
|
||||
|
||||
if (LINUX_WINDOW_SYSTEM STREQUAL "Wayland")
|
||||
add_compile_definitions(EHS_WS_WAYLAND)
|
||||
list(APPEND EHS_SOURCES src/io/xdg-shell-protocol.c include/ehs/io/xdg-shell-client-protocol.h src/io/Window_Way.cpp include/ehs/io/Window_Way.h)
|
||||
list(APPEND EHS_SOURCES
|
||||
src/io/xdg-shell-protocol.c include/ehs/io/xdg-shell-client-protocol.h
|
||||
src/io/xdg-decoration.c include/ehs/io/xdg-decoration.h
|
||||
src/io/Window_Way.cpp include/ehs/io/Window_Way.h)
|
||||
message("Building for Wayland.")
|
||||
elseif (LINUX_WINDOW_SYSTEM STREQUAL "XCB")
|
||||
add_compile_definitions(EHS_WS_XCB)
|
||||
|
@@ -8,6 +8,7 @@ This project does not fully follow the C++ standard.
|
||||
### Features
|
||||
- Audio IO/Processing/Manipulation
|
||||
- Image Processing/Manipulation
|
||||
- Databases
|
||||
- 3D Model & Mesh Processing/Manipulation
|
||||
- File IO
|
||||
- Basic File Monitoring
|
||||
@@ -20,7 +21,7 @@ This project does not fully follow the C++ standard.
|
||||
- Mutexes
|
||||
- Semaphores
|
||||
- CPU information and features at runtime
|
||||
- HTTP(S) Sockets
|
||||
- HTTP(S) Socket Layer
|
||||
- TCP Socket
|
||||
- UDP Socket
|
||||
- COM (Serial) IO
|
||||
@@ -29,12 +30,13 @@ This project does not fully follow the C++ standard.
|
||||
- Twitch Integration
|
||||
- Json Parsing/Writing
|
||||
- User Friendly HID Input
|
||||
- Basic Garbage Collector
|
||||
- Heap Garbage Collector
|
||||
- Linked List
|
||||
- Array
|
||||
- Vector
|
||||
- Asynchronous Task System
|
||||
- URI Parsing
|
||||
- USB (WIP)
|
||||
|
||||
### Supported Architectures
|
||||
- AMD64
|
||||
|
@@ -36,7 +36,7 @@ namespace ehs
|
||||
|
||||
/// Sets the maximum amount of garbage to delete per poll.
|
||||
/// @param[in] newMax The new maximum.
|
||||
static void SetMax(const UInt_64 newMax);
|
||||
static void SetMax(UInt_64 newMax);
|
||||
|
||||
/// Gets the maximum amount of garbage to delete per poll.
|
||||
/// @returns The maximum.
|
||||
@@ -44,7 +44,7 @@ namespace ehs
|
||||
|
||||
/// Sets a new amount for memory pre-allocation to save on memory operations.
|
||||
/// @param[in] newStride The stride to pre-allocate.
|
||||
static void SetStride(const UInt_64 newStride);
|
||||
static void SetStride(UInt_64 newStride);
|
||||
|
||||
/// The amount of data pre-allocated to save on memory operations.
|
||||
/// @returns The stride.
|
||||
|
@@ -1888,11 +1888,7 @@ namespace ehs
|
||||
if (aSize != bSize)
|
||||
return false;
|
||||
|
||||
for (UInt_64 i = 0; i < aSize; ++i)
|
||||
if (a[i] != b[i])
|
||||
return false;
|
||||
|
||||
return true;
|
||||
return Util::Compare(a, b, aSize);
|
||||
}
|
||||
};
|
||||
|
||||
|
@@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
#include "ehs/Vec2.h"
|
||||
#include "ehs/Rect.h"
|
||||
#include "ehs/io/hid/Input.h"
|
||||
|
||||
namespace ehs
|
||||
@@ -60,10 +58,6 @@ namespace ehs
|
||||
|
||||
bool HasFocus() const;
|
||||
|
||||
void EnableResizing(bool enable);
|
||||
|
||||
bool IsResizable() const;
|
||||
|
||||
/// Gets the cursors position on the desktop in pixels.
|
||||
/// @param [in] relative Whether the position should be relative to the windows client.
|
||||
/// @returns The current value.
|
||||
|
16
include/ehs/io/Directory_W32.h
Normal file
16
include/ehs/io/Directory_W32.h
Normal file
@@ -0,0 +1,16 @@
|
||||
#pragma once
|
||||
|
||||
#include "BaseDirectory.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class Directory : public BaseDirectory
|
||||
{
|
||||
public:
|
||||
static Array<Str_8> GetAllFiles(const Str_8 &dir);
|
||||
|
||||
static void CreateRecursive(Str_8 dir);
|
||||
|
||||
static void Create(const Str_8 &dir);
|
||||
};
|
||||
}
|
@@ -4,21 +4,27 @@
|
||||
|
||||
#include <wayland-client.h>
|
||||
#include "xdg-shell-client-protocol.h"
|
||||
#include "xdg-decoration.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class Window : public BaseWindow
|
||||
{
|
||||
private:
|
||||
protected:
|
||||
wl_display *display;
|
||||
wl_registry *registry;
|
||||
wl_compositor *compositor;
|
||||
wl_surface* surface;
|
||||
wl_surface *wlSurface;
|
||||
xdg_wm_base *xdgShell;
|
||||
xdg_surface *xdgSurface;
|
||||
xdg_toplevel *xdgToplevel;
|
||||
zxdg_decoration_manager_v1 *decManager;
|
||||
zxdg_toplevel_decoration_v1 *dec;
|
||||
wl_seat *seat;
|
||||
wl_pointer *pointer;
|
||||
Vec2_u32 scale;
|
||||
|
||||
static void SurfaceConfigure(void *data, xdg_surface *xdg_surface, UInt_32 serial);
|
||||
static void SurfaceConfigEvent(void *data, xdg_surface *xdg_surface, UInt_32 serial);
|
||||
|
||||
static void ShellPing(void *data, xdg_wm_base *shell, UInt_32 serial);
|
||||
|
||||
@@ -26,16 +32,32 @@ namespace ehs
|
||||
|
||||
static void RegistryRemoved(void *data, wl_registry *registry, UInt_32 id);
|
||||
|
||||
static void ResizeEvent(void *data, xdg_toplevel *xdg_toplevel, Int_32 width, Int_32 height, wl_array *states);
|
||||
|
||||
static void CloseEvent(void *data, xdg_toplevel *xdg_toplevel);
|
||||
|
||||
static void SeatCapabilitiesEvent(void *data, wl_seat *seat, UInt_32 capabilities);
|
||||
|
||||
static void PointerMotionEvent(void *data, wl_pointer *pointer, UInt_32 time, wl_fixed_t sx, wl_fixed_t sy);
|
||||
|
||||
public:
|
||||
~Window() override;
|
||||
|
||||
Window();
|
||||
|
||||
void Create_32(const Str_32& title, const Vec2_s32& pos, const Vec2_u32 scale) override;
|
||||
Window(Window &&win) noexcept;
|
||||
|
||||
void Create_16(const Str_16& title, const Vec2_s32& pos, const Vec2_u32 scale) override;
|
||||
Window(const Window &win);
|
||||
|
||||
void Create_8(const Str_8& title, const Vec2_s32& pos, const Vec2_u32 scale) override;
|
||||
Window &operator=(Window &&win) noexcept;
|
||||
|
||||
Window &operator=(const Window &win);
|
||||
|
||||
void Create_32(const Str_32& title, const Vec2_s32& pos, Vec2_u32 scale) override;
|
||||
|
||||
void Create_16(const Str_16& title, const Vec2_s32& pos, Vec2_u32 scale) override;
|
||||
|
||||
void Create_8(const Str_8& title, const Vec2_s32& pos, Vec2_u32 scale) override;
|
||||
|
||||
void OnCreated() override;
|
||||
|
||||
|
18
include/ehs/io/socket/BaseDNS.h
Normal file
18
include/ehs/io/socket/BaseDNS.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "Socket.h"
|
||||
#include "ehs/Str.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class BaseDNS
|
||||
{
|
||||
public:
|
||||
static Str_8 Resolve(AddrType type, const Str_8 &hostname);
|
||||
|
||||
/// Resolves a hostname to an ip address.
|
||||
/// @param [in] hostname The given hostname to resolve.
|
||||
/// @returns The resulting ip address.
|
||||
static Str_8 Resolve(const Str_8 &hostname);
|
||||
};
|
||||
}
|
@@ -146,6 +146,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
virtual bool IsBlocking() const = 0;
|
||||
|
||||
virtual void SetIPv6Only(bool value) = 0;
|
||||
|
||||
virtual bool IsIPv6Only() const = 0;
|
||||
|
||||
/// Retrieves whether or not this socket was initialized.
|
||||
/// @returns The result.
|
||||
virtual bool IsValid() const = 0;
|
||||
|
@@ -69,6 +69,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
virtual bool IsBlocking() const = 0;
|
||||
|
||||
virtual void SetIPv6Only(bool value) = 0;
|
||||
|
||||
virtual bool IsIPv6Only() const = 0;
|
||||
|
||||
/// Retrieves the bound ip version.
|
||||
/// @returns The result.
|
||||
AddrType GetLocalAddressType() const;
|
||||
|
@@ -1,17 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
#include "Socket.h"
|
||||
#include "ehs/system/OS.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class DNS
|
||||
{
|
||||
public:
|
||||
/// Resolves a hostname to an ip address.
|
||||
/// @param [in] hostname The given hostname to resolve.
|
||||
/// @returns The resulting ip address.
|
||||
static Str_8 Resolve(const Str_8& hostname);
|
||||
};
|
||||
}
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
#include "DNS_W32.h"
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
#include "DNS_LNX.h"
|
||||
#endif
|
17
include/ehs/io/socket/DNS_LNX.h
Normal file
17
include/ehs/io/socket/DNS_LNX.h
Normal file
@@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
#include "BaseDNS.h"
|
||||
#include "ehs/EHS.h"
|
||||
#include "ehs/Str.h"
|
||||
#include "Socket.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class DNS final : public BaseDNS
|
||||
{
|
||||
public:
|
||||
static Str_8 Resolve(AddrType type, const Str_8 &hostname);
|
||||
|
||||
static Str_8 Resolve(const Str_8 &hostname);
|
||||
};
|
||||
}
|
14
include/ehs/io/socket/DNS_W32.h
Normal file
14
include/ehs/io/socket/DNS_W32.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "BaseDNS.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
class DNS final : public BaseDNS
|
||||
{
|
||||
public:
|
||||
static Str_8 Resolve(AddrType type, const Str_8 &hostname);
|
||||
|
||||
static Str_8 Resolve(const Str_8 &hostname);
|
||||
};
|
||||
}
|
@@ -80,6 +80,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
bool IsBlocking() const override;
|
||||
|
||||
void SetIPv6Only(bool value) override;
|
||||
|
||||
bool IsIPv6Only() const override;
|
||||
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
|
@@ -80,6 +80,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
bool IsBlocking() const override;
|
||||
|
||||
void SetIPv6Only(bool value) override;
|
||||
|
||||
bool IsIPv6Only() const override;
|
||||
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
|
@@ -68,6 +68,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
bool IsBlocking() const override;
|
||||
|
||||
void SetIPv6Only(bool value) override;
|
||||
|
||||
bool IsIPv6Only() const override;
|
||||
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
|
@@ -68,6 +68,10 @@ namespace ehs
|
||||
/// @returns The result.
|
||||
bool IsBlocking() const override;
|
||||
|
||||
void SetIPv6Only(bool value) override;
|
||||
|
||||
bool IsIPv6Only() const override;
|
||||
|
||||
bool IsValid() const override;
|
||||
|
||||
private:
|
||||
|
@@ -21,7 +21,7 @@ namespace ehs
|
||||
Str_8 id;
|
||||
};
|
||||
|
||||
class Spotify
|
||||
class Spotify final
|
||||
{
|
||||
private:
|
||||
SSL client;
|
||||
@@ -40,14 +40,14 @@ namespace ehs
|
||||
|
||||
Spotify();
|
||||
|
||||
Spotify(const Str_8& clientId, const Str_8& secret, const Str_8& redURI, const Array<Str_8>& scopes, const bool forceVerify);
|
||||
Spotify(Str_8 clientId, Str_8 secret, Str_8 redURI, Array<Str_8> scopes, bool forceVerify);
|
||||
|
||||
bool Authorize();
|
||||
|
||||
/// Sets the volume for a device.
|
||||
/// @param [in] level The percentage to set the volume to.
|
||||
/// @returns The response code.
|
||||
UInt_32 SetVolume(const UInt_8 level);
|
||||
UInt_32 SetVolume(UInt_8 level);
|
||||
|
||||
/// Resume playback for a device.
|
||||
/// @returns The response code.
|
||||
@@ -60,12 +60,12 @@ namespace ehs
|
||||
/// Repeats playback for a device.
|
||||
/// @param [in] status The status to set it to.
|
||||
/// @returns The response code.
|
||||
UInt_32 SetRepeat(const SpotifyState state);
|
||||
UInt_32 SetRepeat(SpotifyState state);
|
||||
|
||||
/// Shuffles playback for a device.
|
||||
/// @param [in] state The state to set shuffle to.
|
||||
/// @returns The response code.
|
||||
UInt_32 SetShuffle(const bool state);
|
||||
UInt_32 SetShuffle(bool state);
|
||||
|
||||
UInt_32 SearchTrack(Vector<Str_8>& artists, Str_8& id, Str_8& name);
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace ehs
|
||||
/// Seeks to a position of the currently playing track in milliseconds.
|
||||
/// @param [in] pos The position in milliseconds to seek to.
|
||||
/// @returns The response code.
|
||||
UInt_32 Seek(const UInt_32 pos);
|
||||
UInt_32 Seek(UInt_32 pos);
|
||||
|
||||
Str_8 GetClientId() const;
|
||||
|
||||
|
377
include/ehs/io/xdg-decoration.h
Normal file
377
include/ehs/io/xdg-decoration.h
Normal file
@@ -0,0 +1,377 @@
|
||||
/* Generated by wayland-scanner 1.23.0 */
|
||||
|
||||
#ifndef XDG_DECORATION_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
#define XDG_DECORATION_UNSTABLE_V1_CLIENT_PROTOCOL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "wayland-client.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @page page_xdg_decoration_unstable_v1 The xdg_decoration_unstable_v1 protocol
|
||||
* @section page_ifaces_xdg_decoration_unstable_v1 Interfaces
|
||||
* - @subpage page_iface_zxdg_decoration_manager_v1 - window decoration manager
|
||||
* - @subpage page_iface_zxdg_toplevel_decoration_v1 - decoration object for a toplevel surface
|
||||
* @section page_copyright_xdg_decoration_unstable_v1 Copyright
|
||||
* <pre>
|
||||
*
|
||||
* Copyright © 2018 Simon Ser
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
* </pre>
|
||||
*/
|
||||
struct xdg_toplevel;
|
||||
struct zxdg_decoration_manager_v1;
|
||||
struct zxdg_toplevel_decoration_v1;
|
||||
|
||||
#ifndef ZXDG_DECORATION_MANAGER_V1_INTERFACE
|
||||
#define ZXDG_DECORATION_MANAGER_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zxdg_decoration_manager_v1 zxdg_decoration_manager_v1
|
||||
* @section page_iface_zxdg_decoration_manager_v1_desc Description
|
||||
*
|
||||
* This interface allows a compositor to announce support for server-side
|
||||
* decorations.
|
||||
*
|
||||
* A window decoration is a set of window controls as deemed appropriate by
|
||||
* the party managing them, such as user interface components used to move,
|
||||
* resize and change a window's state.
|
||||
*
|
||||
* A client can use this protocol to request being decorated by a supporting
|
||||
* compositor.
|
||||
*
|
||||
* If compositor and client do not negotiate the use of a server-side
|
||||
* decoration using this protocol, clients continue to self-decorate as they
|
||||
* see fit.
|
||||
*
|
||||
* Warning! The protocol described in this file is experimental and
|
||||
* backward incompatible changes may be made. Backward compatible changes
|
||||
* may be added together with the corresponding interface version bump.
|
||||
* Backward incompatible changes are done by bumping the version number in
|
||||
* the protocol and interface names and resetting the interface version.
|
||||
* Once the protocol is to be declared stable, the 'z' prefix and the
|
||||
* version number in the protocol and interface names are removed and the
|
||||
* interface version number is reset.
|
||||
* @section page_iface_zxdg_decoration_manager_v1_api API
|
||||
* See @ref iface_zxdg_decoration_manager_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zxdg_decoration_manager_v1 The zxdg_decoration_manager_v1 interface
|
||||
*
|
||||
* This interface allows a compositor to announce support for server-side
|
||||
* decorations.
|
||||
*
|
||||
* A window decoration is a set of window controls as deemed appropriate by
|
||||
* the party managing them, such as user interface components used to move,
|
||||
* resize and change a window's state.
|
||||
*
|
||||
* A client can use this protocol to request being decorated by a supporting
|
||||
* compositor.
|
||||
*
|
||||
* If compositor and client do not negotiate the use of a server-side
|
||||
* decoration using this protocol, clients continue to self-decorate as they
|
||||
* see fit.
|
||||
*
|
||||
* Warning! The protocol described in this file is experimental and
|
||||
* backward incompatible changes may be made. Backward compatible changes
|
||||
* may be added together with the corresponding interface version bump.
|
||||
* Backward incompatible changes are done by bumping the version number in
|
||||
* the protocol and interface names and resetting the interface version.
|
||||
* Once the protocol is to be declared stable, the 'z' prefix and the
|
||||
* version number in the protocol and interface names are removed and the
|
||||
* interface version number is reset.
|
||||
*/
|
||||
extern const struct wl_interface zxdg_decoration_manager_v1_interface;
|
||||
#endif
|
||||
#ifndef ZXDG_TOPLEVEL_DECORATION_V1_INTERFACE
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_INTERFACE
|
||||
/**
|
||||
* @page page_iface_zxdg_toplevel_decoration_v1 zxdg_toplevel_decoration_v1
|
||||
* @section page_iface_zxdg_toplevel_decoration_v1_desc Description
|
||||
*
|
||||
* The decoration object allows the compositor to toggle server-side window
|
||||
* decorations for a toplevel surface. The client can request to switch to
|
||||
* another mode.
|
||||
*
|
||||
* The xdg_toplevel_decoration object must be destroyed before its
|
||||
* xdg_toplevel.
|
||||
* @section page_iface_zxdg_toplevel_decoration_v1_api API
|
||||
* See @ref iface_zxdg_toplevel_decoration_v1.
|
||||
*/
|
||||
/**
|
||||
* @defgroup iface_zxdg_toplevel_decoration_v1 The zxdg_toplevel_decoration_v1 interface
|
||||
*
|
||||
* The decoration object allows the compositor to toggle server-side window
|
||||
* decorations for a toplevel surface. The client can request to switch to
|
||||
* another mode.
|
||||
*
|
||||
* The xdg_toplevel_decoration object must be destroyed before its
|
||||
* xdg_toplevel.
|
||||
*/
|
||||
extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
|
||||
#endif
|
||||
|
||||
#define ZXDG_DECORATION_MANAGER_V1_DESTROY 0
|
||||
#define ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION 1
|
||||
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*/
|
||||
#define ZXDG_DECORATION_MANAGER_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*/
|
||||
#define ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zxdg_decoration_manager_v1 */
|
||||
static inline void
|
||||
zxdg_decoration_manager_v1_set_user_data(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zxdg_decoration_manager_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zxdg_decoration_manager_v1 */
|
||||
static inline void *
|
||||
zxdg_decoration_manager_v1_get_user_data(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_decoration_manager_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zxdg_decoration_manager_v1_get_version(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*
|
||||
* Destroy the decoration manager. This doesn't destroy objects created
|
||||
* with the manager.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_decoration_manager_v1_destroy(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_decoration_manager_v1,
|
||||
ZXDG_DECORATION_MANAGER_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_decoration_manager_v1
|
||||
*
|
||||
* Create a new decoration object associated with the given toplevel.
|
||||
*
|
||||
* Creating an xdg_toplevel_decoration from an xdg_toplevel which has a
|
||||
* buffer attached or committed is a client error, and any attempts by a
|
||||
* client to attach or manipulate a buffer prior to the first
|
||||
* xdg_toplevel_decoration.configure event must also be treated as
|
||||
* errors.
|
||||
*/
|
||||
static inline struct zxdg_toplevel_decoration_v1 *
|
||||
zxdg_decoration_manager_v1_get_toplevel_decoration(struct zxdg_decoration_manager_v1 *zxdg_decoration_manager_v1, struct xdg_toplevel *toplevel)
|
||||
{
|
||||
struct wl_proxy *id;
|
||||
|
||||
id = wl_proxy_marshal_flags((struct wl_proxy *) zxdg_decoration_manager_v1,
|
||||
ZXDG_DECORATION_MANAGER_V1_GET_TOPLEVEL_DECORATION, &zxdg_toplevel_decoration_v1_interface, wl_proxy_get_version((struct wl_proxy *) zxdg_decoration_manager_v1), 0, NULL, toplevel);
|
||||
|
||||
return (struct zxdg_toplevel_decoration_v1 *) id;
|
||||
}
|
||||
|
||||
#ifndef ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM
|
||||
enum zxdg_toplevel_decoration_v1_error {
|
||||
/**
|
||||
* xdg_toplevel has a buffer attached before configure
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_UNCONFIGURED_BUFFER = 0,
|
||||
/**
|
||||
* xdg_toplevel already has a decoration object
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ALREADY_CONSTRUCTED = 1,
|
||||
/**
|
||||
* xdg_toplevel destroyed before the decoration object
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ORPHANED = 2,
|
||||
};
|
||||
#endif /* ZXDG_TOPLEVEL_DECORATION_V1_ERROR_ENUM */
|
||||
|
||||
#ifndef ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
* window decoration modes
|
||||
*
|
||||
* These values describe window decoration modes.
|
||||
*/
|
||||
enum zxdg_toplevel_decoration_v1_mode {
|
||||
/**
|
||||
* no server-side window decoration
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_CLIENT_SIDE = 1,
|
||||
/**
|
||||
* server-side window decoration
|
||||
*/
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE = 2,
|
||||
};
|
||||
#endif /* ZXDG_TOPLEVEL_DECORATION_V1_MODE_ENUM */
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
* @struct zxdg_toplevel_decoration_v1_listener
|
||||
*/
|
||||
struct zxdg_toplevel_decoration_v1_listener {
|
||||
/**
|
||||
* notify a decoration mode change
|
||||
*
|
||||
* The configure event configures the effective decoration mode.
|
||||
* The configured state should not be applied immediately. Clients
|
||||
* must send an ack_configure in response to this event. See
|
||||
* xdg_surface.configure and xdg_surface.ack_configure for details.
|
||||
*
|
||||
* A configure event can be sent at any time. The specified mode
|
||||
* must be obeyed by the client.
|
||||
* @param mode the decoration mode
|
||||
*/
|
||||
void (*configure)(void *data,
|
||||
struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
|
||||
uint32_t mode);
|
||||
};
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
static inline int
|
||||
zxdg_toplevel_decoration_v1_add_listener(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1,
|
||||
const struct zxdg_toplevel_decoration_v1_listener *listener, void *data)
|
||||
{
|
||||
return wl_proxy_add_listener((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
(void (**)(void)) listener, data);
|
||||
}
|
||||
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_DESTROY 0
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE 1
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE 2
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_CONFIGURE_SINCE_VERSION 1
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_DESTROY_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE_SINCE_VERSION 1
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*/
|
||||
#define ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE_SINCE_VERSION 1
|
||||
|
||||
/** @ingroup iface_zxdg_toplevel_decoration_v1 */
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_set_user_data(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, void *user_data)
|
||||
{
|
||||
wl_proxy_set_user_data((struct wl_proxy *) zxdg_toplevel_decoration_v1, user_data);
|
||||
}
|
||||
|
||||
/** @ingroup iface_zxdg_toplevel_decoration_v1 */
|
||||
static inline void *
|
||||
zxdg_toplevel_decoration_v1_get_user_data(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
return wl_proxy_get_user_data((struct wl_proxy *) zxdg_toplevel_decoration_v1);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
zxdg_toplevel_decoration_v1_get_version(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
return wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*
|
||||
* Switch back to a mode without any server-side decorations at the next
|
||||
* commit.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_destroy(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_DESTROY, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), WL_MARSHAL_FLAG_DESTROY);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*
|
||||
* Set the toplevel surface decoration mode. This informs the compositor
|
||||
* that the client prefers the provided decoration mode.
|
||||
*
|
||||
* After requesting a decoration mode, the compositor will respond by
|
||||
* emitting an xdg_surface.configure event. The client should then update
|
||||
* its content, drawing it without decorations if the received mode is
|
||||
* server-side decorations. The client must also acknowledge the configure
|
||||
* when committing the new content (see xdg_surface.ack_configure).
|
||||
*
|
||||
* The compositor can decide not to use the client's mode and enforce a
|
||||
* different mode instead.
|
||||
*
|
||||
* Clients whose decoration mode depend on the xdg_toplevel state may send
|
||||
* a set_mode request in response to an xdg_surface.configure event and wait
|
||||
* for the next xdg_surface.configure event to prevent unwanted state.
|
||||
* Such clients are responsible for preventing configure loops and must
|
||||
* make sure not to send multiple successive set_mode requests with the
|
||||
* same decoration mode.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_set_mode(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1, uint32_t mode)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_SET_MODE, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), 0, mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup iface_zxdg_toplevel_decoration_v1
|
||||
*
|
||||
* Unset the toplevel surface decoration mode. This informs the compositor
|
||||
* that the client doesn't prefer a particular decoration mode.
|
||||
*
|
||||
* This request has the same semantics as set_mode.
|
||||
*/
|
||||
static inline void
|
||||
zxdg_toplevel_decoration_v1_unset_mode(struct zxdg_toplevel_decoration_v1 *zxdg_toplevel_decoration_v1)
|
||||
{
|
||||
wl_proxy_marshal_flags((struct wl_proxy *) zxdg_toplevel_decoration_v1,
|
||||
ZXDG_TOPLEVEL_DECORATION_V1_UNSET_MODE, NULL, wl_proxy_get_version((struct wl_proxy *) zxdg_toplevel_decoration_v1), 0);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@@ -13,14 +13,14 @@ namespace ehs
|
||||
|
||||
if (!dir.Size())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 2, "The given directory was empty.");
|
||||
EHS_LOG_INT(LogType::WARN, 1, "The given directory was empty.");
|
||||
return result;
|
||||
}
|
||||
|
||||
DIR* hdl = opendir(dir);
|
||||
if (!hdl)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to open directory, \"" + dir + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to open directory, \"" + dir + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace ehs
|
||||
|
||||
if (closedir(hdl) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 4, "Failed to close directory, \"" + dir + "\".");
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to close directory, \"" + dir + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
87
src/io/Directory_W32.cpp
Normal file
87
src/io/Directory_W32.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
#include "ehs/io/Directory_W32.h"
|
||||
#include "ehs/UTF.h"
|
||||
#include "ehs/Log.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
Array<Str_8> GetAllFiles(const Str_8 &dir)
|
||||
{
|
||||
Array<Str_8> result;
|
||||
|
||||
if (!dir.Size())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "The given directory was empty.");
|
||||
return result;
|
||||
}
|
||||
|
||||
WIN32_FIND_DATAW fData;
|
||||
HANDLE hFind = FindFirstFileW(UTF::To_16(dir) + L"\\*", &fData);
|
||||
|
||||
if (hFind == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to open directory, \"" + dir + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
Str_8 fName = UTF::To_8(fData.cFileName);
|
||||
if (fName == "." || fName == "..")
|
||||
continue;
|
||||
|
||||
result.Push(fName);
|
||||
}
|
||||
while (FindNextFileW(hFind, &fData) != 0);
|
||||
|
||||
if (!FindClose(hFind))
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 3, "Failed to close directory, \"" + dir + "\".");
|
||||
return result;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void CreateRecursive(Str_8 dir)
|
||||
{
|
||||
dir = dir.ReplaceAll("\\", "/");
|
||||
|
||||
const Vector<Str_8> dirs = dir.Split("/");
|
||||
|
||||
for (UInt_64 i = 0; i < dirs.Size(); ++i)
|
||||
{
|
||||
const Str_8 final = (Str_8&&)dirs[i];
|
||||
for (UInt_64 x = 0; x < i; ++x)
|
||||
dirs[i] += dirs[x] + "/";
|
||||
|
||||
dirs[i] += final;
|
||||
|
||||
if (!CreateDirectoryW(UTF::To_16(dirs[i]), nullptr))
|
||||
{
|
||||
if (const DWORD code = GetLastError(); code != ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create directory, \"" + dirs[i] + "\" with error #" + Str_8::FromNum(code) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
void Create(const Str_8 &dir)
|
||||
{
|
||||
if (!CreateDirectoryW(UTF::To_16(dir), nullptr))
|
||||
{
|
||||
if (const DWORD code = GetLastError(); code != ERROR_ALREADY_EXISTS)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to create directory, \"" + dir + "\" with error #" + Str_8::FromNum(code) + ".");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
}
|
@@ -16,7 +16,7 @@ namespace ehs
|
||||
}
|
||||
|
||||
FileMonitor::FileMonitor()
|
||||
: hdl(nullptr), time{}
|
||||
: hdl(INVALID_HANDLE_VALUE), time{}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace ehs
|
||||
if (!CloseHandle(hdl))
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to close file at file path, \"" + filePath + "\", with error #" + GetLastError() + ".");
|
||||
|
||||
hdl = nullptr;
|
||||
hdl = INVALID_HANDLE_VALUE;
|
||||
}
|
||||
|
||||
UInt_8 FileMonitor::Poll()
|
||||
|
@@ -1,8 +1,6 @@
|
||||
#include "ehs/io/UsbBase.h"
|
||||
#include "ehs/Util.h"
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
UsbBase::UsbBase()
|
||||
|
@@ -108,10 +108,11 @@ namespace ehs
|
||||
if (!keyboard)
|
||||
{
|
||||
UInt_32 bufferSize;
|
||||
GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICENAME, NULL, &bufferSize);
|
||||
GetRawInputDeviceInfoW(raw->header.hDevice, RIDI_DEVICENAME, nullptr, &bufferSize);
|
||||
|
||||
Char_16* deviceName = new Char_16[bufferSize];
|
||||
|
||||
if (GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
|
||||
if (GetRawInputDeviceInfoW(raw->header.hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to retrieve device name.");
|
||||
return 0;
|
||||
@@ -134,10 +135,11 @@ namespace ehs
|
||||
if (!mouse)
|
||||
{
|
||||
UInt_32 bufferSize;
|
||||
GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICENAME, nullptr, &bufferSize);
|
||||
GetRawInputDeviceInfoW(raw->header.hDevice, RIDI_DEVICENAME, nullptr, &bufferSize);
|
||||
|
||||
Char_16* deviceName = new Char_16[bufferSize];
|
||||
|
||||
if (GetRawInputDeviceInfo(raw->header.hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
|
||||
if (GetRawInputDeviceInfoW(raw->header.hDevice, RIDI_DEVICENAME, deviceName, &bufferSize) < 0)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to retrieve device name.");
|
||||
return 0;
|
||||
|
@@ -1,10 +1,20 @@
|
||||
#include "ehs/io/Window_Way.h"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include "ehs/io/Console.h"
|
||||
#include "ehs/io/xdg-shell-client-protocol.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
void Window::SurfaceConfigure(void* data, xdg_surface* xdg_surface, UInt_32 serial)
|
||||
void Window::SurfaceConfigEvent(void* data, xdg_surface* xdg_surface, UInt_32 serial)
|
||||
{
|
||||
xdg_surface_ack_configure(xdg_surface, serial);
|
||||
|
||||
//Window* win = (Window *)data;
|
||||
|
||||
//wl_surface_commit(win->wlSurface);
|
||||
}
|
||||
|
||||
void Window::ShellPing(void* data, xdg_wm_base* shell, UInt_32 serial)
|
||||
@@ -14,43 +24,162 @@ namespace ehs
|
||||
|
||||
void Window::RegistryHandler(void* data, wl_registry* registry, UInt_32 id, const char* interface, UInt_32 version)
|
||||
{
|
||||
Serializer<UInt_64>* ser = (Serializer<UInt_64>*)data;
|
||||
Window *win = (Window *)data;
|
||||
|
||||
if (Str_8::Cmp(interface, "wl_compositor"))
|
||||
{
|
||||
ser->SetOffset(0);
|
||||
wl_compositor** comp = ser->Read<wl_compositor**>();
|
||||
*comp = (wl_compositor*)wl_registry_bind(registry, id, &wl_compositor_interface, 1);
|
||||
}
|
||||
|
||||
if (Str_8::Cmp(interface, "xdg_wm_base"))
|
||||
{
|
||||
ser->SetOffset(sizeof(void*));
|
||||
xdg_wm_base** base = ser->Read<xdg_wm_base**>();
|
||||
*base = (xdg_wm_base*)wl_registry_bind(registry, id, &xdg_wm_base_interface, 1);
|
||||
}
|
||||
if (Str_8::Cmp(interface, wl_compositor_interface.name))
|
||||
win->compositor = (wl_compositor*)wl_registry_bind(registry, id, &wl_compositor_interface, 1);
|
||||
else if (Str_8::Cmp(interface, xdg_wm_base_interface.name))
|
||||
win->xdgShell = (xdg_wm_base*)wl_registry_bind(registry, id, &xdg_wm_base_interface, 1);
|
||||
else if (Str_8::Cmp(interface, zxdg_decoration_manager_v1_interface.name))
|
||||
win->decManager = (zxdg_decoration_manager_v1*)wl_registry_bind(registry, id, &zxdg_decoration_manager_v1_interface, 1);
|
||||
else if (Str_8::Cmp(interface, wl_seat_interface.name))
|
||||
win->seat = (wl_seat *)wl_registry_bind(registry, id, &wl_seat_interface, 1);
|
||||
}
|
||||
|
||||
void Window::RegistryRemoved(void* data, wl_registry* registry, UInt_32 id)
|
||||
{
|
||||
}
|
||||
|
||||
void Window::ResizeEvent(void *data, struct xdg_toplevel *xdg_toplevel, Int_32 width, Int_32 height, wl_array *states)
|
||||
{
|
||||
if (!width && !height)
|
||||
return;
|
||||
|
||||
Window *win = (Window *)data;
|
||||
|
||||
win->scale = {(UInt_32)width, (UInt_32)height};
|
||||
}
|
||||
|
||||
void Window::CloseEvent(void *data, xdg_toplevel *xdg_toplevel)
|
||||
{
|
||||
Window *win = (Window *)data;
|
||||
win->Close();
|
||||
}
|
||||
|
||||
void Window::SeatCapabilitiesEvent(void *data, wl_seat *seat, UInt_32 capabilities)
|
||||
{
|
||||
Window *win = (Window *)data;
|
||||
|
||||
if (capabilities & WL_SEAT_CAPABILITY_POINTER)
|
||||
{
|
||||
win->pointer = wl_seat_get_pointer(seat);
|
||||
|
||||
static const wl_pointer_listener pointer_listener = {
|
||||
.motion = PointerMotionEvent
|
||||
};
|
||||
|
||||
wl_pointer_add_listener(win->pointer, &pointer_listener, win);
|
||||
}
|
||||
}
|
||||
|
||||
void Window::PointerMotionEvent(void *data, wl_pointer *pointer, UInt_32 time, wl_fixed_t sx, wl_fixed_t sy)
|
||||
{
|
||||
EHS_LOG_INT(LogType::INFO, 0, "Pointer Pos: <" + Str_8::FromNum(wl_fixed_to_double(sx)) + ", " + Str_8::FromNum(wl_fixed_to_double(sy)) + ">");
|
||||
}
|
||||
|
||||
Window::~Window()
|
||||
{
|
||||
if (!created)
|
||||
return;
|
||||
|
||||
zxdg_toplevel_decoration_v1_destroy(dec);
|
||||
zxdg_decoration_manager_v1_destroy(decManager);
|
||||
xdg_toplevel_destroy(xdgToplevel);
|
||||
xdg_surface_destroy(xdgSurface);
|
||||
xdg_wm_base_destroy(xdgShell);
|
||||
wl_surface_destroy(surface);
|
||||
wl_surface_destroy(wlSurface);
|
||||
wl_compositor_destroy(compositor);
|
||||
wl_registry_destroy(registry);
|
||||
wl_display_disconnect(display);
|
||||
}
|
||||
|
||||
Window::Window()
|
||||
: display(nullptr), registry(nullptr), compositor(nullptr) , surface(nullptr)
|
||||
: display(nullptr), registry(nullptr), compositor(nullptr), wlSurface(nullptr), xdgShell(nullptr),
|
||||
xdgSurface(nullptr), xdgToplevel(nullptr), decManager(nullptr), dec(nullptr), seat(nullptr), pointer(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Window::Window(Window &&win) noexcept
|
||||
: BaseWindow(win), display(win.display), registry(win.registry), compositor(win.compositor),
|
||||
wlSurface(win.wlSurface), xdgShell(win.xdgShell), xdgSurface(win.xdgSurface), xdgToplevel(win.xdgToplevel),
|
||||
decManager(win.decManager), dec(win.dec), seat(win.seat), pointer(win.pointer)
|
||||
{
|
||||
win.display = nullptr;
|
||||
win.registry = nullptr;
|
||||
win.compositor = nullptr;
|
||||
win.wlSurface = nullptr;
|
||||
win.xdgShell = nullptr;
|
||||
win.xdgSurface = nullptr;
|
||||
win.xdgToplevel = nullptr;
|
||||
win.decManager = nullptr;
|
||||
win.dec = nullptr;
|
||||
win.seat = nullptr;
|
||||
win.pointer = nullptr;
|
||||
}
|
||||
|
||||
Window::Window(const Window &win)
|
||||
: BaseWindow(win), display(nullptr), registry(nullptr), compositor(nullptr), wlSurface(nullptr),
|
||||
xdgShell(nullptr), xdgSurface(nullptr), xdgToplevel(nullptr), decManager(nullptr), dec(nullptr), seat(nullptr),
|
||||
pointer(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
Window & Window::operator=(Window &&win) noexcept
|
||||
{
|
||||
if (this == &win)
|
||||
return *this;
|
||||
|
||||
BaseWindow::operator=(win);
|
||||
|
||||
display = win.display;
|
||||
registry = win.registry;
|
||||
compositor = win.compositor;
|
||||
wlSurface = win.wlSurface;
|
||||
xdgShell = win.xdgShell;
|
||||
xdgSurface = win.xdgSurface;
|
||||
xdgToplevel = win.xdgToplevel;
|
||||
decManager = win.decManager;
|
||||
dec = win.dec;
|
||||
seat = win.seat;
|
||||
pointer = win.pointer;
|
||||
|
||||
win.display = nullptr;
|
||||
win.registry = nullptr;
|
||||
win.compositor = nullptr;
|
||||
win.wlSurface = nullptr;
|
||||
win.xdgShell = nullptr;
|
||||
win.xdgSurface = nullptr;
|
||||
win.xdgToplevel = nullptr;
|
||||
win.decManager = nullptr;
|
||||
win.dec = nullptr;
|
||||
win.seat = nullptr;
|
||||
win.pointer = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Window & Window::operator=(const Window &win)
|
||||
{
|
||||
if (this == &win)
|
||||
return *this;
|
||||
|
||||
BaseWindow::operator=(win);
|
||||
|
||||
display = nullptr;
|
||||
registry = nullptr;
|
||||
compositor = nullptr;
|
||||
wlSurface = nullptr;
|
||||
xdgShell = nullptr;
|
||||
xdgSurface = nullptr;
|
||||
xdgToplevel = nullptr;
|
||||
decManager = nullptr;
|
||||
dec = nullptr;
|
||||
seat = nullptr;
|
||||
pointer = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Window::Create_32(const Str_32& title, const Vec2_s32& pos, const Vec2_u32 scale)
|
||||
{
|
||||
Create_8(UTF::To_8(title), pos, scale);
|
||||
@@ -63,6 +192,9 @@ namespace ehs
|
||||
|
||||
void Window::Create_8(const Str_8& title, const Vec2_s32& pos, const Vec2_u32 scale)
|
||||
{
|
||||
if (created)
|
||||
return;
|
||||
|
||||
display = wl_display_connect(nullptr);
|
||||
if (!display)
|
||||
{
|
||||
@@ -70,17 +202,13 @@ namespace ehs
|
||||
return;
|
||||
}
|
||||
|
||||
Serializer<UInt_64> data(Endianness::LE);
|
||||
data.Write(&compositor);
|
||||
data.Write(&xdgShell);
|
||||
|
||||
static constexpr wl_registry_listener registry_listener = {
|
||||
RegistryHandler,
|
||||
RegistryRemoved
|
||||
.global = RegistryHandler,
|
||||
.global_remove = RegistryRemoved
|
||||
};
|
||||
|
||||
registry = wl_display_get_registry(display);
|
||||
wl_registry_add_listener(registry, ®istry_listener, &data);
|
||||
wl_registry_add_listener(registry, ®istry_listener, this);
|
||||
|
||||
wl_display_dispatch(display);
|
||||
wl_display_roundtrip(display);
|
||||
@@ -91,26 +219,68 @@ namespace ehs
|
||||
return;
|
||||
}
|
||||
|
||||
static constexpr xdg_wm_base_listener xdg_shell_listener = {ShellPing};
|
||||
static constexpr xdg_wm_base_listener xdg_shell_listener = {
|
||||
.ping = ShellPing
|
||||
};
|
||||
|
||||
xdg_wm_base_add_listener(xdgShell, &xdg_shell_listener, nullptr);
|
||||
|
||||
surface = wl_compositor_create_surface(compositor);
|
||||
if (!surface)
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
wlSurface = wl_compositor_create_surface(compositor);
|
||||
if (!wlSurface)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Can't create surface.");
|
||||
return;
|
||||
}
|
||||
|
||||
xdgSurface = xdg_wm_base_get_xdg_surface(xdgShell, surface);
|
||||
xdgSurface = xdg_wm_base_get_xdg_surface(xdgShell, wlSurface);
|
||||
|
||||
static constexpr xdg_surface_listener surfaceListener = {
|
||||
.configure = SurfaceConfigEvent
|
||||
};
|
||||
|
||||
xdg_surface_add_listener(xdgSurface, &surfaceListener, this);
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
xdgToplevel = xdg_surface_get_toplevel(xdgSurface);
|
||||
|
||||
static constexpr xdg_surface_listener surfaceListener = {SurfaceConfigure};
|
||||
static constexpr xdg_toplevel_listener topLevelListener = {
|
||||
.configure = ResizeEvent,
|
||||
.close = CloseEvent
|
||||
};
|
||||
|
||||
xdg_surface_add_listener(xdgSurface, &surfaceListener, nullptr);
|
||||
xdg_toplevel_add_listener(xdgToplevel, &topLevelListener, this);
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
xdg_toplevel_set_title(xdgToplevel, title);
|
||||
wl_surface_commit(surface);
|
||||
xdg_toplevel_set_app_id(xdgToplevel, title);
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
dec = zxdg_decoration_manager_v1_get_toplevel_decoration(decManager, xdgToplevel);
|
||||
zxdg_toplevel_decoration_v1_set_mode(dec, ZXDG_TOPLEVEL_DECORATION_V1_MODE_SERVER_SIDE);
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
static constexpr wl_seat_listener seat_listener = {
|
||||
.capabilities = SeatCapabilitiesEvent
|
||||
};
|
||||
|
||||
wl_seat_add_listener(seat, &seat_listener, this);
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
wl_surface_commit(wlSurface);
|
||||
|
||||
wl_display_roundtrip(display);
|
||||
|
||||
this->scale = scale;
|
||||
created = true;
|
||||
|
||||
OnCreated();
|
||||
}
|
||||
|
||||
void Window::OnCreated()
|
||||
@@ -119,6 +289,15 @@ namespace ehs
|
||||
|
||||
void Window::Close()
|
||||
{
|
||||
if (!created)
|
||||
return;
|
||||
|
||||
zxdg_toplevel_decoration_v1_destroy(dec);
|
||||
dec = nullptr;
|
||||
|
||||
zxdg_decoration_manager_v1_destroy(decManager);
|
||||
decManager = nullptr;
|
||||
|
||||
xdg_toplevel_destroy(xdgToplevel);
|
||||
xdgToplevel = nullptr;
|
||||
|
||||
@@ -128,8 +307,8 @@ namespace ehs
|
||||
xdg_wm_base_destroy(xdgShell);
|
||||
xdgShell = nullptr;
|
||||
|
||||
wl_surface_destroy(surface);
|
||||
surface = nullptr;
|
||||
wl_surface_destroy(wlSurface);
|
||||
wlSurface = nullptr;
|
||||
|
||||
wl_compositor_destroy(compositor);
|
||||
compositor = nullptr;
|
||||
@@ -139,6 +318,8 @@ namespace ehs
|
||||
|
||||
wl_display_disconnect(display);
|
||||
display = nullptr;
|
||||
|
||||
created = false;
|
||||
}
|
||||
|
||||
void Window::Show()
|
||||
@@ -151,7 +332,11 @@ namespace ehs
|
||||
|
||||
bool Window::Poll()
|
||||
{
|
||||
wl_display_dispatch(display);
|
||||
if (wl_display_dispatch_pending(display) == -1)
|
||||
return false;
|
||||
|
||||
if (!created)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -206,7 +391,7 @@ namespace ehs
|
||||
|
||||
Vec2_u32 Window::GetScale() const
|
||||
{
|
||||
return {};
|
||||
return scale;
|
||||
}
|
||||
|
||||
Serializer<UInt_64> Window::GetClipboard()
|
||||
|
@@ -187,8 +187,6 @@ namespace ehs
|
||||
|
||||
QueryPrimaryDevices();
|
||||
|
||||
xcb_map_window(server, hdl);
|
||||
|
||||
xcb_flush(server);
|
||||
|
||||
created = true;
|
||||
|
@@ -407,13 +407,13 @@ namespace ehs
|
||||
case DataType::SINT_8:
|
||||
return ((SInt_8 *)data)[sampleIndex];
|
||||
case DataType::SINT_16:
|
||||
return (SInt_8)((float)((SInt_16*)data)[sampleIndex] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_8_MAX);
|
||||
return (SInt_8)((double)((SInt_16 *)data)[sampleIndex] / (double)EHS_SINT_16_MAX * (double)EHS_SINT_8_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_8)(((float*)data)[sampleIndex] * (float)EHS_SINT_8_MAX);
|
||||
return (SInt_8)(((double *)data)[sampleIndex] * (double)EHS_SINT_8_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_8)((float)((SInt_32*)data)[sampleIndex] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_8_MAX);
|
||||
return (SInt_8)((double)((SInt_32 *)data)[sampleIndex] / (double)EHS_SINT_32_MAX * (double)EHS_SINT_8_MAX);
|
||||
case DataType::SINT_64:
|
||||
return (SInt_8)((float)((SInt_64*)data)[sampleIndex] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_8_MAX);
|
||||
return (SInt_8)((double)((SInt_64 *)data)[sampleIndex] / (double)EHS_SINT_64_MAX * (double)EHS_SINT_8_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -424,15 +424,15 @@ namespace ehs
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_16)((float)((SInt_8*)data)[sampleIndex] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_16_MAX);
|
||||
return (SInt_16)((double)((SInt_8*)data)[sampleIndex] / (double)EHS_SINT_8_MAX * (double)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_16:
|
||||
return ((SInt_16 *)data)[sampleIndex];
|
||||
case DataType::FLOAT:
|
||||
return (SInt_16)(((float*)data)[sampleIndex] * (float)EHS_SINT_16_MAX);
|
||||
return (SInt_16)(((double *)data)[sampleIndex] * (double)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_16)((float)((SInt_32*)data)[sampleIndex] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_16_MAX);
|
||||
return (SInt_16)((double)((SInt_32 *)data)[sampleIndex] / (double)EHS_SINT_32_MAX * (double)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_64:
|
||||
return (SInt_16)((float)((SInt_64*)data)[sampleIndex] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_16_MAX);
|
||||
return (SInt_16)((double)((SInt_64 *)data)[sampleIndex] / (double)EHS_SINT_64_MAX * (double)EHS_SINT_16_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -462,15 +462,15 @@ namespace ehs
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_32)((float)((SInt_8*)data)[sampleIndex] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_32_MAX);
|
||||
return (SInt_32)((double)((SInt_8 *)data)[sampleIndex] / (double)EHS_SINT_8_MAX * (double)EHS_SINT_32_MAX);
|
||||
case DataType::SINT_16:
|
||||
return (SInt_32)((float)((SInt_16*)data)[sampleIndex] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_32_MAX);
|
||||
return (SInt_32)((double)((SInt_16 *)data)[sampleIndex] / (double)EHS_SINT_16_MAX * (double)EHS_SINT_32_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_32)(((float*)data)[sampleIndex] * (float)EHS_SINT_32_MAX);
|
||||
return (SInt_32)(((double *)data)[sampleIndex] * (double)EHS_SINT_32_MAX);
|
||||
case DataType::SINT_32:
|
||||
return ((SInt_32 *)data)[sampleIndex];
|
||||
case DataType::SINT_64:
|
||||
return (SInt_32)((float)((SInt_64*)data)[sampleIndex] / (float)EHS_SINT_64_MAX * (float)EHS_SINT_32_MAX);
|
||||
return (SInt_32)((double)((SInt_64 *)data)[sampleIndex] / (double)EHS_SINT_64_MAX * (double)EHS_SINT_32_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -481,13 +481,13 @@ namespace ehs
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_64)((float)((SInt_8*)data)[sampleIndex] / (float)EHS_SINT_8_MAX * (float)EHS_SINT_64_MAX);
|
||||
return (SInt_64)((double)((SInt_8 *)data)[sampleIndex] / (double)EHS_SINT_8_MAX * (double)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_16:
|
||||
return (SInt_64)((float)((SInt_16*)data)[sampleIndex] / (float)EHS_SINT_16_MAX * (float)EHS_SINT_64_MAX);
|
||||
return (SInt_64)((double)((SInt_16 *)data)[sampleIndex] / (double)EHS_SINT_16_MAX * (double)EHS_SINT_64_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_64)(((float*)data)[sampleIndex] * (float)EHS_SINT_64_MAX);
|
||||
return (SInt_64)(((double *)data)[sampleIndex] * (double)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_64)((float)((SInt_32*)data)[sampleIndex] / (float)EHS_SINT_32_MAX * (float)EHS_SINT_64_MAX);
|
||||
return (SInt_64)((double)((SInt_32 *)data)[sampleIndex] / (double)EHS_SINT_32_MAX * (double)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_64:
|
||||
return ((SInt_64 *)data)[sampleIndex];
|
||||
default:
|
||||
@@ -502,13 +502,13 @@ namespace ehs
|
||||
case DataType::SINT_8:
|
||||
return *(SInt_8*)peak;
|
||||
case DataType::SINT_16:
|
||||
return (SInt_8)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_8_MAX);
|
||||
return (SInt_8)((double)*(SInt_16 *)peak / (double)EHS_SINT_16_MAX * (double)EHS_SINT_8_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_8)(*(float*)peak * (float)EHS_SINT_8_MAX);
|
||||
return (SInt_8)(*(double *)peak * (double)EHS_SINT_8_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_8)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_8_MAX);
|
||||
return (SInt_8)((double)*(SInt_32 *)peak / (double)EHS_SINT_32_MAX * (double)EHS_SINT_8_MAX);
|
||||
case DataType::SINT_64:
|
||||
return (SInt_8)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_8_MAX);
|
||||
return (SInt_8)((double)*(SInt_64 *)peak / (double)EHS_SINT_64_MAX * (double)EHS_SINT_8_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -519,15 +519,15 @@ namespace ehs
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_16)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_16_MAX);
|
||||
return (SInt_16)((double)*(SInt_8 *)peak / (double)EHS_SINT_8_MAX * (double)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_16:
|
||||
return *(SInt_16*)peak;
|
||||
case DataType::FLOAT:
|
||||
return (SInt_16)(*(float*)peak * (float)EHS_SINT_16_MAX);
|
||||
return (SInt_16)(*(double*)peak * (double)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_16)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_16_MAX);
|
||||
return (SInt_16)((double)*(SInt_32 *)peak / (double)EHS_SINT_32_MAX * (double)EHS_SINT_16_MAX);
|
||||
case DataType::SINT_64:
|
||||
return (SInt_16)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_16_MAX);
|
||||
return (SInt_16)((double)*(SInt_64 *)peak / (double)EHS_SINT_64_MAX * (double)EHS_SINT_16_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -557,15 +557,15 @@ namespace ehs
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_32)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_32_MAX);
|
||||
return (SInt_32)((double)*(SInt_8 *)peak / (double)EHS_SINT_8_MAX * (double)EHS_SINT_32_MAX);
|
||||
case DataType::SINT_16:
|
||||
return (SInt_32)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_32_MAX);
|
||||
return (SInt_32)((double)*(SInt_16 *)peak / (double)EHS_SINT_16_MAX * (double)EHS_SINT_32_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_32)(*(float*)peak * (float)EHS_SINT_32_MAX);
|
||||
return (SInt_32)(*(double *)peak * (double)EHS_SINT_32_MAX);
|
||||
case DataType::SINT_32:
|
||||
return *(SInt_32 *)peak;
|
||||
case DataType::SINT_64:
|
||||
return (SInt_32)((float)*(SInt_64*)peak / (float)EHS_SINT_64_MAX * (float)EHS_SINT_32_MAX);
|
||||
return (SInt_32)((double)*(SInt_64 *)peak / (double)EHS_SINT_64_MAX * (double)EHS_SINT_32_MAX);
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
@@ -576,13 +576,13 @@ namespace ehs
|
||||
switch (dataType)
|
||||
{
|
||||
case DataType::SINT_8:
|
||||
return (SInt_64)((float)*(SInt_8*)peak / (float)EHS_SINT_8_MAX * (float)EHS_SINT_64_MAX);
|
||||
return (SInt_64)((double)*(SInt_8 *)peak / (double)EHS_SINT_8_MAX * (double)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_16:
|
||||
return (SInt_64)((float)*(SInt_16*)peak / (float)EHS_SINT_16_MAX * (float)EHS_SINT_64_MAX);
|
||||
return (SInt_64)((double)*(SInt_16 *)peak / (double)EHS_SINT_16_MAX * (double)EHS_SINT_64_MAX);
|
||||
case DataType::FLOAT:
|
||||
return (SInt_64)(*(float*)peak * (float)EHS_SINT_64_MAX);
|
||||
return (SInt_64)(*(double *)peak * (double)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_32:
|
||||
return (SInt_64)((float)*(SInt_32*)peak / (float)EHS_SINT_32_MAX * (float)EHS_SINT_64_MAX);
|
||||
return (SInt_64)((double)*(SInt_32 *)peak / (double)EHS_SINT_32_MAX * (double)EHS_SINT_64_MAX);
|
||||
case DataType::SINT_64:
|
||||
return *(SInt_64 *)peak;
|
||||
default:
|
||||
|
18
src/io/socket/BaseDNS.cpp
Normal file
18
src/io/socket/BaseDNS.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#include "ehs/io/socket/BaseDNS.h"
|
||||
|
||||
#include "ehs/Log.h"
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
Str_8 BaseDNS::Resolve(const AddrType type, const Str_8 &hostname)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Unsupported Operating System.");
|
||||
return {};
|
||||
}
|
||||
|
||||
Str_8 BaseDNS::Resolve(const Str_8 &hostname)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Unsupported Operating System.");
|
||||
return {};
|
||||
}
|
||||
}
|
@@ -1,73 +0,0 @@
|
||||
#include "ehs/io/socket/DNS.h"
|
||||
#include "ehs/Log.h"
|
||||
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
#elif defined(EHS_OS_LINUX)
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
Str_8 DNS::Resolve(const Str_8& hostname)
|
||||
{
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
WSADATA data = {};
|
||||
|
||||
Int_32 wsaCode = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (wsaCode)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to start WSA with error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
||||
addrinfo* result = nullptr;
|
||||
|
||||
Int_32 code = getaddrinfo(hostname, nullptr, nullptr, &result);
|
||||
if (code)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to resolve host with error #" + Str_8::FromNum(code) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return {};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (result->ai_family == AF_INET6)
|
||||
{
|
||||
Str_8 ipResult(INET6_ADDRSTRLEN);
|
||||
|
||||
inet_ntop(result->ai_family, &((sockaddr_in6*)result->ai_addr)->sin6_addr, ipResult, INET6_ADDRSTRLEN);
|
||||
|
||||
ipResult.ExactSize();
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
return ipResult;
|
||||
}
|
||||
else if (result->ai_family == AF_INET)
|
||||
{
|
||||
Str_8 ipResult(INET_ADDRSTRLEN);
|
||||
|
||||
inet_ntop(result->ai_family, &((sockaddr_in*)result->ai_addr)->sin_addr, ipResult, INET_ADDRSTRLEN);
|
||||
|
||||
ipResult.ExactSize();
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
return ipResult;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
101
src/io/socket/DNS_LNX.cpp
Normal file
101
src/io/socket/DNS_LNX.cpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#include "ehs/io/socket/DNS_LNX.h"
|
||||
#include "ehs/Log.h"
|
||||
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
Str_8 DNS::Resolve(const AddrType type, const Str_8 &hostname)
|
||||
{
|
||||
addrinfo* result = nullptr;
|
||||
addrinfo req = {};
|
||||
|
||||
if (type == AddrType::IPV6)
|
||||
req.ai_family = AF_INET6;
|
||||
else if (type == AddrType::IPV4)
|
||||
req.ai_family = AF_INET;
|
||||
|
||||
Int_32 code = getaddrinfo(hostname, nullptr, &req, &result);
|
||||
if (code)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to resolve host with error #" + Str_8::FromNum(code) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (result->ai_family == AF_INET6)
|
||||
{
|
||||
Str_8 ipResult(INET6_ADDRSTRLEN);
|
||||
|
||||
inet_ntop(result->ai_family, &((sockaddr_in6*)result->ai_addr)->sin6_addr, ipResult, INET6_ADDRSTRLEN);
|
||||
|
||||
ipResult.ExactSize();
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return ipResult;
|
||||
}
|
||||
else if (result->ai_family == AF_INET)
|
||||
{
|
||||
Str_8 ipResult(INET_ADDRSTRLEN);
|
||||
|
||||
inet_ntop(result->ai_family, &((sockaddr_in*)result->ai_addr)->sin_addr, ipResult, INET_ADDRSTRLEN);
|
||||
|
||||
ipResult.ExactSize();
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return ipResult;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Str_8 DNS::Resolve(const Str_8 &hostname)
|
||||
{
|
||||
addrinfo* result = nullptr;
|
||||
|
||||
Int_32 code = getaddrinfo(hostname, nullptr, nullptr, &result);
|
||||
if (code)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to resolve host with error #" + Str_8::FromNum(code) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (result->ai_family == AF_INET6)
|
||||
{
|
||||
Str_8 ipResult(INET6_ADDRSTRLEN);
|
||||
|
||||
inet_ntop(result->ai_family, &((sockaddr_in6*)result->ai_addr)->sin6_addr, ipResult, INET6_ADDRSTRLEN);
|
||||
|
||||
ipResult.ExactSize();
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return ipResult;
|
||||
}
|
||||
else if (result->ai_family == AF_INET)
|
||||
{
|
||||
Str_8 ipResult(INET_ADDRSTRLEN);
|
||||
|
||||
inet_ntop(result->ai_family, &((sockaddr_in*)result->ai_addr)->sin_addr, ipResult, INET_ADDRSTRLEN);
|
||||
|
||||
ipResult.ExactSize();
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return ipResult;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
126
src/io/socket/DNS_W32.cpp
Normal file
126
src/io/socket/DNS_W32.cpp
Normal file
@@ -0,0 +1,126 @@
|
||||
#include "ehs/io/socket/DNS_W32.h"
|
||||
#include "ehs/Log.h"
|
||||
|
||||
#include <WinSock2.h>
|
||||
#include <WS2tcpip.h>
|
||||
|
||||
namespace ehs
|
||||
{
|
||||
Str_8 DNS::Resolve(const AddrType type, const Str_8 &hostname)
|
||||
{
|
||||
WSADATA data = {};
|
||||
|
||||
Int_32 wsaCode = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (wsaCode)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to start WSA with error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
addrinfo* result = nullptr;
|
||||
addrinfo req = {};
|
||||
|
||||
if (type == AddrType::IPV6)
|
||||
req.ai_family = AF_INET6;
|
||||
else if (type == AddrType::IPV4)
|
||||
req.ai_family = AF_INET;
|
||||
|
||||
Int_32 code = getaddrinfo(hostname, nullptr, &req, &result);
|
||||
if (code)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to resolve host with error #" + Str_8::FromNum(code) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (result->ai_family == AF_INET6)
|
||||
{
|
||||
Str_8 ipResult(INET6_ADDRSTRLEN);
|
||||
|
||||
inet_ntop(result->ai_family, &((sockaddr_in6*)result->ai_addr)->sin6_addr, ipResult, INET6_ADDRSTRLEN);
|
||||
|
||||
ipResult.ExactSize();
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return ipResult;
|
||||
}
|
||||
else if (result->ai_family == AF_INET)
|
||||
{
|
||||
Str_8 ipResult(INET_ADDRSTRLEN);
|
||||
|
||||
inet_ntop(result->ai_family, &((sockaddr_in*)result->ai_addr)->sin_addr, ipResult, INET_ADDRSTRLEN);
|
||||
|
||||
ipResult.ExactSize();
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return ipResult;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
Str_8 DNS::Resolve(const Str_8 &hostname)
|
||||
{
|
||||
WSADATA data = {};
|
||||
|
||||
Int_32 wsaCode = WSAStartup(MAKEWORD(2, 2), &data);
|
||||
if (wsaCode)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 0, "Failed to start WSA with error #" + Str_8::FromNum(wsaCode) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
addrinfo* result = nullptr;
|
||||
|
||||
Int_32 code = getaddrinfo(hostname, nullptr, nullptr, &result);
|
||||
if (code)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 1, "Failed to resolve host with error #" + Str_8::FromNum(code) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (WSACleanup() == SOCKET_ERROR)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to shutdown WSA with error #" + Str_8::FromNum(WSAGetLastError()) + ".");
|
||||
return {};
|
||||
}
|
||||
|
||||
if (result->ai_family == AF_INET6)
|
||||
{
|
||||
Str_8 ipResult(INET6_ADDRSTRLEN);
|
||||
|
||||
inet_ntop(result->ai_family, &((sockaddr_in6*)result->ai_addr)->sin6_addr, ipResult, INET6_ADDRSTRLEN);
|
||||
|
||||
ipResult.ExactSize();
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
return ipResult;
|
||||
}
|
||||
else if (result->ai_family == AF_INET)
|
||||
{
|
||||
Str_8 ipResult(INET_ADDRSTRLEN);
|
||||
|
||||
inet_ntop(result->ai_family, &((sockaddr_in*)result->ai_addr)->sin_addr, ipResult, INET_ADDRSTRLEN);
|
||||
|
||||
ipResult.ExactSize();
|
||||
|
||||
freeaddrinfo(result);
|
||||
|
||||
return ipResult;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
#include "ehs/io/socket/TCP_BSD.h"
|
||||
#include "ehs/io/socket/DNS.h"
|
||||
#include "ehs/io/socket/DNS_LNX.h"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
@@ -213,13 +213,23 @@ namespace ehs
|
||||
return;
|
||||
|
||||
remoteHostName = address;
|
||||
remoteAddr = DNS::Resolve(address);
|
||||
remotePort = port;
|
||||
|
||||
if (addrType == AddrType::IPV6)
|
||||
{
|
||||
if (IsIPv6Only())
|
||||
remoteAddr = DNS::Resolve(AddrType::IPV6, address);
|
||||
else
|
||||
remoteAddr = DNS::Resolve(address);
|
||||
|
||||
Connect_v6(remoteAddr, port);
|
||||
}
|
||||
else if (addrType == AddrType::IPV4)
|
||||
{
|
||||
remoteAddr = DNS::Resolve(AddrType::IPV4, address);
|
||||
|
||||
Connect_v4(remoteAddr, port);
|
||||
}
|
||||
|
||||
connected = true;
|
||||
}
|
||||
@@ -326,6 +336,55 @@ namespace ehs
|
||||
return !(flags & O_NONBLOCK);
|
||||
}
|
||||
|
||||
void TCP::SetIPv6Only(const bool value)
|
||||
{
|
||||
if (addrType != AddrType::IPV6)
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 0, "Cannot set IPv6 only mode while socket is not using IPv6.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Attempted to set IPv6 only mode while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
const int result = (int)value;
|
||||
if (setsockopt(hdl, IPPROTO_IPV6, IPV6_V6ONLY, &result, sizeof(int)) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set IPv6 only mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
bool TCP::IsIPv6Only() const
|
||||
{
|
||||
if (addrType != AddrType::IPV6)
|
||||
return false;
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Attempted to set IPv6 only mode while socket is not initialized.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int result;
|
||||
socklen_t len = sizeof(int);
|
||||
|
||||
if (getsockopt(hdl, IPPROTO_IPV6, IPV6_V6ONLY, &result, &len) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set IPv6 only mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TCP::IsValid() const
|
||||
{
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
|
@@ -242,13 +242,23 @@ namespace ehs
|
||||
return;
|
||||
|
||||
remoteHostName = address;
|
||||
remoteAddr = DNS::Resolve(address);
|
||||
remotePort = port;
|
||||
|
||||
if (addrType == AddrType::IPV6)
|
||||
{
|
||||
if (IsIPv6Only())
|
||||
remoteAddr = DNS::Resolve(AddrType::IPV6, address);
|
||||
else
|
||||
remoteAddr = DNS::Resolve(address);
|
||||
|
||||
Connect_v6(remoteAddr, port);
|
||||
}
|
||||
else if (addrType == AddrType::IPV4)
|
||||
{
|
||||
remoteAddr = DNS::Resolve(AddrType::IPV4, address);
|
||||
|
||||
Connect_v4(remoteAddr, port);
|
||||
}
|
||||
|
||||
connected = true;
|
||||
}
|
||||
@@ -347,6 +357,55 @@ namespace ehs
|
||||
return (bool)r;
|
||||
}
|
||||
|
||||
void TCP::SetIPv6Only(const bool value)
|
||||
{
|
||||
if (addrType != AddrType::IPV6)
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 0, "Cannot set IPv6 only mode while socket is not using IPv6.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Attempted to set IPv6 only mode while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
const int result = (int)value;
|
||||
if (setsockopt(hdl, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&result, sizeof(int)) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set IPv6 only mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
bool TCP::IsIPv6Only() const
|
||||
{
|
||||
if (addrType != AddrType::IPV6)
|
||||
return false;
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Attempted to set IPv6 only mode while socket is not initialized.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int result;
|
||||
socklen_t len = sizeof(int);
|
||||
|
||||
if (getsockopt(hdl, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&result, &len) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set IPv6 only mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TCP::IsValid() const
|
||||
{
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
|
@@ -203,6 +203,55 @@ namespace ehs
|
||||
return (bool)fcntl(hdl, F_GETFL, O_NONBLOCK);
|
||||
}
|
||||
|
||||
void UDP::SetIPv6Only(const bool value)
|
||||
{
|
||||
if (type != AddrType::IPV6)
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 0, "Cannot set IPv6 only mode while socket is not using IPv6.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Attempted to set IPv6 only mode while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
const int result = (int)value;
|
||||
if (setsockopt(hdl, IPPROTO_IPV6, IPV6_V6ONLY, &result, sizeof(int)) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set IPv6 only mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
bool UDP::IsIPv6Only() const
|
||||
{
|
||||
if (type != AddrType::IPV6)
|
||||
return false;
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Attempted to set IPv6 only mode while socket is not initialized.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int result;
|
||||
socklen_t len = sizeof(int);
|
||||
|
||||
if (getsockopt(hdl, IPPROTO_IPV6, IPV6_V6ONLY, &result, &len) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set IPv6 only mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool UDP::IsValid() const
|
||||
{
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
|
@@ -223,6 +223,55 @@ namespace ehs
|
||||
return (bool)r;
|
||||
}
|
||||
|
||||
void UDP::SetIPv6Only(const bool value)
|
||||
{
|
||||
if (type != AddrType::IPV6)
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 0, "Cannot set IPv6 only mode while socket is not using IPv6.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Attempted to set IPv6 only mode while socket is not initialized.");
|
||||
return;
|
||||
}
|
||||
|
||||
const int result = (int)value;
|
||||
if (setsockopt(hdl, IPPROTO_IPV6, IPV6_V6ONLY, (const char *)&result, sizeof(int)) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set IPv6 only mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
}
|
||||
|
||||
bool UDP::IsIPv6Only() const
|
||||
{
|
||||
if (type != AddrType::IPV6)
|
||||
return false;
|
||||
|
||||
if (!IsValid())
|
||||
{
|
||||
EHS_LOG_INT(LogType::WARN, 1, "Attempted to set IPv6 only mode while socket is not initialized.");
|
||||
return false;
|
||||
}
|
||||
|
||||
int result;
|
||||
socklen_t len = sizeof(int);
|
||||
|
||||
if (getsockopt(hdl, IPPROTO_IPV6, IPV6_V6ONLY, (char *)&result, &len) == -1)
|
||||
{
|
||||
EHS_LOG_INT(LogType::ERR, 2, "Failed to set IPv6 only mode with error #" + Str_8::FromNum(errno) + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
EHS_LOG_SUCCESS();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool UDP::IsValid() const
|
||||
{
|
||||
return hdl != EHS_INVALID_SOCKET;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include "ehs/io/socket/rest/Spotify.h"
|
||||
#include "ehs/io/socket/DNS.h"
|
||||
#include "ehs/io/socket/DNS_LNX.h"
|
||||
#include "ehs/system/System.h"
|
||||
#include "ehs/URI.h"
|
||||
|
||||
@@ -17,8 +17,9 @@ namespace ehs
|
||||
{
|
||||
}
|
||||
|
||||
Spotify::Spotify(const Str_8& clientId, const Str_8& secret, const Str_8& redURI, const Array<Str_8>& scopes, const bool forceVerify)
|
||||
: client(AddrType::IPV4), clientId(clientId), secret(secret), redURI(redURI), scopes(scopes), forceVerify(forceVerify)
|
||||
Spotify::Spotify(Str_8 clientId, Str_8 secret, Str_8 redURI, Array<Str_8> scopes, const bool forceVerify)
|
||||
: client(AddrType::IPV4), clientId((Str_8 &&)clientId), secret((Str_8 &&)secret), redURI((Str_8 &&)redURI),
|
||||
scopes((Array<Str_8> &&)scopes), forceVerify(forceVerify)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ namespace ehs
|
||||
|
||||
TCP server(AddrType::IPV4);
|
||||
server.Initialize();
|
||||
server.Bind(DNS::Resolve("localhost"), 65534);
|
||||
server.Bind("", 65534);
|
||||
server.Listen();
|
||||
|
||||
System::OpenURI(uri);
|
||||
@@ -155,9 +156,6 @@ namespace ehs
|
||||
Request req(Verb::PUT, "/v1/me/player/play");
|
||||
req.BearerAuth(token);
|
||||
|
||||
client.Release();
|
||||
client.Initialize();
|
||||
client.Connect("", SSL::HTTPS_Port);
|
||||
client.SendReq(req);
|
||||
|
||||
Response res = client.RecvRes();
|
||||
@@ -590,7 +588,7 @@ namespace ehs
|
||||
|
||||
bool Spotify::ReAuthorize()
|
||||
{
|
||||
SSL accounts;
|
||||
SSL accounts(AddrType::IPV4);
|
||||
accounts.Initialize();
|
||||
accounts.Connect("accounts.spotify.com", SSL::HTTPS_Port);
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include "ehs/io/socket/rest/Twitch.h"
|
||||
#include "ehs/io/socket/DNS.h"
|
||||
#include "ehs/io/socket/DNS_LNX.h"
|
||||
#include "ehs/system/System.h"
|
||||
#include "ehs/URI.h"
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace ehs
|
||||
scopesFinal;
|
||||
|
||||
TCP server(AddrType::IPV4);
|
||||
server.Bind(DNS::Resolve("localhost"), 65535);
|
||||
server.Bind("", 65535);
|
||||
server.Listen();
|
||||
|
||||
System::OpenURI(uri);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
#include "ehs/io/socket/rest/TwitchChat.h"
|
||||
#include "ehs/io/socket/DNS.h"
|
||||
#include "ehs/io/socket/DNS_LNX.h"
|
||||
#include "ehs/io/Console.h"
|
||||
|
||||
namespace ehs
|
||||
|
76
src/io/xdg-decoration.c
Normal file
76
src/io/xdg-decoration.c
Normal file
@@ -0,0 +1,76 @@
|
||||
/* Generated by wayland-scanner 1.23.0 */
|
||||
|
||||
/*
|
||||
* Copyright © 2018 Simon Ser
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include "wayland-util.h"
|
||||
|
||||
#ifndef __has_attribute
|
||||
# define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */
|
||||
#endif
|
||||
|
||||
#if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4)
|
||||
#define WL_PRIVATE __attribute__ ((visibility("hidden")))
|
||||
#else
|
||||
#define WL_PRIVATE
|
||||
#endif
|
||||
|
||||
extern const struct wl_interface xdg_toplevel_interface;
|
||||
extern const struct wl_interface zxdg_toplevel_decoration_v1_interface;
|
||||
|
||||
static const struct wl_interface *xdg_decoration_unstable_v1_types[] = {
|
||||
NULL,
|
||||
&zxdg_toplevel_decoration_v1_interface,
|
||||
&xdg_toplevel_interface,
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_decoration_manager_v1_requests[] = {
|
||||
{ "destroy", "", xdg_decoration_unstable_v1_types + 0 },
|
||||
{ "get_toplevel_decoration", "no", xdg_decoration_unstable_v1_types + 1 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zxdg_decoration_manager_v1_interface = {
|
||||
"zxdg_decoration_manager_v1", 1,
|
||||
2, zxdg_decoration_manager_v1_requests,
|
||||
0, NULL,
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_toplevel_decoration_v1_requests[] = {
|
||||
{ "destroy", "", xdg_decoration_unstable_v1_types + 0 },
|
||||
{ "set_mode", "u", xdg_decoration_unstable_v1_types + 0 },
|
||||
{ "unset_mode", "", xdg_decoration_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
static const struct wl_message zxdg_toplevel_decoration_v1_events[] = {
|
||||
{ "configure", "u", xdg_decoration_unstable_v1_types + 0 },
|
||||
};
|
||||
|
||||
WL_PRIVATE const struct wl_interface zxdg_toplevel_decoration_v1_interface = {
|
||||
"zxdg_toplevel_decoration_v1", 1,
|
||||
3, zxdg_toplevel_decoration_v1_requests,
|
||||
1, zxdg_toplevel_decoration_v1_events,
|
||||
};
|
||||
|
@@ -75,7 +75,7 @@ namespace ehs
|
||||
if (hdl == EHS_INVALID_THREAD)
|
||||
return false;
|
||||
|
||||
#if defined(EHS_WINDOWS)
|
||||
#if defined(EHS_OS_WINDOWS)
|
||||
unsigned int r = WaitForSingleObject(hdl, timeout);
|
||||
if (r == WAIT_ABANDONED)
|
||||
{
|
||||
|
Reference in New Issue
Block a user