raylib input system
raylib input system basically uses an event polling mechanism, centralized on raylib core module.
At the end of the game loop,
EndDrawing() function is called. This function calls
PollInputEvents(), multiple input devices are scanned at that moment and states are reqistered.
Depending on the platform, input events are managed using different mechanisms.
Default supported input systems are:
On this platform GLFW3 library (rglfw) is used for input management. Events polling is done using
|KEYBOARD||GLFW3||Values are registered through callbacks
|MOUSE||GLFW3||Values are registered through callbacks
|GAMEPAD||GLFW3||Values registered by (no-callbacks):
|TOUCH||-||Not available by default. Mouse clicks are mapped to touch events using gestures API.|
Some of the inputs in this platform are directly using GLFW3 because the library has been partially ported to emscripten. Despite that, gamepad and touch inputs are directly managed using emscripten API.
|GAMEPAD||Emscripten||Using emscripten gamepad API:
|TOUCH||Emscripten||Using emscripten touch API:
Android NDK provides its own events polling system:
ALooper_pollAll(), called on
AndroidInputCallback(), all inputs can be later processed. Currently only some inputs are processed but additional inputs could be processed
|KEYBOARD||Android NDK||Keys registered on
|MOUSE||-||Mouse inputs are actually mapped with TOUCH input|
|GAMEPAD||Android NDK||Support partially implemented on
|TOUCH||Android NDK||Touch points registered on
Probably this platform inputs polling is the most complex one. Some input events are polled by multiple secondary threads.
Keyboard polling is a special case, it can use directly
stdin inputs to read keycodes. In that case,
stdin is being reconfigured for ASCII chars reading and reseted at the end of the program... This approach presents several problems like a standard input lose if program is not closed properly but it does not require
X.org libraries or superuser rights... Second option is being implemented to avoid
Probably inputs could be further improved in all platforms, specially TOUCH inputs support and mapping with MOUSE.