summaryrefslogtreecommitdiff
path: root/src/input_common/udp/protocol.h
diff options
context:
space:
mode:
authorGravatar Ameer2020-06-21 13:02:43 -0400
committerGravatar Ameer2020-06-21 13:02:43 -0400
commit0076a08d04017036b12405bfb933fa9272f8b0cd (patch)
tree69eda77b0bc11a6f13a002f62517c333fa7635a2 /src/input_common/udp/protocol.h
parentAdd libusb dependency (diff)
downloadyuzu-0076a08d04017036b12405bfb933fa9272f8b0cd.tar.gz
yuzu-0076a08d04017036b12405bfb933fa9272f8b0cd.tar.xz
yuzu-0076a08d04017036b12405bfb933fa9272f8b0cd.zip
Cleanup after linter
Diffstat (limited to 'src/input_common/udp/protocol.h')
-rw-r--r--src/input_common/udp/protocol.h32
1 files changed, 9 insertions, 23 deletions
diff --git a/src/input_common/udp/protocol.h b/src/input_common/udp/protocol.h
index 2b31846db..3ba4d1fc8 100644
--- a/src/input_common/udp/protocol.h
+++ b/src/input_common/udp/protocol.h
@@ -35,7 +35,6 @@ struct Header {
35 ///> the data 35 ///> the data
36 Type type{}; 36 Type type{};
37}; 37};
38
39static_assert(sizeof(Header) == 20, "UDP Message Header struct has wrong size"); 38static_assert(sizeof(Header) == 20, "UDP Message Header struct has wrong size");
40static_assert(std::is_trivially_copyable_v<Header>, "UDP Message Header is not trivially copyable"); 39static_assert(std::is_trivially_copyable_v<Header>, "UDP Message Header is not trivially copyable");
41 40
@@ -55,9 +54,7 @@ constexpr Type GetMessageType();
55 54
56namespace Request { 55namespace Request {
57 56
58struct Version { 57struct Version {};
59};
60
61/** 58/**
62 * Requests the server to send information about what controllers are plugged into the ports 59 * Requests the server to send information about what controllers are plugged into the ports
63 * In citra's case, we only have one controller, so for simplicity's sake, we can just send a 60 * In citra's case, we only have one controller, so for simplicity's sake, we can just send a
@@ -65,14 +62,12 @@ struct Version {
65 * nice to make this configurable 62 * nice to make this configurable
66 */ 63 */
67constexpr u32 MAX_PORTS = 4; 64constexpr u32 MAX_PORTS = 4;
68
69struct PortInfo { 65struct PortInfo {
70 u32_le pad_count{}; ///> Number of ports to request data for 66 u32_le pad_count{}; ///> Number of ports to request data for
71 std::array<u8, MAX_PORTS> port; 67 std::array<u8, MAX_PORTS> port;
72}; 68};
73
74static_assert(std::is_trivially_copyable_v<PortInfo>, 69static_assert(std::is_trivially_copyable_v<PortInfo>,
75 "UDP Request PortInfo is not trivially copyable"); 70 "UDP Request PortInfo is not trivially copyable");
76 71
77/** 72/**
78 * Request the latest pad information from the server. If the server hasn't received this message 73 * Request the latest pad information from the server. If the server hasn't received this message
@@ -85,7 +80,6 @@ struct PadData {
85 Id, 80 Id,
86 Mac, 81 Mac,
87 }; 82 };
88
89 /// Determines which method will be used as a look up for the controller 83 /// Determines which method will be used as a look up for the controller
90 Flags flags{}; 84 Flags flags{};
91 /// Index of the port of the controller to retrieve data about 85 /// Index of the port of the controller to retrieve data about
@@ -93,10 +87,9 @@ struct PadData {
93 /// Mac address of the controller to retrieve data about 87 /// Mac address of the controller to retrieve data about
94 MacAddress mac; 88 MacAddress mac;
95}; 89};
96
97static_assert(sizeof(PadData) == 8, "UDP Request PadData struct has wrong size"); 90static_assert(sizeof(PadData) == 8, "UDP Request PadData struct has wrong size");
98static_assert(std::is_trivially_copyable_v<PadData>, 91static_assert(std::is_trivially_copyable_v<PadData>,
99 "UDP Request PadData is not trivially copyable"); 92 "UDP Request PadData is not trivially copyable");
100 93
101/** 94/**
102 * Creates a message with the proper header data that can be sent to the server. 95 * Creates a message with the proper header data that can be sent to the server.
@@ -121,10 +114,9 @@ namespace Response {
121struct Version { 114struct Version {
122 u16_le version{}; 115 u16_le version{};
123}; 116};
124
125static_assert(sizeof(Version) == 2, "UDP Response Version struct has wrong size"); 117static_assert(sizeof(Version) == 2, "UDP Response Version struct has wrong size");
126static_assert(std::is_trivially_copyable_v<Version>, 118static_assert(std::is_trivially_copyable_v<Version>,
127 "UDP Response Version is not trivially copyable"); 119 "UDP Response Version is not trivially copyable");
128 120
129struct PortInfo { 121struct PortInfo {
130 u8 id{}; 122 u8 id{};
@@ -135,10 +127,9 @@ struct PortInfo {
135 u8 battery{}; 127 u8 battery{};
136 u8 is_pad_active{}; 128 u8 is_pad_active{};
137}; 129};
138
139static_assert(sizeof(PortInfo) == 12, "UDP Response PortInfo struct has wrong size"); 130static_assert(sizeof(PortInfo) == 12, "UDP Response PortInfo struct has wrong size");
140static_assert(std::is_trivially_copyable_v<PortInfo>, 131static_assert(std::is_trivially_copyable_v<PortInfo>,
141 "UDP Response PortInfo is not trivially copyable"); 132 "UDP Response PortInfo is not trivially copyable");
142 133
143#pragma pack(push, 1) 134#pragma pack(push, 1)
144struct PadData { 135struct PadData {
@@ -215,16 +206,16 @@ struct PadData {
215 206
216static_assert(sizeof(PadData) == 80, "UDP Response PadData struct has wrong size "); 207static_assert(sizeof(PadData) == 80, "UDP Response PadData struct has wrong size ");
217static_assert(std::is_trivially_copyable_v<PadData>, 208static_assert(std::is_trivially_copyable_v<PadData>,
218 "UDP Response PadData is not trivially copyable"); 209 "UDP Response PadData is not trivially copyable");
219 210
220static_assert(sizeof(Message<PadData>) == MAX_PACKET_SIZE, 211static_assert(sizeof(Message<PadData>) == MAX_PACKET_SIZE,
221 "UDP MAX_PACKET_SIZE is no longer larger than Message<PadData>"); 212 "UDP MAX_PACKET_SIZE is no longer larger than Message<PadData>");
222 213
223static_assert(sizeof(PadData::AnalogButton) == 12, 214static_assert(sizeof(PadData::AnalogButton) == 12,
224 "UDP Response AnalogButton struct has wrong size "); 215 "UDP Response AnalogButton struct has wrong size ");
225static_assert(sizeof(PadData::TouchPad) == 6, "UDP Response TouchPad struct has wrong size "); 216static_assert(sizeof(PadData::TouchPad) == 6, "UDP Response TouchPad struct has wrong size ");
226static_assert(sizeof(PadData::Accelerometer) == 12, 217static_assert(sizeof(PadData::Accelerometer) == 12,
227 "UDP Response Accelerometer struct has wrong size "); 218 "UDP Response Accelerometer struct has wrong size ");
228static_assert(sizeof(PadData::Gyroscope) == 12, "UDP Response Gyroscope struct has wrong size "); 219static_assert(sizeof(PadData::Gyroscope) == 12, "UDP Response Gyroscope struct has wrong size ");
229 220
230/** 221/**
@@ -241,27 +232,22 @@ template <>
241constexpr Type GetMessageType<Request::Version>() { 232constexpr Type GetMessageType<Request::Version>() {
242 return Type::Version; 233 return Type::Version;
243} 234}
244
245template <> 235template <>
246constexpr Type GetMessageType<Request::PortInfo>() { 236constexpr Type GetMessageType<Request::PortInfo>() {
247 return Type::PortInfo; 237 return Type::PortInfo;
248} 238}
249
250template <> 239template <>
251constexpr Type GetMessageType<Request::PadData>() { 240constexpr Type GetMessageType<Request::PadData>() {
252 return Type::PadData; 241 return Type::PadData;
253} 242}
254
255template <> 243template <>
256constexpr Type GetMessageType<Response::Version>() { 244constexpr Type GetMessageType<Response::Version>() {
257 return Type::Version; 245 return Type::Version;
258} 246}
259
260template <> 247template <>
261constexpr Type GetMessageType<Response::PortInfo>() { 248constexpr Type GetMessageType<Response::PortInfo>() {
262 return Type::PortInfo; 249 return Type::PortInfo;
263} 250}
264
265template <> 251template <>
266constexpr Type GetMessageType<Response::PadData>() { 252constexpr Type GetMessageType<Response::PadData>() {
267 return Type::PadData; 253 return Type::PadData;