FreeRTOS Tetris
|
Keyboard and mouse event retrieval API. More...
Functions | |
int | tumEventInit (void) |
Initializes the TUM Event backend. More... | |
void | tumEventExit (void) |
Deinitializes the TUM Event backend. | |
signed short | tumEventGetMouseX (void) |
Returns a copy of the mouse's most recent X coord (in pixels) More... | |
signed short | tumEventGetMouseY (void) |
Returns a copy of the mouse's most recent Y coord (in pixels) More... | |
signed char | tumEventGetMouseLeft (void) |
Returns a copy of the mouse's left button status. More... | |
signed char | tumEventGetMouseRight (void) |
Returns a copy of the mouse's right button status. More... | |
signed char | tumEventGetMouseMiddle (void) |
Returns a copy of the mouse's middle button status. More... | |
int | tumEventFetchEvents (int flags) |
Polls all outstanding SDL Events. Should be called from Draw Loop that holds the OpenGL context. More... | |
Variables | |
QueueHandle_t | buttonInputQueue |
FreeRTOS queue used to obtain a current copy of the keyboard lookup table. More... | |
Event fetching flags | |
Flags for tumEventFetchEvents() Fetching of SDL events can be done in a block, nonblocking as well as GL context checking fashion. See tumEventFetchEvents() for more details. | |
#define | FETCH_EVENT_BLOCK 0b1 |
#define | FETCH_EVENT_NONBLOCK 0b10 |
#define | FETCH_EVENT_NO_GL_CHECK 0b100 |
Keyboard and mouse event retrieval API.
API to retrieve event's from the backend SDL library. Events are the movement of the mouse and keypresses. Mouse coordinates are exposed through tumEventGetMouseX and tumEventGetMouseY while keypress events are received by retriving the most recent copy of the button status lookup table exposed through the FreeRTOS queue buttonInputQueue.
buttonInputQueue holds a single array of unsigned chars of the length SDL_NUM_SCANCODES. The scancodes that are defind in the SDL header SDL_scancode.h are used as the indicies when accessing the stored data in the table.
#define FETCH_EVENT_BLOCK 0b1 |
#include <TUM_Event.h>
Event fetching should block until events could be fetched
#define FETCH_EVENT_NO_GL_CHECK 0b100 |
#include <TUM_Event.h>
Event fetching should not check OpenGL context
#define FETCH_EVENT_NONBLOCK 0b10 |
#include <TUM_Event.h>
Event fetching should not block and return if events could not be fetched
int tumEventFetchEvents | ( | int | flags | ) |
#include <TUM_Event.h>
Polls all outstanding SDL Events. Should be called from Draw Loop that holds the OpenGL context.
Events can be retrieved in either a blocking or non-blocking fashion. The flags FETCH_EVENT_BLOCK and FETCH_EVENT_NONBLOCK specify which action is to be taken. flag values that are not FETCH_EVENT_BLOCK or FETCH_EVENT_NONBLOCK will result in nonblocking behaviour.
Events ideally should only be fetched from threads that holds the GL context, obtained using tumDrawBindThread(). Binding a thread has a large overhead and should be avoided. It is unsure if this is absolutly necessary and as such if you would like to fetch events in a non-context holding thread, pass the flag FETCH_EVENT_NO_GL_CHECK to skip this check.
Multiple flags can be used in a 'OR' fashion,
eg.
tumEventFetchEvents(FETCH_EVENT_NONBLOCK | FETCH_EVENT_NO_GL_CHECK)
flags | Flags specifying the bahaviour of the function. See FETCH_EVENT_BLOCK, FETCH_EVENT_NONBLOCK and FETCH_EVENT_NO_GL_CHECK |
signed char tumEventGetMouseLeft | ( | void | ) |
#include <TUM_Event.h>
Returns a copy of the mouse's left button status.
signed char tumEventGetMouseMiddle | ( | void | ) |
#include <TUM_Event.h>
Returns a copy of the mouse's middle button status.
signed char tumEventGetMouseRight | ( | void | ) |
#include <TUM_Event.h>
Returns a copy of the mouse's right button status.
signed short tumEventGetMouseX | ( | void | ) |
#include <TUM_Event.h>
Returns a copy of the mouse's most recent X coord (in pixels)
signed short tumEventGetMouseY | ( | void | ) |
#include <TUM_Event.h>
Returns a copy of the mouse's most recent Y coord (in pixels)
int tumEventInit | ( | void | ) |
QueueHandle_t buttonInputQueue |
#include <TUM_Event.h>
FreeRTOS queue used to obtain a current copy of the keyboard lookup table.
Sends an unsigned char array of length SDL_NUM_SCANCODES. Acts as a lookup table using the SDL scancodes defined in <SDL2/SDL_scancode.h>