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