FreeRTOS Emulator with SDL2 Based Graphics and Input Library  1.0
A POSIX wrapper to run FreeRTOS on an x86 machine with some basic input and output libraries aimed at making teaching FreeRTOS simpler.
GFX Event API

Keyboard and mouse event retrieval API. More...

Functions

int gfxEventInit (void)
 Initializes the GFX Event backend. More...
 
void gfxEventExit (void)
 Deinitializes the GFX Event backend. More...
 
signed short gfxEventGetMouseX (void)
 Returns a copy of the mouse's most recent X coord (in pixels) More...
 
signed short gfxEventGetMouseY (void)
 Returns a copy of the mouse's most recent Y coord (in pixels) More...
 
signed char gfxEventGetMouseLeft (void)
 Returns a copy of the mouse's left button status. More...
 
signed char gfxEventGetMouseRight (void)
 Returns a copy of the mouse's right button status. More...
 
signed char gfxEventGetMouseMiddle (void)
 Returns a copy of the mouse's middle button status. More...
 
int gfxEventFetchEvents (int flags)
 Polls all outstanding SDL Events. Should be called from Draw Loop that holds the OpenGL context. More...
 

Variables

QueueHandle_t buttonInputQueue
 

Event fetching flags

Flags for gfxEventFetchEvents()

Fetching of SDL events can be done in a block, nonblocking as well as GL context checking fashion. See gfxEventFetchEvents() for more details.

#define FETCH_EVENT_BLOCK   0b1
 
#define FETCH_EVENT_NONBLOCK   0b10
 
#define FETCH_EVENT_NO_GL_CHECK   0b100
 

Detailed Description

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 gfxEventGetMouseX and gfxEventGetMouseY 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.

Macro Definition Documentation

◆ FETCH_EVENT_BLOCK

#define FETCH_EVENT_BLOCK   0b1

Event fetching should block until events could be fetched

◆ FETCH_EVENT_NO_GL_CHECK

#define FETCH_EVENT_NO_GL_CHECK   0b100

Event fetching should not check OpenGL context

◆ FETCH_EVENT_NONBLOCK

#define FETCH_EVENT_NONBLOCK   0b10

Event fetching should not block and return if events could not be fetched

Function Documentation

◆ gfxEventExit()

void gfxEventExit ( void  )

Deinitializes the GFX Event backend.

◆ gfxEventFetchEvents()

int gfxEventFetchEvents ( int  flags)

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 gfxDrawBindThread(). 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.

gfxEventFetchEvents(FETCH_EVENT_NONBLOCK | FETCH_EVENT_NO_GL_CHECK)
Parameters
flagsFlags specifying the bahaviour of the function. See FETCH_EVENT_BLOCK, FETCH_EVENT_NONBLOCK and FETCH_EVENT_NO_GL_CHECK
Returns
0 on success.

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>

◆ gfxEventGetMouseLeft()

signed char gfxEventGetMouseLeft ( void  )

Returns a copy of the mouse's left button status.

Returns
Either 1 for pressed or 0 for not pressed.

◆ gfxEventGetMouseMiddle()

signed char gfxEventGetMouseMiddle ( void  )

Returns a copy of the mouse's middle button status.

Returns
Either 1 for pressed or 0 for not pressed.

◆ gfxEventGetMouseRight()

signed char gfxEventGetMouseRight ( void  )

Returns a copy of the mouse's right button status.

Returns
Either 1 for pressed or 0 for not pressed.

◆ gfxEventGetMouseX()

signed short gfxEventGetMouseX ( void  )

Returns a copy of the mouse's most recent X coord (in pixels)

Returns
signed short X axis pixel location of the mouse

◆ gfxEventGetMouseY()

signed short gfxEventGetMouseY ( void  )

Returns a copy of the mouse's most recent Y coord (in pixels)

Returns
signed short Y axis pixel location of the mouse

◆ gfxEventInit()

int gfxEventInit ( void  )

Initializes the GFX Event backend.

Returns
0 on success

Variable Documentation

◆ buttonInputQueue

QueueHandle_t buttonInputQueue
extern