Add no exit key config option

Make it possible for the exit key to not exit the program when pressed.
This commit is contained in:
Gota7 2022-05-30 15:18:57 -04:00
parent cc06d0d462
commit 22f5e4c7f9
2 changed files with 6 additions and 5 deletions

View File

@ -502,7 +502,8 @@ typedef enum {
FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer
FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI
FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X
FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D) FLAG_INTERLACED_HINT = 0x00010000, // Set to try enabling interlaced video format (for V3D)
FLAG_DISABLE_EXIT_KEY = 0x00004000 // Set to disable the exit key to close the window.
} ConfigFlags; } ConfigFlags;
// Trace log level // Trace log level

View File

@ -5253,7 +5253,7 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
} }
// Check the exit key to set close window // Check the exit key to set close window
if ((key == CORE.Input.Keyboard.exitKey) && (action == GLFW_PRESS)) glfwSetWindowShouldClose(CORE.Window.handle, GLFW_TRUE); if ((CORE.Window.flags & FLAG_DISABLE_EXIT_KEY) == 0 && (key == CORE.Input.Keyboard.exitKey) && (action == GLFW_PRESS)) glfwSetWindowShouldClose(CORE.Window.handle, GLFW_TRUE);
#if defined(SUPPORT_SCREEN_CAPTURE) #if defined(SUPPORT_SCREEN_CAPTURE)
if ((key == GLFW_KEY_F12) && (action == GLFW_PRESS)) if ((key == GLFW_KEY_F12) && (action == GLFW_PRESS))
@ -5882,7 +5882,7 @@ static void ProcessKeyboard(void)
if (keysBuffer[i] == 0x1b) if (keysBuffer[i] == 0x1b)
{ {
// Check if ESCAPE key has been pressed to stop program // Check if ESCAPE key has been pressed to stop program
if (bufferByteCount == 1) CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] = 1; if (bufferByteCount == 1 && (CORE.Window.flags & FLAG_DISABLE_EXIT_KEY) == 0) CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] = 1;
else else
{ {
if (keysBuffer[i + 1] == 0x5b) // Special function key if (keysBuffer[i + 1] == 0x5b) // Special function key
@ -5957,7 +5957,7 @@ static void ProcessKeyboard(void)
} }
// Check exit key (same functionality as GLFW3 KeyCallback()) // Check exit key (same functionality as GLFW3 KeyCallback())
if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] == 1) CORE.Window.shouldClose = true; if ((CORE.Window.flags & FLAG_DISABLE_EXIT_KEY) == 0 && CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] == 1) CORE.Window.shouldClose = true;
#if defined(SUPPORT_SCREEN_CAPTURE) #if defined(SUPPORT_SCREEN_CAPTURE)
// Check screen capture key (raylib key: KEY_F12) // Check screen capture key (raylib key: KEY_F12)
@ -6278,7 +6278,7 @@ static void PollKeyboardEvents(void)
} }
#endif #endif
if (CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] == 1) CORE.Window.shouldClose = true; if ((CORE.Window.flags & FLAG_DISABLE_EXIT_KEY) == 0 && CORE.Input.Keyboard.currentKeyState[CORE.Input.Keyboard.exitKey] == 1) CORE.Window.shouldClose = true;
TRACELOGD("RPI: KEY_%s ScanCode: %4i KeyCode: %4i", event.value == 0 ? "UP":"DOWN", event.code, keycode); TRACELOGD("RPI: KEY_%s ScanCode: %4i KeyCode: %4i", event.value == 0 ? "UP":"DOWN", event.code, keycode);
} }