More main-loop reduction & removal of redundant globals.

Fixed JoyUpdateButtonLatch() to debounce in 5mecs instead of 5secs!

SpkrToggle() was using redundant global ('cyclenum') when using the PC speaker.
. I reworked the code (as it looked out-of-date),
    but probably better to just remove all the PC speaker support.
This commit is contained in:
tomcw
2014-09-14 21:23:54 +01:00
parent 0db62489f9
commit 8c019bcd35
7 changed files with 45 additions and 65 deletions
+14 -6
View File
@@ -45,7 +45,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Configuration\PropertySheet.h"
#define BUTTONTIME 5000 // TODO: Describe this magic number
#define BUTTONTIME 5000 // This is the latch (debounce) time in usecs for the joystick buttons
enum {DEVICE_NONE=0, DEVICE_JOYSTICK, DEVICE_KEYBOARD, DEVICE_MOUSE};
@@ -82,7 +82,7 @@ static POINT keyvalue[9] = {{PDL_MIN,PDL_MAX}, {PDL_CENTRAL,PDL_MAX}, {PDL
{PDL_MIN,PDL_CENTRAL},{PDL_CENTRAL,PDL_CENTRAL},{PDL_MAX,PDL_CENTRAL},
{PDL_MIN,PDL_MIN}, {PDL_CENTRAL,PDL_MIN}, {PDL_MAX,PDL_MIN}};
static DWORD buttonlatch[3] = {0,0,0};
static int buttonlatch[3] = {0,0,0};
static BOOL joybutton[3] = {0,0,0};
static int joyshrx[2] = {8,8};
@@ -703,11 +703,19 @@ void JoySetPosition(int xvalue, int xrange, int yvalue, int yrange)
}
//===========================================================================
void JoyUpdatePosition()
// Update the latch (debounce) time for each button
void JoyUpdateButtonLatch(const UINT nExecutionPeriodUsec)
{
if (buttonlatch[0]) --buttonlatch[0];
if (buttonlatch[1]) --buttonlatch[1];
if (buttonlatch[2]) --buttonlatch[2];
for (UINT i=0; i<3; i++)
{
if (buttonlatch[i])
{
buttonlatch[i] -= nExecutionPeriodUsec;
if (buttonlatch[i] < 0)
buttonlatch[i] = 0;
}
}
}
//===========================================================================