Some formatting review
This commit is contained in:
parent
7c10f971c1
commit
40940f4398
53
src/core.c
53
src/core.c
@ -476,12 +476,13 @@ static EM_BOOL EmscriptenGamepadCallback(int eventType, const EmscriptenGamepadE
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_RPI)
|
#if defined(PLATFORM_RPI)
|
||||||
|
static void InitEvdevInput(void); // Evdev inputs initialization
|
||||||
|
static void EventThreadSpawn(char *device); // Identifies a input device and spawns a thread to handle it if needed
|
||||||
|
static void *EventThread(void *arg); // Input device events reading thread
|
||||||
|
|
||||||
static void InitKeyboard(void); // Init raw keyboard system (standard input reading)
|
static void InitKeyboard(void); // Init raw keyboard system (standard input reading)
|
||||||
static void ProcessKeyboard(void); // Process keyboard events
|
static void ProcessKeyboard(void); // Process keyboard events
|
||||||
static void RestoreKeyboard(void); // Restore keyboard system
|
static void RestoreKeyboard(void); // Restore keyboard system
|
||||||
static void InitEvdevInput(void); // Mouse initialization (including mouse thread)
|
|
||||||
static void EventThreadSpawn(char *device); // Identifies a input device and spawns a thread to handle it if needed
|
|
||||||
static void *EventThread(void *arg); // Input device events reading thread
|
|
||||||
static void InitGamepad(void); // Init raw gamepad input
|
static void InitGamepad(void); // Init raw gamepad input
|
||||||
static void *GamepadThread(void *arg); // Mouse reading thread
|
static void *GamepadThread(void *arg); // Mouse reading thread
|
||||||
#endif
|
#endif
|
||||||
@ -595,7 +596,7 @@ void InitWindow(int width, int height, const char *title)
|
|||||||
|
|
||||||
#if defined(PLATFORM_RPI)
|
#if defined(PLATFORM_RPI)
|
||||||
// Init raw input system
|
// Init raw input system
|
||||||
InitEvdevInput(); // Mouse init
|
InitEvdevInput(); // Evdev inputs initialization
|
||||||
InitKeyboard(); // Keyboard init
|
InitKeyboard(); // Keyboard init
|
||||||
InitGamepad(); // Gamepad init
|
InitGamepad(); // Gamepad init
|
||||||
#endif
|
#endif
|
||||||
@ -629,7 +630,7 @@ void InitWindow(int width, int height, const char *title)
|
|||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
LogoAnimation();
|
LogoAnimation();
|
||||||
}
|
}
|
||||||
#endif // defined(PLATFORM_ANDROID)
|
#endif // PLATFORM_ANDROID
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close window and unload OpenGL context
|
// Close window and unload OpenGL context
|
||||||
@ -2369,12 +2370,12 @@ static bool InitGraphicsDevice(int width, int height)
|
|||||||
// Screen size security check
|
// Screen size security check
|
||||||
if (screenWidth <= 0) screenWidth = displayWidth;
|
if (screenWidth <= 0) screenWidth = displayWidth;
|
||||||
if (screenHeight <= 0) screenHeight = displayHeight;
|
if (screenHeight <= 0) screenHeight = displayHeight;
|
||||||
#endif // defined(PLATFORM_DESKTOP)
|
#endif // PLATFORM_DESKTOP
|
||||||
|
|
||||||
#if defined(PLATFORM_WEB)
|
#if defined(PLATFORM_WEB)
|
||||||
displayWidth = screenWidth;
|
displayWidth = screenWidth;
|
||||||
displayHeight = screenHeight;
|
displayHeight = screenHeight;
|
||||||
#endif // defined(PLATFORM_WEB)
|
#endif // PLATFORM_WEB
|
||||||
|
|
||||||
glfwDefaultWindowHints(); // Set default windows hints:
|
glfwDefaultWindowHints(); // Set default windows hints:
|
||||||
//glfwWindowHint(GLFW_RED_BITS, 8); // Framebuffer red color component bits
|
//glfwWindowHint(GLFW_RED_BITS, 8); // Framebuffer red color component bits
|
||||||
@ -2552,7 +2553,7 @@ static bool InitGraphicsDevice(int width, int height)
|
|||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
TraceLog(LOG_INFO, "Trying to enable VSYNC");
|
TraceLog(LOG_INFO, "Trying to enable VSYNC");
|
||||||
}
|
}
|
||||||
#endif // defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
#endif // PLATFORM_DESKTOP || PLATFORM_WEB
|
||||||
|
|
||||||
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_UWP)
|
#if defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI) || defined(PLATFORM_UWP)
|
||||||
fullscreen = true;
|
fullscreen = true;
|
||||||
@ -2819,7 +2820,7 @@ static bool InitGraphicsDevice(int width, int height)
|
|||||||
//ANativeWindow_setBuffersGeometry(androidApp->window, 0, 0, displayFormat); // Force use of native display size
|
//ANativeWindow_setBuffersGeometry(androidApp->window, 0, 0, displayFormat); // Force use of native display size
|
||||||
|
|
||||||
surface = eglCreateWindowSurface(display, config, androidApp->window, NULL);
|
surface = eglCreateWindowSurface(display, config, androidApp->window, NULL);
|
||||||
#endif // defined(PLATFORM_ANDROID)
|
#endif // PLATFORM_ANDROID
|
||||||
|
|
||||||
#if defined(PLATFORM_RPI)
|
#if defined(PLATFORM_RPI)
|
||||||
graphics_get_display_size(0, &displayWidth, &displayHeight);
|
graphics_get_display_size(0, &displayWidth, &displayHeight);
|
||||||
@ -2859,7 +2860,8 @@ static bool InitGraphicsDevice(int width, int height)
|
|||||||
|
|
||||||
surface = eglCreateWindowSurface(display, config, &nativeWindow, NULL);
|
surface = eglCreateWindowSurface(display, config, &nativeWindow, NULL);
|
||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
#endif // defined(PLATFORM_RPI)
|
#endif // PLATFORM_RPI
|
||||||
|
|
||||||
// There must be at least one frame displayed before the buffers are swapped
|
// There must be at least one frame displayed before the buffers are swapped
|
||||||
//eglSwapInterval(display, 1);
|
//eglSwapInterval(display, 1);
|
||||||
|
|
||||||
@ -2880,7 +2882,7 @@ static bool InitGraphicsDevice(int width, int height)
|
|||||||
TraceLog(LOG_INFO, "Screen size: %i x %i", screenWidth, screenHeight);
|
TraceLog(LOG_INFO, "Screen size: %i x %i", screenWidth, screenHeight);
|
||||||
TraceLog(LOG_INFO, "Viewport offsets: %i, %i", renderOffsetX, renderOffsetY);
|
TraceLog(LOG_INFO, "Viewport offsets: %i, %i", renderOffsetX, renderOffsetY);
|
||||||
}
|
}
|
||||||
#endif // defined(PLATFORM_ANDROID) || defined(PLATFORM_RPI)
|
#endif // PLATFORM_ANDROID || PLATFORM_RPI
|
||||||
|
|
||||||
renderWidth = screenWidth;
|
renderWidth = screenWidth;
|
||||||
renderHeight = screenHeight;
|
renderHeight = screenHeight;
|
||||||
@ -3267,7 +3269,7 @@ static void PollInputEvents(void)
|
|||||||
|
|
||||||
DeleteUWPMessage(msg); //Delete, we are done
|
DeleteUWPMessage(msg); //Delete, we are done
|
||||||
}
|
}
|
||||||
#endif // defined(PLATFORM_UWP)
|
#endif // PLATFORM_UWP
|
||||||
|
|
||||||
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
#if defined(PLATFORM_DESKTOP) || defined(PLATFORM_WEB)
|
||||||
// Mouse input polling
|
// Mouse input polling
|
||||||
@ -3414,12 +3416,11 @@ static void PollInputEvents(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PLATFORM_RPI)
|
#if defined(PLATFORM_RPI)
|
||||||
// NOTE: Mouse input events polling is done asynchonously in another pthread - EventThread()
|
|
||||||
|
|
||||||
// NOTE: Keyboard reading could be done using input_event(s) reading or just read from stdin,
|
// NOTE: Keyboard reading could be done using input_event(s) reading or just read from stdin,
|
||||||
// we now use both methods inside here. 2nd method is still used for legacy purposes (Allows for input trough SSH console)
|
// we now use both methods inside here. 2nd method is still used for legacy purposes (Allows for input trough SSH console)
|
||||||
ProcessKeyboard();
|
ProcessKeyboard();
|
||||||
|
|
||||||
|
// NOTE: Mouse input events polling is done asynchronously in another pthread - EventThread()
|
||||||
// NOTE: Gamepad (Joystick) input events polling is done asynchonously in another pthread - GamepadThread()
|
// NOTE: Gamepad (Joystick) input events polling is done asynchonously in another pthread - GamepadThread()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@ -4244,6 +4245,7 @@ static void InitEvdevInput(void)
|
|||||||
|
|
||||||
// Open the linux directory of "/dev/input"
|
// Open the linux directory of "/dev/input"
|
||||||
directory = opendir(DEFAULT_EVDEV_PATH);
|
directory = opendir(DEFAULT_EVDEV_PATH);
|
||||||
|
|
||||||
if (directory)
|
if (directory)
|
||||||
{
|
{
|
||||||
while ((entity = readdir(directory)) != NULL)
|
while ((entity = readdir(directory)) != NULL)
|
||||||
@ -4460,7 +4462,8 @@ static void EventThreadSpawn(char *device)
|
|||||||
static void *EventThread(void *arg)
|
static void *EventThread(void *arg)
|
||||||
{
|
{
|
||||||
// Scancode to keycode mapping for US keyboards
|
// Scancode to keycode mapping for US keyboards
|
||||||
// TODO: Proabobly replace this with a keymap from the X11 to get the correct regional map for the keyboard (Currently non US keyboards will have the wrong mapping for some keys)
|
// TODO: Probably replace this with a keymap from the X11 to get the correct regional map for the keyboard:
|
||||||
|
// Currently non US keyboards will have the wrong mapping for some keys
|
||||||
static const int keymap_US[] =
|
static const int keymap_US[] =
|
||||||
{ 0,256,49,50,51,52,53,54,55,56,57,48,45,61,259,258,81,87,69,82,84,
|
{ 0,256,49,50,51,52,53,54,55,56,57,48,45,61,259,258,81,87,69,82,84,
|
||||||
89,85,73,79,80,91,93,257,341,65,83,68,70,71,72,74,75,76,59,39,96,
|
89,85,73,79,80,91,93,257,341,65,83,68,70,71,72,74,75,76,59,39,96,
|
||||||
@ -4515,10 +4518,7 @@ static void *EventThread(void *arg)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.code == REL_WHEEL)
|
if (event.code == REL_WHEEL) currentMouseWheelY += event.value;
|
||||||
{
|
|
||||||
currentMouseWheelY += event.value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Absolute movement parsing
|
// Absolute movement parsing
|
||||||
@ -4546,21 +4546,16 @@ static void *EventThread(void *arg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Multitouch movement
|
// Multitouch movement
|
||||||
if (event.code == ABS_MT_SLOT)
|
if (event.code == ABS_MT_SLOT) worker->touchSlot = event.value; // Remeber the slot number for the folowing events
|
||||||
{
|
|
||||||
worker->touchSlot = event.value; // Remeber the slot number for the folowing events
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.code == ABS_MT_POSITION_X)
|
if (event.code == ABS_MT_POSITION_X)
|
||||||
{
|
{
|
||||||
if (worker->touchSlot < MAX_TOUCH_POINTS)
|
if (worker->touchSlot < MAX_TOUCH_POINTS) touchPosition[worker->touchSlot].x = (event.value - worker->absRange.x)*screenWidth/worker->absRange.width; // Scale acording to absRange
|
||||||
touchPosition[worker->touchSlot].x = (event.value - worker->absRange.x)*screenWidth/worker->absRange.width; // Scale acording to absRange
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.code == ABS_MT_POSITION_Y)
|
if (event.code == ABS_MT_POSITION_Y)
|
||||||
{
|
{
|
||||||
if (worker->touchSlot < MAX_TOUCH_POINTS)
|
if (worker->touchSlot < MAX_TOUCH_POINTS) touchPosition[worker->touchSlot].y = (event.value - worker->absRange.y)*screenHeight/worker->absRange.height; // Scale acording to absRange
|
||||||
touchPosition[worker->touchSlot].y = (event.value - worker->absRange.y)*screenHeight/worker->absRange.height; // Scale acording to absRange
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.code == ABS_MT_TRACKING_ID)
|
if (event.code == ABS_MT_TRACKING_ID)
|
||||||
@ -4577,7 +4572,6 @@ static void *EventThread(void *arg)
|
|||||||
// Button parsing
|
// Button parsing
|
||||||
if (event.type == EV_KEY)
|
if (event.type == EV_KEY)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Mouse button parsing
|
// Mouse button parsing
|
||||||
if ((event.code == BTN_TOUCH) || (event.code == BTN_LEFT))
|
if ((event.code == BTN_TOUCH) || (event.code == BTN_LEFT))
|
||||||
{
|
{
|
||||||
@ -4598,6 +4592,7 @@ static void *EventThread(void *arg)
|
|||||||
if ((event.code >= 1) && (event.code <= 255)) //Keyboard keys appear for codes 1 to 255
|
if ((event.code >= 1) && (event.code <= 255)) //Keyboard keys appear for codes 1 to 255
|
||||||
{
|
{
|
||||||
keycode = keymap_US[event.code & 0xFF]; // The code we get is a scancode so we look up the apropriate keycode
|
keycode = keymap_US[event.code & 0xFF]; // The code we get is a scancode so we look up the apropriate keycode
|
||||||
|
|
||||||
// Make sure we got a valid keycode
|
// Make sure we got a valid keycode
|
||||||
if ((keycode > 0) && (keycode < sizeof(currentKeyState)))
|
if ((keycode > 0) && (keycode < sizeof(currentKeyState)))
|
||||||
{
|
{
|
||||||
@ -4610,10 +4605,10 @@ static void *EventThread(void *arg)
|
|||||||
lastKeyPressedEvdev.Head = (lastKeyPressedEvdev.Head + 1) & 0x07; // Increment the head pointer forwards and binary wraparound after 7 (fifo is 8 elements long)
|
lastKeyPressedEvdev.Head = (lastKeyPressedEvdev.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)
|
// 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
TraceLog(LOG_DEBUG, "KEY%s ScanCode: %4i KeyCode: %4i",event.value == 0 ? "UP":"DOWN", event.code, keycode);
|
TraceLog(LOG_DEBUG, "KEY%s ScanCode: %4i KeyCode: %4i",event.value == 0 ? "UP":"DOWN", event.code, keycode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Screen confinement
|
// Screen confinement
|
||||||
|
16
src/rlgl.h
16
src/rlgl.h
@ -831,9 +831,9 @@ static RenderTexture2D stereoFbo; // VR stereo rendering framebuffer
|
|||||||
static bool vrSimulatorReady = false; // VR simulator ready flag
|
static bool vrSimulatorReady = false; // VR simulator ready flag
|
||||||
static bool vrStereoRender = false; // VR stereo rendering enabled/disabled flag
|
static bool vrStereoRender = false; // VR stereo rendering enabled/disabled flag
|
||||||
// NOTE: This flag is useful to render data over stereo image (i.e. FPS)
|
// NOTE: This flag is useful to render data over stereo image (i.e. FPS)
|
||||||
#endif // defined(SUPPORT_VR_SIMULATOR)
|
#endif // SUPPORT_VR_SIMULATOR
|
||||||
|
|
||||||
#endif // defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||||
|
|
||||||
static int blendMode = 0; // Track current blending mode
|
static int blendMode = 0; // Track current blending mode
|
||||||
|
|
||||||
@ -864,7 +864,7 @@ static void GenDrawQuad(void); // Generate and draw quad
|
|||||||
static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView); // Set internal projection and modelview matrix depending on eye
|
static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView); // Set internal projection and modelview matrix depending on eye
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11)
|
||||||
static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight);
|
static int GenerateMipmaps(unsigned char *data, int baseWidth, int baseHeight);
|
||||||
@ -1691,7 +1691,7 @@ void rlglInit(int width, int height)
|
|||||||
projection = MatrixIdentity();
|
projection = MatrixIdentity();
|
||||||
modelview = MatrixIdentity();
|
modelview = MatrixIdentity();
|
||||||
currentMatrix = &modelview;
|
currentMatrix = &modelview;
|
||||||
#endif // defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||||
|
|
||||||
// Initialize OpenGL default states
|
// Initialize OpenGL default states
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------
|
||||||
@ -1883,11 +1883,11 @@ unsigned int rlLoadTexture(void *data, int width, int height, int format, int mi
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif // defined(GRAPHICS_API_OPENGL_11)
|
#endif // GRAPHICS_API_OPENGL_11
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
||||||
|
|
||||||
glGenTextures(1, &id); // Generate Pointer to the texture
|
glGenTextures(1, &id); // Generate texture id
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
||||||
//glActiveTexture(GL_TEXTURE0); // If not defined, using GL_TEXTURE0 by default (shader texture)
|
//glActiveTexture(GL_TEXTURE0); // If not defined, using GL_TEXTURE0 by default (shader texture)
|
||||||
@ -4428,9 +4428,9 @@ static void SetStereoView(int eye, Matrix matProjection, Matrix matModelView)
|
|||||||
SetMatrixModelview(eyeModelView);
|
SetMatrixModelview(eyeModelView);
|
||||||
SetMatrixProjection(eyeProjection);
|
SetMatrixProjection(eyeProjection);
|
||||||
}
|
}
|
||||||
#endif // defined(SUPPORT_VR_SIMULATOR)
|
#endif // SUPPORT_VR_SIMULATOR
|
||||||
|
|
||||||
#endif //defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
|
#endif // GRAPHICS_API_OPENGL_33 || GRAPHICS_API_OPENGL_ES2
|
||||||
|
|
||||||
#if defined(GRAPHICS_API_OPENGL_11)
|
#if defined(GRAPHICS_API_OPENGL_11)
|
||||||
// Mipmaps data is generated after image data
|
// Mipmaps data is generated after image data
|
||||||
|
@ -69,7 +69,7 @@ AAssetManager *assetManager;
|
|||||||
// Module specific Functions Declaration
|
// Module specific Functions Declaration
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
#if defined(PLATFORM_ANDROID)
|
#if defined(PLATFORM_ANDROID)
|
||||||
/* This should be in <stdio.h>, but Travis doesn't find it... */
|
// This should be in <stdio.h>, but Travis does not find it...
|
||||||
FILE *funopen(const void *cookie, int (*readfn)(void *, char *, int), int (*writefn)(void *, const char *, int),
|
FILE *funopen(const void *cookie, int (*readfn)(void *, char *, int), int (*writefn)(void *, const char *, int),
|
||||||
fpos_t (*seekfn)(void *, fpos_t, int), int (*closefn)(void *));
|
fpos_t (*seekfn)(void *, fpos_t, int), int (*closefn)(void *));
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ FILE *android_fopen(const char *fileName, const char *mode)
|
|||||||
|
|
||||||
return funopen(asset, android_read, android_write, android_seek, android_close);
|
return funopen(asset, android_read, android_write, android_seek, android_close);
|
||||||
}
|
}
|
||||||
#endif
|
#endif // PLATFORM_ANDROID
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module specific Functions Definition
|
// Module specific Functions Definition
|
||||||
@ -201,7 +201,7 @@ static int android_close(void *cookie)
|
|||||||
AAsset_close((AAsset *)cookie);
|
AAsset_close((AAsset *)cookie);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif // PLATFORM_ANDROID
|
||||||
|
|
||||||
#if defined(PLATFORM_UWP)
|
#if defined(PLATFORM_UWP)
|
||||||
|
|
||||||
@ -276,4 +276,4 @@ UWPMessage* GetMessageFromUWP(void)
|
|||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
#endif // defined(PLATFORM_UWP)
|
#endif // PLATFORM_UWP
|
||||||
|
Loading…
Reference in New Issue
Block a user