summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/param_package.cpp19
-rw-r--r--src/common/param_package.h2
-rw-r--r--src/core/hle/ipc_helpers.h19
-rw-r--r--src/core/hle/service/apm/interface.cpp17
4 files changed, 47 insertions, 10 deletions
diff --git a/src/common/param_package.cpp b/src/common/param_package.cpp
index e0df430ab..9526ca0c6 100644
--- a/src/common/param_package.cpp
+++ b/src/common/param_package.cpp
@@ -3,7 +3,9 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <array> 5#include <array>
6#include <utility>
6#include <vector> 7#include <vector>
8
7#include "common/logging/log.h" 9#include "common/logging/log.h"
8#include "common/param_package.h" 10#include "common/param_package.h"
9#include "common/string_util.h" 11#include "common/string_util.h"
@@ -12,10 +14,11 @@ namespace Common {
12 14
13constexpr char KEY_VALUE_SEPARATOR = ':'; 15constexpr char KEY_VALUE_SEPARATOR = ':';
14constexpr char PARAM_SEPARATOR = ','; 16constexpr char PARAM_SEPARATOR = ',';
17
15constexpr char ESCAPE_CHARACTER = '$'; 18constexpr char ESCAPE_CHARACTER = '$';
16const std::string KEY_VALUE_SEPARATOR_ESCAPE{ESCAPE_CHARACTER, '0'}; 19constexpr char KEY_VALUE_SEPARATOR_ESCAPE[] = "$0";
17const std::string PARAM_SEPARATOR_ESCAPE{ESCAPE_CHARACTER, '1'}; 20constexpr char PARAM_SEPARATOR_ESCAPE[] = "$1";
18const std::string ESCAPE_CHARACTER_ESCAPE{ESCAPE_CHARACTER, '2'}; 21constexpr char ESCAPE_CHARACTER_ESCAPE[] = "$2";
19 22
20ParamPackage::ParamPackage(const std::string& serialized) { 23ParamPackage::ParamPackage(const std::string& serialized) {
21 std::vector<std::string> pairs; 24 std::vector<std::string> pairs;
@@ -35,7 +38,7 @@ ParamPackage::ParamPackage(const std::string& serialized) {
35 part = Common::ReplaceAll(part, ESCAPE_CHARACTER_ESCAPE, {ESCAPE_CHARACTER}); 38 part = Common::ReplaceAll(part, ESCAPE_CHARACTER_ESCAPE, {ESCAPE_CHARACTER});
36 } 39 }
37 40
38 Set(key_value[0], key_value[1]); 41 Set(key_value[0], std::move(key_value[1]));
39 } 42 }
40} 43}
41 44
@@ -101,16 +104,16 @@ float ParamPackage::Get(const std::string& key, float default_value) const {
101 } 104 }
102} 105}
103 106
104void ParamPackage::Set(const std::string& key, const std::string& value) { 107void ParamPackage::Set(const std::string& key, std::string value) {
105 data[key] = value; 108 data.insert_or_assign(key, std::move(value));
106} 109}
107 110
108void ParamPackage::Set(const std::string& key, int value) { 111void ParamPackage::Set(const std::string& key, int value) {
109 data[key] = std::to_string(value); 112 data.insert_or_assign(key, std::to_string(value));
110} 113}
111 114
112void ParamPackage::Set(const std::string& key, float value) { 115void ParamPackage::Set(const std::string& key, float value) {
113 data[key] = std::to_string(value); 116 data.insert_or_assign(key, std::to_string(value));
114} 117}
115 118
116bool ParamPackage::Has(const std::string& key) const { 119bool ParamPackage::Has(const std::string& key) const {
diff --git a/src/common/param_package.h b/src/common/param_package.h
index c4c11b221..7842cd4ef 100644
--- a/src/common/param_package.h
+++ b/src/common/param_package.h
@@ -28,7 +28,7 @@ public:
28 std::string Get(const std::string& key, const std::string& default_value) const; 28 std::string Get(const std::string& key, const std::string& default_value) const;
29 int Get(const std::string& key, int default_value) const; 29 int Get(const std::string& key, int default_value) const;
30 float Get(const std::string& key, float default_value) const; 30 float Get(const std::string& key, float default_value) const;
31 void Set(const std::string& key, const std::string& value); 31 void Set(const std::string& key, std::string value);
32 void Set(const std::string& key, int value); 32 void Set(const std::string& key, int value);
33 void Set(const std::string& key, float value); 33 void Set(const std::string& key, float value);
34 bool Has(const std::string& key) const; 34 bool Has(const std::string& key) const;
diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h
index 24605a273..8b5b06f31 100644
--- a/src/core/hle/ipc_helpers.h
+++ b/src/core/hle/ipc_helpers.h
@@ -175,6 +175,25 @@ public:
175 void Push(const First& first_value, const Other&... other_values); 175 void Push(const First& first_value, const Other&... other_values);
176 176
177 /** 177 /**
178 * Helper function for pushing strongly-typed enumeration values.
179 *
180 * @tparam Enum The enumeration type to be pushed
181 *
182 * @param value The value to push.
183 *
184 * @note The underlying size of the enumeration type is the size of the
185 * data that gets pushed. e.g. "enum class SomeEnum : u16" will
186 * push a u16-sized amount of data.
187 */
188 template <typename Enum>
189 void PushEnum(Enum value) {
190 static_assert(std::is_enum_v<Enum>, "T must be an enum type within a PushEnum call.");
191 static_assert(!std::is_convertible_v<Enum, int>,
192 "enum type in PushEnum must be a strongly typed enum.");
193 Push(static_cast<std::underlying_type_t<Enum>>(value));
194 }
195
196 /**
178 * @brief Copies the content of the given trivially copyable class to the buffer as a normal 197 * @brief Copies the content of the given trivially copyable class to the buffer as a normal
179 * param 198 * param
180 * @note: The input class must be correctly packed/padded to fit hardware layout. 199 * @note: The input class must be correctly packed/padded to fit hardware layout.
diff --git a/src/core/hle/service/apm/interface.cpp b/src/core/hle/service/apm/interface.cpp
index 751d73f8d..ce943d829 100644
--- a/src/core/hle/service/apm/interface.cpp
+++ b/src/core/hle/service/apm/interface.cpp
@@ -20,6 +20,21 @@ public:
20 } 20 }
21 21
22private: 22private:
23 enum class PerformanceConfiguration : u32 {
24 Config1 = 0x00010000,
25 Config2 = 0x00010001,
26 Config3 = 0x00010002,
27 Config4 = 0x00020000,
28 Config5 = 0x00020001,
29 Config6 = 0x00020002,
30 Config7 = 0x00020003,
31 Config8 = 0x00020004,
32 Config9 = 0x00020005,
33 Config10 = 0x00020006,
34 Config11 = 0x92220007,
35 Config12 = 0x92220008,
36 };
37
23 void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) { 38 void SetPerformanceConfiguration(Kernel::HLERequestContext& ctx) {
24 IPC::RequestParser rp{ctx}; 39 IPC::RequestParser rp{ctx};
25 40
@@ -40,7 +55,7 @@ private:
40 55
41 IPC::ResponseBuilder rb{ctx, 3}; 56 IPC::ResponseBuilder rb{ctx, 3};
42 rb.Push(RESULT_SUCCESS); 57 rb.Push(RESULT_SUCCESS);
43 rb.Push<u32>(0); // Performance configuration 58 rb.Push<u32>(static_cast<u32>(PerformanceConfiguration::Config1));
44 59
45 LOG_WARNING(Service_APM, "(STUBBED) called mode={}", static_cast<u32>(mode)); 60 LOG_WARNING(Service_APM, "(STUBBED) called mode={}", static_cast<u32>(mode));
46 } 61 }