summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt10
-rw-r--r--src/common/announce_multiplayer_room.h11
-rw-r--r--src/common/input.h5
-rw-r--r--src/common/microprofile.h9
-rw-r--r--src/common/parent_of_member.h2
-rw-r--r--src/common/settings.cpp3
-rw-r--r--src/common/settings.h4
-rw-r--r--src/common/socket_types.h51
-rw-r--r--src/common/uint128.h1
9 files changed, 72 insertions, 24 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index a6dc31b53..68436a4bc 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -19,7 +19,7 @@ find_package(Git QUIET)
19 19
20add_custom_command(OUTPUT scm_rev.cpp 20add_custom_command(OUTPUT scm_rev.cpp
21 COMMAND ${CMAKE_COMMAND} 21 COMMAND ${CMAKE_COMMAND}
22 -DSRC_DIR=${CMAKE_SOURCE_DIR} 22 -DSRC_DIR=${PROJECT_SOURCE_DIR}
23 -DBUILD_REPOSITORY=${BUILD_REPOSITORY} 23 -DBUILD_REPOSITORY=${BUILD_REPOSITORY}
24 -DTITLE_BAR_FORMAT_IDLE=${TITLE_BAR_FORMAT_IDLE} 24 -DTITLE_BAR_FORMAT_IDLE=${TITLE_BAR_FORMAT_IDLE}
25 -DTITLE_BAR_FORMAT_RUNNING=${TITLE_BAR_FORMAT_RUNNING} 25 -DTITLE_BAR_FORMAT_RUNNING=${TITLE_BAR_FORMAT_RUNNING}
@@ -31,13 +31,13 @@ add_custom_command(OUTPUT scm_rev.cpp
31 -DGIT_BRANCH=${GIT_BRANCH} 31 -DGIT_BRANCH=${GIT_BRANCH}
32 -DBUILD_FULLNAME=${BUILD_FULLNAME} 32 -DBUILD_FULLNAME=${BUILD_FULLNAME}
33 -DGIT_EXECUTABLE=${GIT_EXECUTABLE} 33 -DGIT_EXECUTABLE=${GIT_EXECUTABLE}
34 -P ${CMAKE_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake 34 -P ${PROJECT_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake
35 DEPENDS 35 DEPENDS
36 # Check that the scm_rev files haven't changed 36 # Check that the scm_rev files haven't changed
37 "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in" 37 "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.cpp.in"
38 "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.h" 38 "${CMAKE_CURRENT_SOURCE_DIR}/scm_rev.h"
39 # technically we should regenerate if the git version changed, but its not worth the effort imo 39 # technically we should regenerate if the git version changed, but its not worth the effort imo
40 "${CMAKE_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake" 40 "${PROJECT_SOURCE_DIR}/CMakeModules/GenerateSCMRev.cmake"
41 VERBATIM 41 VERBATIM
42) 42)
43 43
@@ -124,6 +124,7 @@ add_library(common STATIC
124 settings.h 124 settings.h
125 settings_input.cpp 125 settings_input.cpp
126 settings_input.h 126 settings_input.h
127 socket_types.h
127 spin_lock.cpp 128 spin_lock.cpp
128 spin_lock.h 129 spin_lock.h
129 stream.cpp 130 stream.cpp
@@ -165,6 +166,7 @@ if(ARCHITECTURE_x86_64)
165 x64/xbyak_abi.h 166 x64/xbyak_abi.h
166 x64/xbyak_util.h 167 x64/xbyak_util.h
167 ) 168 )
169 target_link_libraries(common PRIVATE xbyak)
168endif() 170endif()
169 171
170if (MSVC) 172if (MSVC)
@@ -188,7 +190,7 @@ endif()
188create_target_directory_groups(common) 190create_target_directory_groups(common)
189 191
190target_link_libraries(common PUBLIC ${Boost_LIBRARIES} fmt::fmt microprofile Threads::Threads) 192target_link_libraries(common PUBLIC ${Boost_LIBRARIES} fmt::fmt microprofile Threads::Threads)
191target_link_libraries(common PRIVATE lz4::lz4 xbyak) 193target_link_libraries(common PRIVATE lz4::lz4)
192if (TARGET zstd::zstd) 194if (TARGET zstd::zstd)
193 target_link_libraries(common PRIVATE zstd::zstd) 195 target_link_libraries(common PRIVATE zstd::zstd)
194else() 196else()
diff --git a/src/common/announce_multiplayer_room.h b/src/common/announce_multiplayer_room.h
index 0ad9da2be..4a3100fa4 100644
--- a/src/common/announce_multiplayer_room.h
+++ b/src/common/announce_multiplayer_room.h
@@ -8,15 +8,15 @@
8#include <string> 8#include <string>
9#include <vector> 9#include <vector>
10#include "common/common_types.h" 10#include "common/common_types.h"
11#include "common/socket_types.h"
11#include "web_service/web_result.h" 12#include "web_service/web_result.h"
12 13
13namespace AnnounceMultiplayerRoom { 14namespace AnnounceMultiplayerRoom {
14 15
15using MacAddress = std::array<u8, 6>;
16
17struct GameInfo { 16struct GameInfo {
18 std::string name{""}; 17 std::string name{""};
19 u64 id{0}; 18 u64 id{0};
19 std::string version{""};
20}; 20};
21 21
22struct Member { 22struct Member {
@@ -24,7 +24,7 @@ struct Member {
24 std::string nickname; 24 std::string nickname;
25 std::string display_name; 25 std::string display_name;
26 std::string avatar_url; 26 std::string avatar_url;
27 MacAddress mac_address; 27 Network::IPv4Address fake_ip;
28 GameInfo game; 28 GameInfo game;
29}; 29};
30 30
@@ -75,10 +75,7 @@ public:
75 const bool has_password, const GameInfo& preferred_game) = 0; 75 const bool has_password, const GameInfo& preferred_game) = 0;
76 /** 76 /**
77 * Adds a player information to the data that gets announced 77 * Adds a player information to the data that gets announced
78 * @param nickname The nickname of the player 78 * @param member The player to add
79 * @param mac_address The MAC Address of the player
80 * @param game_id The title id of the game the player plays
81 * @param game_name The name of the game the player plays
82 */ 79 */
83 virtual void AddPlayer(const Member& member) = 0; 80 virtual void AddPlayer(const Member& member) = 0;
84 81
diff --git a/src/common/input.h b/src/common/input.h
index 213aa2384..825b0d650 100644
--- a/src/common/input.h
+++ b/src/common/input.h
@@ -102,6 +102,8 @@ struct AnalogProperties {
102 float offset{}; 102 float offset{};
103 // Invert direction of the sensor data 103 // Invert direction of the sensor data
104 bool inverted{}; 104 bool inverted{};
105 // Press once to activate, press again to release
106 bool toggle{};
105}; 107};
106 108
107// Single analog sensor data 109// Single analog sensor data
@@ -115,8 +117,11 @@ struct AnalogStatus {
115struct ButtonStatus { 117struct ButtonStatus {
116 Common::UUID uuid{}; 118 Common::UUID uuid{};
117 bool value{}; 119 bool value{};
120 // Invert value of the button
118 bool inverted{}; 121 bool inverted{};
122 // Press once to activate, press again to release
119 bool toggle{}; 123 bool toggle{};
124 // Internal lock for the toggle status
120 bool locked{}; 125 bool locked{};
121}; 126};
122 127
diff --git a/src/common/microprofile.h b/src/common/microprofile.h
index 91d14d5e1..56ef0a2dc 100644
--- a/src/common/microprofile.h
+++ b/src/common/microprofile.h
@@ -22,12 +22,3 @@ typedef void* HANDLE;
22#include <microprofile.h> 22#include <microprofile.h>
23 23
24#define MP_RGB(r, g, b) ((r) << 16 | (g) << 8 | (b) << 0) 24#define MP_RGB(r, g, b) ((r) << 16 | (g) << 8 | (b) << 0)
25
26// On OS X, some Mach header included by MicroProfile defines these as macros, conflicting with
27// identifiers we use.
28#ifdef PAGE_SIZE
29#undef PAGE_SIZE
30#endif
31#ifdef PAGE_MASK
32#undef PAGE_MASK
33#endif
diff --git a/src/common/parent_of_member.h b/src/common/parent_of_member.h
index 70b1c5624..8e03f17d8 100644
--- a/src/common/parent_of_member.h
+++ b/src/common/parent_of_member.h
@@ -11,7 +11,7 @@ namespace Common {
11namespace detail { 11namespace detail {
12template <typename T, size_t Size, size_t Align> 12template <typename T, size_t Size, size_t Align>
13struct TypedStorageImpl { 13struct TypedStorageImpl {
14 std::aligned_storage_t<Size, Align> storage_; 14 alignas(Align) u8 storage_[Size];
15}; 15};
16} // namespace detail 16} // namespace detail
17 17
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 1c7b6dfae..0a560ebb7 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -105,7 +105,7 @@ float Volume() {
105 if (values.audio_muted) { 105 if (values.audio_muted) {
106 return 0.0f; 106 return 0.0f;
107 } 107 }
108 return values.volume.GetValue() / 100.0f; 108 return values.volume.GetValue() / static_cast<f32>(values.volume.GetDefault());
109} 109}
110 110
111void UpdateRescalingInfo() { 111void UpdateRescalingInfo() {
@@ -195,6 +195,7 @@ void RestoreGlobalState(bool is_powered_on) {
195 values.shader_backend.SetGlobal(true); 195 values.shader_backend.SetGlobal(true);
196 values.use_asynchronous_shaders.SetGlobal(true); 196 values.use_asynchronous_shaders.SetGlobal(true);
197 values.use_fast_gpu_time.SetGlobal(true); 197 values.use_fast_gpu_time.SetGlobal(true);
198 values.use_pessimistic_flushes.SetGlobal(true);
198 values.bg_red.SetGlobal(true); 199 values.bg_red.SetGlobal(true);
199 values.bg_green.SetGlobal(true); 200 values.bg_green.SetGlobal(true);
200 values.bg_blue.SetGlobal(true); 201 values.bg_blue.SetGlobal(true);
diff --git a/src/common/settings.h b/src/common/settings.h
index 1079cf8cb..851812f28 100644
--- a/src/common/settings.h
+++ b/src/common/settings.h
@@ -374,7 +374,7 @@ struct Values {
374 Setting<std::string> audio_output_device_id{"auto", "output_device"}; 374 Setting<std::string> audio_output_device_id{"auto", "output_device"};
375 Setting<std::string> audio_input_device_id{"auto", "input_device"}; 375 Setting<std::string> audio_input_device_id{"auto", "input_device"};
376 Setting<bool> audio_muted{false, "audio_muted"}; 376 Setting<bool> audio_muted{false, "audio_muted"};
377 SwitchableSetting<u8, true> volume{100, 0, 100, "volume"}; 377 SwitchableSetting<u8, true> volume{100, 0, 200, "volume"};
378 Setting<bool> dump_audio_commands{false, "dump_audio_commands"}; 378 Setting<bool> dump_audio_commands{false, "dump_audio_commands"};
379 379
380 // Core 380 // Core
@@ -446,6 +446,7 @@ struct Values {
446 ShaderBackend::SPIRV, "shader_backend"}; 446 ShaderBackend::SPIRV, "shader_backend"};
447 SwitchableSetting<bool> use_asynchronous_shaders{false, "use_asynchronous_shaders"}; 447 SwitchableSetting<bool> use_asynchronous_shaders{false, "use_asynchronous_shaders"};
448 SwitchableSetting<bool> use_fast_gpu_time{true, "use_fast_gpu_time"}; 448 SwitchableSetting<bool> use_fast_gpu_time{true, "use_fast_gpu_time"};
449 SwitchableSetting<bool> use_pessimistic_flushes{false, "use_pessimistic_flushes"};
449 450
450 SwitchableSetting<u8> bg_red{0, "bg_red"}; 451 SwitchableSetting<u8> bg_red{0, "bg_red"};
451 SwitchableSetting<u8> bg_green{0, "bg_green"}; 452 SwitchableSetting<u8> bg_green{0, "bg_green"};
@@ -529,6 +530,7 @@ struct Values {
529 Setting<bool> use_debug_asserts{false, "use_debug_asserts"}; 530 Setting<bool> use_debug_asserts{false, "use_debug_asserts"};
530 Setting<bool> use_auto_stub{false, "use_auto_stub"}; 531 Setting<bool> use_auto_stub{false, "use_auto_stub"};
531 Setting<bool> enable_all_controllers{false, "enable_all_controllers"}; 532 Setting<bool> enable_all_controllers{false, "enable_all_controllers"};
533 Setting<bool> create_crash_dumps{false, "create_crash_dumps"};
532 534
533 // Miscellaneous 535 // Miscellaneous
534 Setting<std::string> log_filter{"*:Info", "log_filter"}; 536 Setting<std::string> log_filter{"*:Info", "log_filter"};
diff --git a/src/common/socket_types.h b/src/common/socket_types.h
new file mode 100644
index 000000000..0a801a443
--- /dev/null
+++ b/src/common/socket_types.h
@@ -0,0 +1,51 @@
1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "common/common_types.h"
7
8namespace Network {
9
10/// Address families
11enum class Domain : u8 {
12 INET, ///< Address family for IPv4
13};
14
15/// Socket types
16enum class Type {
17 STREAM,
18 DGRAM,
19 RAW,
20 SEQPACKET,
21};
22
23/// Protocol values for sockets
24enum class Protocol : u8 {
25 ICMP,
26 TCP,
27 UDP,
28};
29
30/// Shutdown mode
31enum class ShutdownHow {
32 RD,
33 WR,
34 RDWR,
35};
36
37/// Array of IPv4 address
38using IPv4Address = std::array<u8, 4>;
39
40/// Cross-platform sockaddr structure
41struct SockAddrIn {
42 Domain family;
43 IPv4Address ip;
44 u16 portno;
45};
46
47constexpr u32 FLAG_MSG_PEEK = 0x2;
48constexpr u32 FLAG_MSG_DONTWAIT = 0x80;
49constexpr u32 FLAG_O_NONBLOCK = 0x800;
50
51} // namespace Network
diff --git a/src/common/uint128.h b/src/common/uint128.h
index f890ffec2..f450a6db9 100644
--- a/src/common/uint128.h
+++ b/src/common/uint128.h
@@ -12,7 +12,6 @@
12#pragma intrinsic(_udiv128) 12#pragma intrinsic(_udiv128)
13#else 13#else
14#include <cstring> 14#include <cstring>
15#include <x86intrin.h>
16#endif 15#endif
17 16
18#include "common/common_types.h" 17#include "common/common_types.h"