diff --git a/src/emucore/Driving.cxx b/src/emucore/Driving.cxx index 1cab7b75a..2fb5a4840 100644 --- a/src/emucore/Driving.cxx +++ b/src/emucore/Driving.cxx @@ -114,6 +114,7 @@ void Driving::updateControllerAxes() { // Digital events (from keyboard or joystick hats & buttons) const int d_axis = myEvent.get(myXAxisValue); + uInt32 oldCounterHires = myCounterHires; if(myEvent.get(myCCWEvent) != 0 && myLastCCWEvent == 0) myCounterHires = ((myGrayIndex + 4) * 256.0F) / SENSITIVITY - 1; // set to end of previous counter interval @@ -136,16 +137,17 @@ void Driving::updateControllerAxes() range as digital inputs. */ myCounterHires += (a_axis/512) + (a_axis >= 0); - cerr << "! "; } - // Only consider the lower-most bits (corresponding to pins 1 & 2) - myGrayIndex = static_cast((myCounterHires / 256.0F) * SENSITIVITY) & 0b11; + if(oldCounterHires != myCounterHires) + // Only consider the lower-most bits (corresponding to pins 1 & 2) + myGrayIndex = static_cast((myCounterHires / 256.0F) * SENSITIVITY) & 0b11; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Driving::updateMouseAxes() { + Int32 oldCounter = myCounter; static constexpr int MJ_Threshold = 2; // Mouse motion and button events @@ -178,6 +180,8 @@ void Driving::updateMouseAxes() ++myCounter; } } + if(myCounter != oldCounter) + myGrayIndex = (myCounter >> 2) & 0b11; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -206,6 +210,7 @@ void Driving::updateStelladaptorAxes() // simulated gray codes generated by PC keyboard or PC joystick // Must be rounded into the middle of the myCounter interval! myCounter = (myGrayIndex + 0.5F) * 4.0F / SENSITIVITY; + myCounterHires = myCounter * 256.0F / 4.0F; } }