| 629 | } |
| 630 | |
| 631 | void Joystick_::sendState() |
| 632 | { |
| 633 | uint8_t data[_hidReportSize]; |
| 634 | int index = 0; |
| 635 | |
| 636 | // Load Button State |
| 637 | for (; index < _buttonValuesArraySize; index++) |
| 638 | { |
| 639 | data[index] = _buttonValues[index]; |
| 640 | } |
| 641 | |
| 642 | // Set Hat Switch Values |
| 643 | if (_hatSwitchCount > 0) { |
| 644 | |
| 645 | // Calculate hat-switch values |
| 646 | uint8_t convertedHatSwitch[JOYSTICK_HATSWITCH_COUNT_MAXIMUM]; |
| 647 | for (int hatSwitchIndex = 0; hatSwitchIndex < JOYSTICK_HATSWITCH_COUNT_MAXIMUM; hatSwitchIndex++) |
| 648 | { |
| 649 | if (_hatSwitchValues[hatSwitchIndex] < 0) |
| 650 | { |
| 651 | convertedHatSwitch[hatSwitchIndex] = 8; |
| 652 | } |
| 653 | else |
| 654 | { |
| 655 | convertedHatSwitch[hatSwitchIndex] = (_hatSwitchValues[hatSwitchIndex] % 360) / 45; |
| 656 | } |
| 657 | } |
| 658 | |
| 659 | // Pack hat-switch states into a single byte |
| 660 | data[index++] = (convertedHatSwitch[1] << 4) | (B00001111 & convertedHatSwitch[0]); |
| 661 | |
| 662 | } // Hat Switches |
| 663 | |
| 664 | // Set Axis Values |
| 665 | index += buildAndSetAxisValue(_includeAxisFlags & JOYSTICK_INCLUDE_X_AXIS, _xAxis, _xAxisMinimum, _xAxisMaximum, &(data[index])); |
| 666 | index += buildAndSetAxisValue(_includeAxisFlags & JOYSTICK_INCLUDE_Y_AXIS, _yAxis, _yAxisMinimum, _yAxisMaximum, &(data[index])); |
| 667 | index += buildAndSetAxisValue(_includeAxisFlags & JOYSTICK_INCLUDE_Z_AXIS, _zAxis, _zAxisMinimum, _zAxisMaximum, &(data[index])); |
| 668 | index += buildAndSetAxisValue(_includeAxisFlags & JOYSTICK_INCLUDE_RX_AXIS, _xAxisRotation, _rxAxisMinimum, _rxAxisMaximum, &(data[index])); |
| 669 | index += buildAndSetAxisValue(_includeAxisFlags & JOYSTICK_INCLUDE_RY_AXIS, _yAxisRotation, _ryAxisMinimum, _ryAxisMaximum, &(data[index])); |
| 670 | index += buildAndSetAxisValue(_includeAxisFlags & JOYSTICK_INCLUDE_RZ_AXIS, _zAxisRotation, _rzAxisMinimum, _rzAxisMaximum, &(data[index])); |
| 671 | |
| 672 | // Set Simulation Values |
| 673 | index += buildAndSetSimulationValue(_includeSimulatorFlags & JOYSTICK_INCLUDE_RUDDER, _rudder, _rudderMinimum, _rudderMaximum, &(data[index])); |
| 674 | index += buildAndSetSimulationValue(_includeSimulatorFlags & JOYSTICK_INCLUDE_THROTTLE, _throttle, _throttleMinimum, _throttleMaximum, &(data[index])); |
| 675 | index += buildAndSetSimulationValue(_includeSimulatorFlags & JOYSTICK_INCLUDE_ACCELERATOR, _accelerator, _acceleratorMinimum, _acceleratorMaximum, &(data[index])); |
| 676 | index += buildAndSetSimulationValue(_includeSimulatorFlags & JOYSTICK_INCLUDE_BRAKE, _brake, _brakeMinimum, _brakeMaximum, &(data[index])); |
| 677 | index += buildAndSetSimulationValue(_includeSimulatorFlags & JOYSTICK_INCLUDE_STEERING, _steering, _steeringMinimum, _steeringMaximum, &(data[index])); |
| 678 | |
| 679 | DynamicHID().SendReport(_hidReportId, data, _hidReportSize); |
| 680 | } |
| 681 | |
| 682 | #endif |
nothing calls this directly
no test coverage detected