mirror of
https://github.com/raysan5/raylib.git
synced 2025-09-12 14:28:15 +00:00
Remove trail spaces and some tweaks
This commit is contained in:
20
src/core.c
20
src/core.c
@@ -312,9 +312,9 @@ typedef struct {
|
||||
} InputEventWorker;
|
||||
|
||||
typedef struct {
|
||||
int Contents[8];
|
||||
char Head;
|
||||
char Tail;
|
||||
int contents[8]; // Key events FIFO contents (8 positions)
|
||||
char head; // Key events FIFO head position
|
||||
char tail; // Key events FIFO tail position
|
||||
} KeyEventFifo;
|
||||
#endif
|
||||
|
||||
@@ -3598,12 +3598,12 @@ static void PollInputEvents(void)
|
||||
for (int i = 0; i < 512; i++)CORE.Input.Keyboard.previousKeyState[i] = CORE.Input.Keyboard.currentKeyState[i];
|
||||
|
||||
// Grab a keypress from the evdev fifo if avalable
|
||||
if (CORE.Input.Keyboard.lastKeyPressed.Head != CORE.Input.Keyboard.lastKeyPressed.Tail)
|
||||
if (CORE.Input.Keyboard.lastKeyPressed.head != CORE.Input.Keyboard.lastKeyPressed.tail)
|
||||
{
|
||||
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = CORE.Input.Keyboard.lastKeyPressed.Contents[CORE.Input.Keyboard.lastKeyPressed.Tail]; // Read the key from the buffer
|
||||
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = CORE.Input.Keyboard.lastKeyPressed.contents[CORE.Input.Keyboard.lastKeyPressed.tail]; // Read the key from the buffer
|
||||
CORE.Input.Keyboard.keyPressedQueueCount++;
|
||||
|
||||
CORE.Input.Keyboard.lastKeyPressed.Tail = (CORE.Input.Keyboard.lastKeyPressed.Tail + 1) & 0x07; // Increment the tail pointer forwards and binary wraparound after 7 (fifo is 8 elements long)
|
||||
CORE.Input.Keyboard.lastKeyPressed.tail = (CORE.Input.Keyboard.lastKeyPressed.tail + 1) & 0x07; // Increment the tail pointer forwards and binary wraparound after 7 (fifo is 8 elements long)
|
||||
}
|
||||
|
||||
// Register previous mouse states
|
||||
@@ -4767,8 +4767,8 @@ static void InitEvdevInput(void)
|
||||
}
|
||||
|
||||
// Reset keypress buffer
|
||||
CORE.Input.Keyboard.lastKeyPressed.Head = 0;
|
||||
CORE.Input.Keyboard.lastKeyPressed.Tail = 0;
|
||||
CORE.Input.Keyboard.lastKeyPressed.head = 0;
|
||||
CORE.Input.Keyboard.lastKeyPressed.tail = 0;
|
||||
|
||||
// Reset keyboard key state
|
||||
for (int i = 0; i < 512; i++) CORE.Input.Keyboard.currentKeyState[i] = 0;
|
||||
@@ -5131,8 +5131,8 @@ static void *EventThread(void *arg)
|
||||
if (event.value > 0)
|
||||
{
|
||||
// Add the key int the fifo
|
||||
CORE.Input.Keyboard.lastKeyPressed.Contents[CORE.Input.Keyboard.lastKeyPressed.Head] = keycode; // Put the data at the front of the fifo snake
|
||||
CORE.Input.Keyboard.lastKeyPressed.Head = (CORE.Input.Keyboard.lastKeyPressed.Head + 1) & 0x07; // Increment the head pointer forwards and binary wraparound after 7 (fifo is 8 elements long)
|
||||
CORE.Input.Keyboard.lastKeyPressed.contents[CORE.Input.Keyboard.lastKeyPressed.head] = keycode; // Put the data at the front of the fifo snake
|
||||
CORE.Input.Keyboard.lastKeyPressed.head = (CORE.Input.Keyboard.lastKeyPressed.head + 1) & 0x07; // Increment the head pointer forwards and binary wraparound after 7 (fifo is 8 elements long)
|
||||
// TODO: This fifo is not fully threadsafe with multiple writers, so multiple keyboards hitting a key at the exact same time could miss a key (double write to head before it was incremented)
|
||||
}
|
||||
*/
|
||||
|
Reference in New Issue
Block a user