summaryrefslogtreecommitdiff
path: root/src/input_common/helpers
diff options
context:
space:
mode:
authorGravatar bunnei2021-12-17 23:43:19 -0800
committerGravatar GitHub2021-12-17 23:43:19 -0800
commit212b497d5c60676036dcd541ca54cf0ab260f344 (patch)
treebdfb846bdec1bbd04cf827017f3adba5cccb9a6c /src/input_common/helpers
parentMerge pull request #7399 from ameerj/art-refactor (diff)
parent[input_common] Move variable declaration closer to usage (diff)
downloadyuzu-212b497d5c60676036dcd541ca54cf0ab260f344.tar.gz
yuzu-212b497d5c60676036dcd541ca54cf0ab260f344.tar.xz
yuzu-212b497d5c60676036dcd541ca54cf0ab260f344.zip
Merge pull request #7302 from VPeruS/check-deadlock
[input_common] Fixed thread hang
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 {
54template <typename T> 54template <typename T>
55constexpr Type GetMessageType(); 55constexpr Type GetMessageType();
56 56
57template <typename T>
58Message<T> CreateMessage(const u32 magic, const T data, const u32 sender_id) {
59 boost::crc_32_type crc;
60 Header header{
61 magic, PROTOCOL_VERSION, sizeof(T) + sizeof(Type), 0, sender_id, GetMessageType<T>(),
62 };
63 Message<T> message{header, data};
64 crc.process_bytes(&message, sizeof(Message<T>));
65 message.header.crc = crc.checksum();
66 return message;
67}
68
57namespace Request { 69namespace Request {
58 70
59enum RegisterFlags : u8 { 71enum RegisterFlags : u8 {
@@ -101,14 +113,7 @@ static_assert(std::is_trivially_copyable_v<PadData>,
101 */ 113 */
102template <typename T> 114template <typename T>
103Message<T> Create(const T data, const u32 client_id = 0) { 115Message<T> Create(const T data, const u32 client_id = 0) {
104 boost::crc_32_type crc; 116 return CreateMessage(CLIENT_MAGIC, data, client_id);
105 Header header{
106 CLIENT_MAGIC, PROTOCOL_VERSION, sizeof(T) + sizeof(Type), 0, client_id, GetMessageType<T>(),
107 };
108 Message<T> message{header, data};
109 crc.process_bytes(&message, sizeof(Message<T>));
110 message.header.crc = crc.checksum();
111 return message;
112} 117}
113} // namespace Request 118} // namespace Request
114 119