Emulates the handbrake as a joystick over USB.
#include <Joystick.h>
const int Pin_Handbrake = A2;
Joystick_ Joystick(
JOYSTICK_DEFAULT_REPORT_ID,
JOYSTICK_TYPE_JOYSTICK,
0,
0,
false, false,
true,
false, false, false, false, false, false, false, false);
const int ADC_Max = 1023;
const bool AlwaysSend = false;
void setup() {
Joystick.begin(false);
Joystick.setZAxisRange(0, ADC_Max);
updateJoystick();
}
void loop() {
updateJoystick();
}
}
void updateJoystick() {
Joystick.setZAxis(pos);
Joystick.sendState();
}
Header file for the Sim Racing Library.
Interface with analog handbrakes that use hall effect sensors.
virtual void begin()
Initializes the pin for reading from the handbrake.
long getPosition(long rMin=0, long rMax=100) const
Retrieves the buffered position for the handbrake axis, rescaled to a nominal range using the calibra...
bool positionChanged() const
Checks whether the handbrake's position has changed since the last update.
virtual bool update()
Polls the handbrake to update its position.