File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -285,6 +285,26 @@ int AnalogInput::getPositionRaw() const {
285285 return this ->position ;
286286}
287287
288+ bool AnalogInput::inRange () const {
289+ return inRange (this ->getPositionRaw ());
290+ }
291+
292+ bool AnalogInput::inRange (int p) const {
293+ bool output;
294+
295+ // In 'normal' orientation, we are within range if the position
296+ // is above the min and below the max.
297+ if (!isInverted ()) {
298+ output = (p >= getMin () && p <= getMax ());
299+ }
300+ // In 'inverted' orientation, we are within range if the position
301+ // is below the min and above the max.
302+ else {
303+ output = (p >= getMax () && p <= getMin ());
304+ }
305+ return output;
306+ }
307+
288308bool AnalogInput::isInverted () const {
289309 return (this ->cal .min > this ->cal .max ); // inverted if min is greater than max
290310}
Original file line number Diff line number Diff line change @@ -175,6 +175,23 @@ namespace SimRacing {
175175 */
176176 int getMax () const { return this ->cal .max ; }
177177
178+ /* *
179+ * Checks whether the current position is within the calibrated
180+ * range of the axis.
181+ *
182+ * @return 'true' if position is within range, 'false' otherwise
183+ */
184+ bool inRange () const ;
185+
186+ /* *
187+ * Checks whether a given input value is within the calibrated
188+ * range of the axis.
189+ *
190+ * @param p position value to test
191+ * @return 'true' if test value is within range, 'false' otherwise
192+ */
193+ bool inRange (int p) const ;
194+
178195 /* *
179196 * Check whether the axis is inverted or not.
180197 *
You can’t perform that action at this time.
0 commit comments