@@ -158,20 +158,18 @@ boolean ClassicController_Shared::checkHighRes(boolean *hr) const {
158158 * controllers apparently don't understand how to act as a proper
159159 * register-based I2C device and just return junk. So instead we're starting
160160 * at the beginning of the data block.
161- *
162- * On the plus side, requesting more data here does make the error-checking
163- * more robust! Although at the expensive of a longer delay.
164161 */
165- static const uint8_t CheckPtr = 0x00 ; // start of the control data block
166- static const uint8_t CheckSize = 8 ; // 8 bytes to cover both std and high res
162+ static const uint8_t CheckPtr = 0x00 ; // start of the control data block
163+ static const uint8_t CheckSize = 8 ; // 8 bytes to cover both std and high res
164+ static const uint8_t DataOffset = 0x06 ; // start of the data we're interested in (7 / 8)
167165 uint8_t checkData[CheckSize] = { 0x00 }, verifyData[CheckSize] = { 0x00 };
168166 do {
169167 if (!requestData (CheckPtr, CheckSize, checkData)) return false ;
170168 delayMicroseconds (I2C_ConversionDelay); // need a brief delay between reads
171169 if (!requestData (CheckPtr, CheckSize, verifyData)) return false ;
172170
173171 boolean equal = true ;
174- for (uint8_t i = 0 ; i < CheckSize; i++) {
172+ for (uint8_t i = 0 ; i < CheckSize - DataOffset ; i++) {
175173 if (checkData[i] != verifyData[i]) {
176174 equal = false ; // one byte does not match! quit
177175 break ;
@@ -182,7 +180,7 @@ boolean ClassicController_Shared::checkHighRes(boolean *hr) const {
182180 delayMicroseconds (I2C_ConversionDelay); // if we're doing another loop, wait between reads again
183181 } while (true );
184182
185- *hr = !(checkData[6 ] == 0x00 && checkData[7 ] == 0x00 ); // if both are '0', high res is false
183+ *hr = !(checkData[DataOffset ] == 0x00 && checkData[DataOffset+ 1 ] == 0x00 ); // if both are '0', high res is false
186184 return true ; // successfully read state
187185}
188186
0 commit comments