Any input gesture is now guaranteed to persist for at least one frame.

This fixes Bug #864.  Note that this also adds an "Input Frame" 
abstraction into the input library.


git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2688 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
mcmartin
2007-01-30 07:43:40 +00:00
parent 94fd412f2e
commit 4a99d4b2fb
6 changed files with 54 additions and 6 deletions
+2 -1
View File
@@ -1,5 +1,6 @@
Changes towards version 0.7: Changes towards version 0.7:
- Remove the unnecessary VControl memory abstraction layer - Michael - Any input will register for at least one frame (Bug #864) - Michael
- Many VControl cleanups - Michael
- Fix compilation without Netplay support - SvdB - Fix compilation without Netplay support - SvdB
- Added limited AIFF sound file decoder for playing 3DO originals; - Added limited AIFF sound file decoder for playing 3DO originals;
SDX2 decoder by SvdB - Alex SDX2 decoder by SvdB - Alex
+1
View File
@@ -233,6 +233,7 @@ UpdateInputState (void)
CurrentInputState = ImmediateInputState; CurrentInputState = ImmediateInputState;
OldInputState = CachedInputState; OldInputState = CachedInputState;
CachedInputState = ImmediateInputState; CachedInputState = ImmediateInputState;
BeginInputFrame ();
NewTime = GetTimeCounter (); NewTime = GetTimeCounter ();
if (_gestalt_keys) if (_gestalt_keys)
{ {
+4
View File
@@ -55,5 +55,9 @@ void RebindInputState (int template, int control, int index);
void SaveKeyConfiguration (uio_DirHandle *path, const char *fname); void SaveKeyConfiguration (uio_DirHandle *path, const char *fname);
/* Separate inputs into frames for dealing with very fast inputs */
void BeginInputFrame (void);
#endif /* _INPLIB_H */ #endif /* _INPLIB_H */
+6
View File
@@ -478,4 +478,10 @@ SaveKeyConfiguration (uio_DirHandle *path, const char *fname)
} }
} }
void
BeginInputFrame (void)
{
VControl_BeginFrame ();
}
#endif #endif
+28 -5
View File
@@ -385,7 +385,7 @@ activate (keybinding *i)
{ {
while (i != NULL) while (i != NULL)
{ {
*(i->target) = *(i->target)+1; *(i->target) = (*(i->target)+1) | VCONTROL_STARTBIT;
i = i->next; i = i->next;
} }
} }
@@ -395,9 +395,10 @@ deactivate (keybinding *i)
{ {
while (i != NULL) while (i != NULL)
{ {
if (*(i->target) > 0) int v = *(i->target) & VCONTROL_MASK;
if (v > 0)
{ {
*(i->target) = *(i->target)-1; *(i->target) = (v-1) | (*(i->target) & VCONTROL_STARTBIT);
} }
i = i->next; i = i->next;
} }
@@ -739,7 +740,7 @@ VControl_RemoveJoyHatBinding (int port, int which, Uint8 dir, int *target)
} }
void void
VControl_RemoveAllBindings () VControl_RemoveAllBindings (void)
{ {
key_uninit (); key_uninit ();
key_init (); key_init ();
@@ -861,7 +862,7 @@ VControl_ProcessJoyHat (int port, int which, Uint8 value)
} }
void void
VControl_ResetInput () VControl_ResetInput (void)
{ {
/* Step through every valid entry in the binding pool and zero /* Step through every valid entry in the binding pool and zero
* them out. This will probably zero entries multiple times; * them out. This will probably zero entries multiple times;
@@ -882,6 +883,28 @@ VControl_ResetInput ()
} }
} }
void
VControl_BeginFrame (void)
{
/* Step through every valid entry in the binding pool and zero
* out the frame-start bit. This will probably zero entries
* multiple times; oh well, no harm done. */
keypool *base = pool;
while (base != NULL)
{
int i;
for (i = 0; i < POOL_CHUNK_SIZE; i++)
{
if(base->pool[i].target)
{
*(base->pool[i].target) &= VCONTROL_MASK;
}
}
base = base->next;
}
}
void void
VControl_HandleEvent (const SDL_Event *e) VControl_HandleEvent (const SDL_Event *e)
{ {
+13
View File
@@ -63,6 +63,9 @@ void VControl_RemoveJoyHatBinding (int port, int which, Uint8 dir, int *target);
void VControl_RemoveAllBindings (void); void VControl_RemoveAllBindings (void);
/* Signal to VControl that a frame is about to begin. */
void VControl_BeginFrame (void);
/* The listener. Routines besides HandleEvent may be used to 'fake' inputs without /* The listener. Routines besides HandleEvent may be used to 'fake' inputs without
* fabricating an SDL_Event. * fabricating an SDL_Event.
*/ */
@@ -119,4 +122,14 @@ int VControl_NextBinding (VCONTROL_GESTURE *gesture);
void VControl_ClearGesture (void); void VControl_ClearGesture (void);
int VControl_GetLastGesture (VCONTROL_GESTURE *g); int VControl_GetLastGesture (VCONTROL_GESTURE *g);
/* Constants for handling the "Start bit." If a gesture is made, and
* then ends, within a single frame, it will still, for one frame,
* have a nonzero value. This is because Bit 16 will be on for the
* first frame a gesture is struck. This bit is cleared when
* VControl_BeginFrame() is called. These constants are used to mask
* out results if necessary. */
#define VCONTROL_STARTBIT 0x10000
#define VCONTROL_MASK 0x0FFFF
#endif #endif