diff options
Diffstat (limited to 'src/input_common/helpers/udp_protocol.h')
| -rw-r--r-- | src/input_common/helpers/udp_protocol.h | 75 |
1 files changed, 53 insertions, 22 deletions
diff --git a/src/input_common/helpers/udp_protocol.h b/src/input_common/helpers/udp_protocol.h index 1bdc9209e..bcba12c58 100644 --- a/src/input_common/helpers/udp_protocol.h +++ b/src/input_common/helpers/udp_protocol.h | |||
| @@ -56,6 +56,12 @@ constexpr Type GetMessageType(); | |||
| 56 | 56 | ||
| 57 | namespace Request { | 57 | namespace Request { |
| 58 | 58 | ||
| 59 | enum RegisterFlags : u8 { | ||
| 60 | AllPads, | ||
| 61 | PadID, | ||
| 62 | PadMACAdddress, | ||
| 63 | }; | ||
| 64 | |||
| 59 | struct Version {}; | 65 | struct Version {}; |
| 60 | /** | 66 | /** |
| 61 | * Requests the server to send information about what controllers are plugged into the ports | 67 | * Requests the server to send information about what controllers are plugged into the ports |
| @@ -77,13 +83,8 @@ static_assert(std::is_trivially_copyable_v<PortInfo>, | |||
| 77 | * timeout seems to be 5 seconds. | 83 | * timeout seems to be 5 seconds. |
| 78 | */ | 84 | */ |
| 79 | struct PadData { | 85 | struct PadData { |
| 80 | enum class Flags : u8 { | ||
| 81 | AllPorts, | ||
| 82 | Id, | ||
| 83 | Mac, | ||
| 84 | }; | ||
| 85 | /// Determines which method will be used as a look up for the controller | 86 | /// Determines which method will be used as a look up for the controller |
| 86 | Flags flags{}; | 87 | RegisterFlags flags{}; |
| 87 | /// Index of the port of the controller to retrieve data about | 88 | /// Index of the port of the controller to retrieve data about |
| 88 | u8 port_id{}; | 89 | u8 port_id{}; |
| 89 | /// Mac address of the controller to retrieve data about | 90 | /// Mac address of the controller to retrieve data about |
| @@ -113,6 +114,36 @@ Message<T> Create(const T data, const u32 client_id = 0) { | |||
| 113 | 114 | ||
| 114 | namespace Response { | 115 | namespace Response { |
| 115 | 116 | ||
| 117 | enum class ConnectionType : u8 { | ||
| 118 | None, | ||
| 119 | Usb, | ||
| 120 | Bluetooth, | ||
| 121 | }; | ||
| 122 | |||
| 123 | enum class State : u8 { | ||
| 124 | Disconnected, | ||
| 125 | Reserved, | ||
| 126 | Connected, | ||
| 127 | }; | ||
| 128 | |||
| 129 | enum class Model : u8 { | ||
| 130 | None, | ||
| 131 | PartialGyro, | ||
| 132 | FullGyro, | ||
| 133 | Generic, | ||
| 134 | }; | ||
| 135 | |||
| 136 | enum class Battery : u8 { | ||
| 137 | None = 0x00, | ||
| 138 | Dying = 0x01, | ||
| 139 | Low = 0x02, | ||
| 140 | Medium = 0x03, | ||
| 141 | High = 0x04, | ||
| 142 | Full = 0x05, | ||
| 143 | Charging = 0xEE, | ||
| 144 | Charged = 0xEF, | ||
| 145 | }; | ||
| 146 | |||
| 116 | struct Version { | 147 | struct Version { |
| 117 | u16_le version{}; | 148 | u16_le version{}; |
| 118 | }; | 149 | }; |
| @@ -122,11 +153,11 @@ static_assert(std::is_trivially_copyable_v<Version>, | |||
| 122 | 153 | ||
| 123 | struct PortInfo { | 154 | struct PortInfo { |
| 124 | u8 id{}; | 155 | u8 id{}; |
| 125 | u8 state{}; | 156 | State state{}; |
| 126 | u8 model{}; | 157 | Model model{}; |
| 127 | u8 connection_type{}; | 158 | ConnectionType connection_type{}; |
| 128 | MacAddress mac; | 159 | MacAddress mac; |
| 129 | u8 battery{}; | 160 | Battery battery{}; |
| 130 | u8 is_pad_active{}; | 161 | u8 is_pad_active{}; |
| 131 | }; | 162 | }; |
| 132 | static_assert(sizeof(PortInfo) == 12, "UDP Response PortInfo struct has wrong size"); | 163 | static_assert(sizeof(PortInfo) == 12, "UDP Response PortInfo struct has wrong size"); |
| @@ -177,18 +208,18 @@ struct PadData { | |||
| 177 | u8 right_stick_y{}; | 208 | u8 right_stick_y{}; |
| 178 | 209 | ||
| 179 | struct AnalogButton { | 210 | struct AnalogButton { |
| 180 | u8 button_8{}; | 211 | u8 button_dpad_left_analog{}; |
| 181 | u8 button_7{}; | 212 | u8 button_dpad_down_analog{}; |
| 182 | u8 button_6{}; | 213 | u8 button_dpad_right_analog{}; |
| 183 | u8 button_5{}; | 214 | u8 button_dpad_up_analog{}; |
| 184 | u8 button_12{}; | 215 | u8 button_square_analog{}; |
| 185 | u8 button_11{}; | 216 | u8 button_cross_analog{}; |
| 186 | u8 button_10{}; | 217 | u8 button_circle_analog{}; |
| 187 | u8 button_9{}; | 218 | u8 button_triangle_analog{}; |
| 188 | u8 button_16{}; | 219 | u8 button_r1_analog{}; |
| 189 | u8 button_15{}; | 220 | u8 button_l1_analog{}; |
| 190 | u8 button_14{}; | 221 | u8 trigger_r2{}; |
| 191 | u8 button_13{}; | 222 | u8 trigger_l2{}; |
| 192 | } analog_button; | 223 | } analog_button; |
| 193 | 224 | ||
| 194 | std::array<TouchPad, 2> touch; | 225 | std::array<TouchPad, 2> touch; |