static BOOLEAN KeyboardQueuePush(BYTE ScanCode)
{
/* Check if the keyboard queue is full */
- if (!KeyboardQueueEmpty && (KeyboardQueueStart == KeyboardQueueEnd)) return FALSE;
-
WaitForSingleObject(QueueMutex, INFINITE);
+ if (!KeyboardQueueEmpty && (KeyboardQueueStart == KeyboardQueueEnd)) return FALSE;
+
/* Insert the value in the queue */
KeyboardQueue[KeyboardQueueEnd] = ScanCode;
KeyboardQueueEnd++;
static BOOLEAN KeyboardQueuePop(BYTE *ScanCode)
{
+ BOOLEAN Result = TRUE;
+
/* Make sure the keyboard queue is not empty */
if (KeyboardQueueEmpty) return FALSE;
WaitForSingleObject(QueueMutex, INFINITE);
+ if (KeyboardQueueEmpty)
+ {
+ Result = FALSE;
+ goto Done;
+ }
+
/* Get the scan code */
*ScanCode = KeyboardQueue[KeyboardQueueStart];
KeyboardQueueEmpty = TRUE;
}
+Done:
ReleaseMutex(QueueMutex);
- return TRUE;
+ return Result;
}
/* PUBLIC FUNCTIONS ***********************************************************/