Add SetScreenshotKey to allow users to override the default F12 key for screenshots. Parity with SetExitKey
This commit is contained in:
parent
059ebaa6ad
commit
29285dab0a
|
|
@ -1187,6 +1187,7 @@ RLAPI int GetKeyPressed(void); // Get key pressed
|
||||||
RLAPI int GetCharPressed(void); // Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty
|
RLAPI int GetCharPressed(void); // Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty
|
||||||
RLAPI const char *GetKeyName(int key); // Get name of a QWERTY key on the current keyboard layout (eg returns string 'q' for KEY_A on an AZERTY keyboard)
|
RLAPI const char *GetKeyName(int key); // Get name of a QWERTY key on the current keyboard layout (eg returns string 'q' for KEY_A on an AZERTY keyboard)
|
||||||
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
|
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
|
||||||
|
RLAPI void SetScreenshotKey(int key); // Set a custom key for taking a screenshot (default is F12)
|
||||||
|
|
||||||
// Input-related functions: gamepads
|
// Input-related functions: gamepads
|
||||||
RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available
|
RLAPI bool IsGamepadAvailable(int gamepad); // Check if a gamepad is available
|
||||||
|
|
|
||||||
12
src/rcore.c
12
src/rcore.c
|
|
@ -327,6 +327,7 @@ typedef struct CoreData {
|
||||||
struct {
|
struct {
|
||||||
struct {
|
struct {
|
||||||
int exitKey; // Default exit key
|
int exitKey; // Default exit key
|
||||||
|
int screenshotKey; // Default screenshot key
|
||||||
char currentKeyState[MAX_KEYBOARD_KEYS]; // Registers current frame key state
|
char currentKeyState[MAX_KEYBOARD_KEYS]; // Registers current frame key state
|
||||||
char previousKeyState[MAX_KEYBOARD_KEYS]; // Registers previous frame key state
|
char previousKeyState[MAX_KEYBOARD_KEYS]; // Registers previous frame key state
|
||||||
|
|
||||||
|
|
@ -692,6 +693,8 @@ void InitWindow(int width, int height, const char *title)
|
||||||
// Initialize global input state
|
// Initialize global input state
|
||||||
memset(&CORE.Input, 0, sizeof(CORE.Input)); // Reset CORE.Input structure to 0
|
memset(&CORE.Input, 0, sizeof(CORE.Input)); // Reset CORE.Input structure to 0
|
||||||
CORE.Input.Keyboard.exitKey = KEY_ESCAPE;
|
CORE.Input.Keyboard.exitKey = KEY_ESCAPE;
|
||||||
|
CORE.Input.Keyboard.screenshotKey = KEY_F12;
|
||||||
|
|
||||||
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
|
CORE.Input.Mouse.scale = (Vector2){ 1.0f, 1.0f };
|
||||||
CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW;
|
CORE.Input.Mouse.cursor = MOUSE_CURSOR_ARROW;
|
||||||
CORE.Input.Gamepad.lastButtonPressed = GAMEPAD_BUTTON_UNKNOWN;
|
CORE.Input.Gamepad.lastButtonPressed = GAMEPAD_BUTTON_UNKNOWN;
|
||||||
|
|
@ -940,7 +943,7 @@ void EndDrawing(void)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(SUPPORT_SCREEN_CAPTURE)
|
#if defined(SUPPORT_SCREEN_CAPTURE)
|
||||||
if (IsKeyPressed(KEY_F12))
|
if (IsKeyPressed(CORE.Input.Keyboard.screenshotKey))
|
||||||
{
|
{
|
||||||
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
|
TakeScreenshot(TextFormat("screenshot%03i.png", screenshotCounter));
|
||||||
screenshotCounter++;
|
screenshotCounter++;
|
||||||
|
|
@ -3951,6 +3954,13 @@ void SetExitKey(int key)
|
||||||
CORE.Input.Keyboard.exitKey = key;
|
CORE.Input.Keyboard.exitKey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set a custom key to take a screenshot
|
||||||
|
// NOTE: default screenshotKey is set to F12
|
||||||
|
void SetScreenshotKey(int key)
|
||||||
|
{
|
||||||
|
CORE.Input.Keyboard.screenshotKey = key;
|
||||||
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Functions Definition: Input Handling: Gamepad
|
// Module Functions Definition: Input Handling: Gamepad
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user