diff options
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/CMakeLists.txt | 7 | ||||
| -rw-r--r-- | src/common/bit_field.h | 15 | ||||
| -rw-r--r-- | src/common/bounded_threadsafe_queue.h | 9 | ||||
| -rw-r--r-- | src/common/concepts.h | 16 | ||||
| -rw-r--r-- | src/common/fs/file.h | 12 | ||||
| -rw-r--r-- | src/common/input.h | 5 |
6 files changed, 28 insertions, 36 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 46cf75fde..c0555f840 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt | |||
| @@ -156,12 +156,13 @@ if (MSVC) | |||
| 156 | ) | 156 | ) |
| 157 | target_compile_options(common PRIVATE | 157 | target_compile_options(common PRIVATE |
| 158 | /W4 | 158 | /W4 |
| 159 | /WX | 159 | |
| 160 | /we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data | ||
| 161 | /we4254 # 'operator': conversion from 'type1:field_bits' to 'type2:field_bits', possible loss of data | ||
| 162 | /we4800 # Implicit conversion from 'type' to bool. Possible information loss | ||
| 160 | ) | 163 | ) |
| 161 | else() | 164 | else() |
| 162 | target_compile_options(common PRIVATE | 165 | target_compile_options(common PRIVATE |
| 163 | -Werror | ||
| 164 | |||
| 165 | $<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation> | 166 | $<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation> |
| 166 | ) | 167 | ) |
| 167 | endif() | 168 | endif() |
diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 7e1df62b1..e4e58ea45 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h | |||
| @@ -141,10 +141,6 @@ public: | |||
| 141 | constexpr BitField(BitField&&) noexcept = default; | 141 | constexpr BitField(BitField&&) noexcept = default; |
| 142 | constexpr BitField& operator=(BitField&&) noexcept = default; | 142 | constexpr BitField& operator=(BitField&&) noexcept = default; |
| 143 | 143 | ||
| 144 | [[nodiscard]] constexpr operator T() const { | ||
| 145 | return Value(); | ||
| 146 | } | ||
| 147 | |||
| 148 | constexpr void Assign(const T& value) { | 144 | constexpr void Assign(const T& value) { |
| 149 | #ifdef _MSC_VER | 145 | #ifdef _MSC_VER |
| 150 | storage = static_cast<StorageType>((storage & ~mask) | FormatValue(value)); | 146 | storage = static_cast<StorageType>((storage & ~mask) | FormatValue(value)); |
| @@ -162,6 +158,17 @@ public: | |||
| 162 | return ExtractValue(storage); | 158 | return ExtractValue(storage); |
| 163 | } | 159 | } |
| 164 | 160 | ||
| 161 | template <typename ConvertedToType> | ||
| 162 | [[nodiscard]] constexpr ConvertedToType As() const { | ||
| 163 | static_assert(!std::is_same_v<T, ConvertedToType>, | ||
| 164 | "Unnecessary cast. Use Value() instead."); | ||
| 165 | return static_cast<ConvertedToType>(Value()); | ||
| 166 | } | ||
| 167 | |||
| 168 | [[nodiscard]] constexpr operator T() const { | ||
| 169 | return Value(); | ||
| 170 | } | ||
| 171 | |||
| 165 | [[nodiscard]] constexpr explicit operator bool() const { | 172 | [[nodiscard]] constexpr explicit operator bool() const { |
| 166 | return Value() != 0; | 173 | return Value() != 0; |
| 167 | } | 174 | } |
diff --git a/src/common/bounded_threadsafe_queue.h b/src/common/bounded_threadsafe_queue.h index 7e465549b..21217801e 100644 --- a/src/common/bounded_threadsafe_queue.h +++ b/src/common/bounded_threadsafe_queue.h | |||
| @@ -21,11 +21,6 @@ constexpr size_t hardware_interference_size = std::hardware_destructive_interfer | |||
| 21 | constexpr size_t hardware_interference_size = 64; | 21 | constexpr size_t hardware_interference_size = 64; |
| 22 | #endif | 22 | #endif |
| 23 | 23 | ||
| 24 | #ifdef _MSC_VER | ||
| 25 | #pragma warning(push) | ||
| 26 | #pragma warning(disable : 4324) | ||
| 27 | #endif | ||
| 28 | |||
| 29 | template <typename T, size_t capacity = 0x400> | 24 | template <typename T, size_t capacity = 0x400> |
| 30 | class MPSCQueue { | 25 | class MPSCQueue { |
| 31 | public: | 26 | public: |
| @@ -160,8 +155,4 @@ private: | |||
| 160 | static_assert(std::is_nothrow_destructible_v<T>, "T must be nothrow destructible"); | 155 | static_assert(std::is_nothrow_destructible_v<T>, "T must be nothrow destructible"); |
| 161 | }; | 156 | }; |
| 162 | 157 | ||
| 163 | #ifdef _MSC_VER | ||
| 164 | #pragma warning(pop) | ||
| 165 | #endif | ||
| 166 | |||
| 167 | } // namespace Common | 158 | } // namespace Common |
diff --git a/src/common/concepts.h b/src/common/concepts.h index e8ce30dfe..a9acff3e7 100644 --- a/src/common/concepts.h +++ b/src/common/concepts.h | |||
| @@ -3,24 +3,14 @@ | |||
| 3 | 3 | ||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <iterator> | ||
| 6 | #include <type_traits> | 7 | #include <type_traits> |
| 7 | 8 | ||
| 8 | namespace Common { | 9 | namespace Common { |
| 9 | 10 | ||
| 10 | // Check if type is like an STL container | 11 | // Check if type satisfies the ContiguousContainer named requirement. |
| 11 | template <typename T> | 12 | template <typename T> |
| 12 | concept IsSTLContainer = requires(T t) { | 13 | concept IsContiguousContainer = std::contiguous_iterator<typename T::iterator>; |
| 13 | typename T::value_type; | ||
| 14 | typename T::iterator; | ||
| 15 | typename T::const_iterator; | ||
| 16 | // TODO(ogniK): Replace below is std::same_as<void> when MSVC supports it. | ||
| 17 | t.begin(); | ||
| 18 | t.end(); | ||
| 19 | t.cbegin(); | ||
| 20 | t.cend(); | ||
| 21 | t.data(); | ||
| 22 | t.size(); | ||
| 23 | }; | ||
| 24 | 14 | ||
| 25 | // TODO: Replace with std::derived_from when the <concepts> header | 15 | // TODO: Replace with std::derived_from when the <concepts> header |
| 26 | // is available on all supported platforms. | 16 | // is available on all supported platforms. |
diff --git a/src/common/fs/file.h b/src/common/fs/file.h index 69b53384c..167c4d826 100644 --- a/src/common/fs/file.h +++ b/src/common/fs/file.h | |||
| @@ -209,8 +209,8 @@ public: | |||
| 209 | 209 | ||
| 210 | /** | 210 | /** |
| 211 | * Helper function which deduces the value type of a contiguous STL container used in ReadSpan. | 211 | * Helper function which deduces the value type of a contiguous STL container used in ReadSpan. |
| 212 | * If T is not a contiguous STL container as defined by the concept IsSTLContainer, this calls | 212 | * If T is not a contiguous container as defined by the concept IsContiguousContainer, this |
| 213 | * ReadObject and T must be a trivially copyable object. | 213 | * calls ReadObject and T must be a trivially copyable object. |
| 214 | * | 214 | * |
| 215 | * See ReadSpan for more details if T is a contiguous container. | 215 | * See ReadSpan for more details if T is a contiguous container. |
| 216 | * See ReadObject for more details if T is a trivially copyable object. | 216 | * See ReadObject for more details if T is a trivially copyable object. |
| @@ -223,7 +223,7 @@ public: | |||
| 223 | */ | 223 | */ |
| 224 | template <typename T> | 224 | template <typename T> |
| 225 | [[nodiscard]] size_t Read(T& data) const { | 225 | [[nodiscard]] size_t Read(T& data) const { |
| 226 | if constexpr (IsSTLContainer<T>) { | 226 | if constexpr (IsContiguousContainer<T>) { |
| 227 | using ContiguousType = typename T::value_type; | 227 | using ContiguousType = typename T::value_type; |
| 228 | static_assert(std::is_trivially_copyable_v<ContiguousType>, | 228 | static_assert(std::is_trivially_copyable_v<ContiguousType>, |
| 229 | "Data type must be trivially copyable."); | 229 | "Data type must be trivially copyable."); |
| @@ -235,8 +235,8 @@ public: | |||
| 235 | 235 | ||
| 236 | /** | 236 | /** |
| 237 | * Helper function which deduces the value type of a contiguous STL container used in WriteSpan. | 237 | * Helper function which deduces the value type of a contiguous STL container used in WriteSpan. |
| 238 | * If T is not a contiguous STL container as defined by the concept IsSTLContainer, this calls | 238 | * If T is not a contiguous STL container as defined by the concept IsContiguousContainer, this |
| 239 | * WriteObject and T must be a trivially copyable object. | 239 | * calls WriteObject and T must be a trivially copyable object. |
| 240 | * | 240 | * |
| 241 | * See WriteSpan for more details if T is a contiguous container. | 241 | * See WriteSpan for more details if T is a contiguous container. |
| 242 | * See WriteObject for more details if T is a trivially copyable object. | 242 | * See WriteObject for more details if T is a trivially copyable object. |
| @@ -249,7 +249,7 @@ public: | |||
| 249 | */ | 249 | */ |
| 250 | template <typename T> | 250 | template <typename T> |
| 251 | [[nodiscard]] size_t Write(const T& data) const { | 251 | [[nodiscard]] size_t Write(const T& data) const { |
| 252 | if constexpr (IsSTLContainer<T>) { | 252 | if constexpr (IsContiguousContainer<T>) { |
| 253 | using ContiguousType = typename T::value_type; | 253 | using ContiguousType = typename T::value_type; |
| 254 | static_assert(std::is_trivially_copyable_v<ContiguousType>, | 254 | static_assert(std::is_trivially_copyable_v<ContiguousType>, |
| 255 | "Data type must be trivially copyable."); | 255 | "Data type must be trivially copyable."); |
diff --git a/src/common/input.h b/src/common/input.h index b533f3844..cb30b7254 100644 --- a/src/common/input.h +++ b/src/common/input.h | |||
| @@ -100,7 +100,6 @@ enum class CameraError { | |||
| 100 | enum class VibrationAmplificationType { | 100 | enum class VibrationAmplificationType { |
| 101 | Linear, | 101 | Linear, |
| 102 | Exponential, | 102 | Exponential, |
| 103 | Test, | ||
| 104 | }; | 103 | }; |
| 105 | 104 | ||
| 106 | // Analog properties for calibration | 105 | // Analog properties for calibration |
| @@ -325,6 +324,10 @@ public: | |||
| 325 | return VibrationError::NotSupported; | 324 | return VibrationError::NotSupported; |
| 326 | } | 325 | } |
| 327 | 326 | ||
| 327 | virtual bool IsVibrationEnabled() { | ||
| 328 | return false; | ||
| 329 | } | ||
| 330 | |||
| 328 | virtual PollingError SetPollingMode([[maybe_unused]] PollingMode polling_mode) { | 331 | virtual PollingError SetPollingMode([[maybe_unused]] PollingMode polling_mode) { |
| 329 | return PollingError::NotSupported; | 332 | return PollingError::NotSupported; |
| 330 | } | 333 | } |