///////////////////////////////////////////////////////
| 545 | |
| 546 | //////////////////////////////////////////////////////////// |
| 547 | JoystickCaps JoystickImpl::getCapabilities() const |
| 548 | { |
| 549 | JoystickCaps caps; |
| 550 | |
| 551 | if (m_file < 0) |
| 552 | return caps; |
| 553 | |
| 554 | // Get the number of buttons |
| 555 | char buttonCount = 0; |
| 556 | ioctl(m_file, JSIOCGBUTTONS, &buttonCount); |
| 557 | caps.buttonCount = static_cast<unsigned int>(buttonCount); |
| 558 | if (caps.buttonCount > Joystick::ButtonCount) |
| 559 | caps.buttonCount = Joystick::ButtonCount; |
| 560 | |
| 561 | // Get the supported axes |
| 562 | char axesCount = 0; |
| 563 | ioctl(m_file, JSIOCGAXES, &axesCount); |
| 564 | for (int i = 0; i < axesCount; ++i) |
| 565 | { |
| 566 | switch (m_mapping[static_cast<std::size_t>(i)]) |
| 567 | { |
| 568 | // clang-format off |
| 569 | case ABS_X: caps.axes[Joystick::Axis::X] = true; break; |
| 570 | case ABS_Y: caps.axes[Joystick::Axis::Y] = true; break; |
| 571 | case ABS_Z: |
| 572 | case ABS_THROTTLE: caps.axes[Joystick::Axis::Z] = true; break; |
| 573 | case ABS_RZ: |
| 574 | case ABS_RUDDER: caps.axes[Joystick::Axis::R] = true; break; |
| 575 | case ABS_RX: caps.axes[Joystick::Axis::U] = true; break; |
| 576 | case ABS_RY: caps.axes[Joystick::Axis::V] = true; break; |
| 577 | case ABS_HAT0X: caps.axes[Joystick::Axis::PovX] = true; break; |
| 578 | case ABS_HAT0Y: caps.axes[Joystick::Axis::PovY] = true; break; |
| 579 | default: break; |
| 580 | // clang-format on |
| 581 | } |
| 582 | } |
| 583 | |
| 584 | return caps; |
| 585 | } |
| 586 | |
| 587 | |
| 588 | //////////////////////////////////////////////////////////// |
no outgoing calls
no test coverage detected