Skip to content

Commit b036943

Browse files
committed
Create Handbrake positionChanged() function
1 parent 078c5e0 commit b036943

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

src/SimRacing.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -987,15 +987,18 @@ LogitechShifter::LogitechShifter(uint8_t pinX, uint8_t pinY, uint8_t pinRev, uin
987987
//#########################################################
988988

989989
Handbrake::Handbrake(uint8_t pinAx, uint8_t detectPin)
990-
: analogAxis(pinAx), detector(detectPin)
990+
:
991+
analogAxis(pinAx),
992+
detector(detectPin),
993+
changed(false)
991994
{}
992995

993996
void Handbrake::begin() {
994997
update(); // set initial handbrake position
995998
}
996999

9971000
bool Handbrake::update() {
998-
bool changed = false;
1001+
changed = false;
9991002

10001003
detector.poll();
10011004
if (detector.getState() == DeviceConnection::Connected) {

src/SimRacing.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,6 +716,13 @@ namespace SimRacing {
716716
*/
717717
int getPositionRaw() const;
718718

719+
/**
720+
* Checks whether the handbrake's position has changed since the last update.
721+
*
722+
* @return 'true' if the position has changed, 'false' otherwise
723+
*/
724+
bool positionChanged() const { return changed; }
725+
719726
/// @copydoc AnalogInput::setCalibration()
720727
void setCalibration(AnalogInput::Calibration newCal);
721728

@@ -728,6 +735,7 @@ namespace SimRacing {
728735
private:
729736
AnalogInput analogAxis; ///< axis data for the handbrake's position
730737
DeviceConnection detector; ///< detector instance for checking if the handbrake is connected
738+
bool changed; ///< whether the handbrake position has changed since the previous update
731739
};
732740

733741

0 commit comments

Comments
 (0)