| 198 | } |
| 199 | |
| 200 | uint8_t Ds4GamepadState::compute_dpad_value() const |
| 201 | { |
| 202 | // DS4 D-pad encoding: N=0, NE=1, E=2, SE=3, S=4, SW=5, W=6, NW=7, None=8 |
| 203 | bool up = dpad_state_ & 0x01; |
| 204 | bool right = dpad_state_ & 0x02; |
| 205 | bool down = dpad_state_ & 0x04; |
| 206 | bool left = dpad_state_ & 0x08; |
| 207 | |
| 208 | // Handle conflicting directions (both pressed = neither active) |
| 209 | if (up && down) { |
| 210 | up = down = false; |
| 211 | } |
| 212 | if (left && right) { |
| 213 | left = right = false; |
| 214 | } |
| 215 | |
| 216 | if (up && right) { |
| 217 | return 1; |
| 218 | } |
| 219 | if (right && down) { |
| 220 | return 3; |
| 221 | } |
| 222 | if (down && left) { |
| 223 | return 5; |
| 224 | } |
| 225 | if (left && up) { |
| 226 | return 7; |
| 227 | } |
| 228 | if (up) { |
| 229 | return 0; |
| 230 | } |
| 231 | if (right) { |
| 232 | return 2; |
| 233 | } |
| 234 | if (down) { |
| 235 | return 4; |
| 236 | } |
| 237 | if (left) { |
| 238 | return 6; |
| 239 | } |
| 240 | return 8; |
| 241 | } |
| 242 | |
| 243 | // Factory |
| 244 |
nothing calls this directly
no outgoing calls
no test coverage detected