| 27 | #include <QDebug> |
| 28 | |
| 29 | InputDeviceBitArrayStatus::InputDeviceBitArrayStatus(InputDevice *device, bool readCurrent, QObject *parent) |
| 30 | : QObject(parent) |
| 31 | { |
| 32 | for (int i = 0; i < device->getNumberRawAxes(); i++) |
| 33 | { |
| 34 | SetJoystick *currentSet = device->getActiveSetJoystick(); |
| 35 | JoyAxis *axis = currentSet->getJoyAxis(i); |
| 36 | |
| 37 | if ((axis != nullptr) && readCurrent) |
| 38 | { |
| 39 | axesStatus.append(!axis->inDeadZone(axis->getCurrentRawValue()) ? true : false); |
| 40 | } else |
| 41 | { |
| 42 | axesStatus.append(false); |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | for (int i = 0; i < device->getNumberRawHats(); i++) |
| 47 | { |
| 48 | SetJoystick *currentSet = device->getActiveSetJoystick(); |
| 49 | JoyDPad *dpad = currentSet->getJoyDPad(i); |
| 50 | |
| 51 | if ((dpad != nullptr) && readCurrent) |
| 52 | { |
| 53 | hatButtonStatus.append(dpad->getCurrentDirection() != JoyDPadButton::DpadCentered ? true : false); |
| 54 | } else |
| 55 | { |
| 56 | hatButtonStatus.append(false); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | getButtonStatusLocal().resize(device->getNumberRawButtons()); |
| 61 | getButtonStatusLocal().fill(0); |
| 62 | |
| 63 | for (int i = 0; i < device->getNumberRawButtons(); i++) |
| 64 | { |
| 65 | SetJoystick *currentSet = device->getActiveSetJoystick(); |
| 66 | JoyButton *button = currentSet->getJoyButton(i); |
| 67 | |
| 68 | if ((button != nullptr) && readCurrent) |
| 69 | { |
| 70 | getButtonStatusLocal().setBit(i, button->getButtonState()); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | m_sensor_status.resize(SENSOR_COUNT); |
| 75 | m_sensor_status.fill(0); |
| 76 | } |
| 77 | |
| 78 | void InputDeviceBitArrayStatus::changeAxesStatus(int axisIndex, bool value) |
| 79 | { |
nothing calls this directly
no test coverage detected