summaryrefslogtreecommitdiffstats
path: root/src/input_common/helpers
diff options
context:
space:
mode:
authorvperus <vperus@gmail.com>2021-11-07 13:56:33 +0100
committervperus <vperus@gmail.com>2021-11-29 15:33:12 +0100
commit04fa990b0ced02a7011ad4801d8c956cbc1f65ab (patch)
treeeacea725e34348119594f1cb153fcf24aefde666 /src/input_common/helpers
parentMerge pull request #7396 from FernandoS27/blit-this-mf (diff)
downloadyuzu-04fa990b0ced02a7011ad4801d8c956cbc1f65ab.tar
yuzu-04fa990b0ced02a7011ad4801d8c956cbc1f65ab.tar.gz
yuzu-04fa990b0ced02a7011ad4801d8c956cbc1f65ab.tar.bz2
yuzu-04fa990b0ced02a7011ad4801d8c956cbc1f65ab.tar.lz
yuzu-04fa990b0ced02a7011ad4801d8c956cbc1f65ab.tar.xz
yuzu-04fa990b0ced02a7011ad4801d8c956cbc1f65ab.tar.zst
yuzu-04fa990b0ced02a7011ad4801d8c956cbc1f65ab.zip
Diffstat (limited to 'src/input_common/helpers')
-rw-r--r--src/input_common/helpers/udp_protocol.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/input_common/helpers/udp_protocol.h b/src/input_common/helpers/udp_protocol.h
index bcba12c58..2d5d54ddb 100644
--- a/src/input_common/helpers/udp_protocol.h
+++ b/src/input_common/helpers/udp_protocol.h
@@ -54,6 +54,18 @@ struct Message {
template <typename T>
constexpr Type GetMessageType();
+template <typename T>
+Message<T> CreateMessage(const u32 magic, const T data, const u32 sender_id) {
+ boost::crc_32_type crc;
+ Header header{
+ magic, PROTOCOL_VERSION, sizeof(T) + sizeof(Type), 0, sender_id, GetMessageType<T>(),
+ };
+ Message<T> message{header, data};
+ crc.process_bytes(&message, sizeof(Message<T>));
+ message.header.crc = crc.checksum();
+ return message;
+}
+
namespace Request {
enum RegisterFlags : u8 {
@@ -101,14 +113,7 @@ static_assert(std::is_trivially_copyable_v<PadData>,
*/
template <typename T>
Message<T> Create(const T data, const u32 client_id = 0) {
- boost::crc_32_type crc;
- Header header{
- CLIENT_MAGIC, PROTOCOL_VERSION, sizeof(T) + sizeof(Type), 0, client_id, GetMessageType<T>(),
- };
- Message<T> message{header, data};
- crc.process_bytes(&message, sizeof(Message<T>));
- message.header.crc = crc.checksum();
- return message;
+ return CreateMessage(CLIENT_MAGIC, data, client_id);
}
} // namespace Request