Skip to content

Commit 4b9b8eb

Browse files
committed
Fix G27 button output when using DF shifter
This lets you read the Driving Force shifter with the G27 object. As the detection pins are the same, the two shifters cannot be simply distinguished by the microcontroller.
1 parent e96cc54 commit 4b9b8eb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/SimRacing.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,21 @@ uint16_t LogitechShifterG27::readShiftRegisters() {
12471247
}
12481248
digitalWrite(this->pinClock, LOW);
12491249

1250+
// edge case: two of the bits (0x8000 and 0x2000) are connected only to
1251+
// pull-down resistors, and should theoretically never be high. If they,
1252+
// and all other bits, *are* high, then we are not reading from a shifter
1253+
// that has shift registers. The "Driving Force" (G29/G920/G923) shifter
1254+
// has its data output connected to the 'reverse' button through a buffer,
1255+
// and will report 'high' if the reverse button is pressed no matter how
1256+
// many times the clock is pulsed.
1257+
//
1258+
// QED: we are connected to a "Driving Force" shifter, and not a G27.
1259+
// That's okay! If we set the state of the 'reverse' button and clear
1260+
// all others, we can still behave like a G27.
1261+
if (data == 0xFFFF) {
1262+
data = (1 << (uint8_t) Button::BUTTON_REVERSE);
1263+
}
1264+
12501265
return data;
12511266
}
12521267

0 commit comments

Comments
 (0)