///////////////////////////////////////////////////////
| 253 | |
| 254 | //////////////////////////////////////////////////////////// |
| 255 | JoystickCaps JoystickImpl::getCapabilities() const |
| 256 | { |
| 257 | JoystickCaps caps; |
| 258 | hid_item_t item; |
| 259 | |
| 260 | hid_data_t data = hid_start_parse(m_desc, 1 << hid_input, m_id); |
| 261 | |
| 262 | while (hid_get_item(data, &item)) |
| 263 | { |
| 264 | if (item.kind == hid_input) |
| 265 | { |
| 266 | int usage = HID_USAGE(item.usage); |
| 267 | |
| 268 | if (usage == HUP_BUTTON) |
| 269 | { |
| 270 | ++caps.buttonCount; |
| 271 | break; |
| 272 | } |
| 273 | else if (usage == HUP_GENERIC_DESKTOP) |
| 274 | { |
| 275 | if (usage == HUG_HAT_SWITCH) |
| 276 | { |
| 277 | caps.axes[Joystick::Axis::PovX] = true; |
| 278 | caps.axes[Joystick::Axis::PovY] = true; |
| 279 | } |
| 280 | else if (const std::optional<Joystick::Axis> axis = usageToAxis(usage)) |
| 281 | { |
| 282 | caps.axes[*axis] = true; |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | hid_end_parse(data); |
| 289 | |
| 290 | return caps; |
| 291 | } |
| 292 | |
| 293 | |
| 294 | //////////////////////////////////////////////////////////// |
nothing calls this directly
no test coverage detected