mirror of
https://github.com/AppleWin/AppleWin.git
synced 2026-04-25 19:19:02 +00:00
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:
+14
-6
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
||||
Reference in New Issue
Block a user