From 7519879f408de85c46e1872e89b14a01b8b097e9 Mon Sep 17 00:00:00 2001 From: virtmedia Date: Mon, 7 May 2018 09:47:26 +0200 Subject: [PATCH] Added return value to sendState() The return value can be useful to detect, if USB host is active, or if it only supply power to the device. --- Joystick/src/Joystick.cpp | 4 ++-- Joystick/src/Joystick.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Joystick/src/Joystick.cpp b/Joystick/src/Joystick.cpp index db988cc..9305bdd 100644 --- a/Joystick/src/Joystick.cpp +++ b/Joystick/src/Joystick.cpp @@ -626,7 +626,7 @@ int Joystick_::buildAndSetSimulationValue(bool includeValue, int16_t value, int1 return buildAndSet16BitValue(includeValue, value, valueMinimum, valueMaximum, JOYSTICK_SIMULATOR_MINIMUM, JOYSTICK_SIMULATOR_MAXIMUM, dataLocation); } -void Joystick_::sendState() +int Joystick_::sendState() { uint8_t data[_hidReportSize]; int index = 0; @@ -674,7 +674,7 @@ void Joystick_::sendState() index += buildAndSetSimulationValue(_includeSimulatorFlags & JOYSTICK_INCLUDE_BRAKE, _brake, _brakeMinimum, _brakeMaximum, &(data[index])); index += buildAndSetSimulationValue(_includeSimulatorFlags & JOYSTICK_INCLUDE_STEERING, _steering, _steeringMinimum, _steeringMaximum, &(data[index])); - DynamicHID().SendReport(_hidReportId, data, _hidReportSize); + return DynamicHID().SendReport(_hidReportId, data, _hidReportSize); } #endif diff --git a/Joystick/src/Joystick.h b/Joystick/src/Joystick.h index a20d374..d07db57 100644 --- a/Joystick/src/Joystick.h +++ b/Joystick/src/Joystick.h @@ -211,7 +211,7 @@ class Joystick_ void setHatSwitch(int8_t hatSwitch, int16_t value); - void sendState(); + int sendState(); }; #endif // !defined(_USING_DYNAMIC_HID)