Browse Source

Merge b4f97addf7 into 68503ed96f

pull/4481/merge
Jeffery Myers 19 hours ago
committed by GitHub
parent
commit
365f96b461
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
12 changed files with 479 additions and 431 deletions
  1. +11
    -0
      parser/output/raylib_api.json
  2. +8
    -0
      parser/output/raylib_api.lua
  3. +420
    -415
      parser/output/raylib_api.txt
  4. +4
    -1
      parser/output/raylib_api.xml
  5. +2
    -1
      src/platforms/rcore_android.c
  6. +2
    -1
      src/platforms/rcore_desktop_glfw.c
  7. +2
    -1
      src/platforms/rcore_desktop_rgfw.c
  8. +2
    -1
      src/platforms/rcore_desktop_sdl.c
  9. +8
    -4
      src/platforms/rcore_drm.c
  10. +2
    -1
      src/platforms/rcore_web.c
  11. +1
    -0
      src/raylib.h
  12. +17
    -6
      src/rcore.c

+ 11
- 0
parser/output/raylib_api.json View File

@ -4881,6 +4881,17 @@
"description": "Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty",
"returnType": "int"
},
{
"name": "GetKeyPressedPro",
"description": "Get key pressed (keycode), and optional scancode, call it multiple times for keys queued, returns 0 when the queue is empty",
"returnType": "int",
"params": [
{
"type": "int*",
"name": "scanCode"
}
]
},
{
"name": "SetExitKey",
"description": "Set a custom key to exit program (default is ESC)",

+ 8
- 0
parser/output/raylib_api.lua View File

@ -4326,6 +4326,14 @@ return {
description = "Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty",
returnType = "int"
},
{
name = "GetKeyPressedPro",
description = "Get key pressed (keycode), and optional scancode, call it multiple times for keys queued, returns 0 when the queue is empty",
returnType = "int",
params = {
{type = "int*", name = "scanCode"}
}
},
{
name = "SetExitKey",
description = "Set a custom key to exit program (default is ESC)",

+ 420
- 415
parser/output/raylib_api.txt
File diff suppressed because it is too large
View File


+ 4
- 1
parser/output/raylib_api.xml View File

@ -674,7 +674,7 @@
<Param type="unsigned int" name="frames" desc="" />
</Callback>
</Callbacks>
<Functions count="581">
<Functions count="582">
<Function name="InitWindow" retType="void" paramCount="3" desc="Initialize window and OpenGL context">
<Param type="int" name="width" desc="" />
<Param type="int" name="height" desc="" />
@ -1181,6 +1181,9 @@
</Function>
<Function name="GetCharPressed" retType="int" paramCount="0" desc="Get char pressed (unicode), call it multiple times for chars queued, returns 0 when the queue is empty">
</Function>
<Function name="GetKeyPressedPro" retType="int" paramCount="1" desc="Get key pressed (keycode), and optional scancode, call it multiple times for keys queued, returns 0 when the queue is empty">
<Param type="int*" name="scanCode" desc="" />
</Function>
<Function name="SetExitKey" retType="void" paramCount="1" desc="Set a custom key to exit program (default is ESC)">
<Param type="int" name="key" desc="" />
</Function>

+ 2
- 1
src/platforms/rcore_android.c View File

@ -1225,7 +1225,8 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
{
CORE.Input.Keyboard.currentKeyState[key] = 1; // Key down
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].keycode = key;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].scancode = -1;
CORE.Input.Keyboard.keyPressedQueueCount++;
}
else if (AKeyEvent_getAction(event) == AKEY_EVENT_ACTION_MULTIPLE) CORE.Input.Keyboard.keyRepeatInFrame[key] = 1;

+ 2
- 1
src/platforms/rcore_desktop_glfw.c View File

@ -1806,7 +1806,8 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
if ((CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE) && (action == GLFW_PRESS))
{
// Add character to the queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].keycode = key;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].scancode = scancode;
CORE.Input.Keyboard.keyPressedQueueCount++;
}

+ 2
- 1
src/platforms/rcore_desktop_rgfw.c View File

@ -1001,7 +1001,8 @@ void PollInputEvents(void)
// If key was up, add it to the key pressed queue
if ((CORE.Input.Keyboard.currentKeyState[key] == 0) && (CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE))
{
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].keycode = key;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].scancode = event->keyCode;
CORE.Input.Keyboard.keyPressedQueueCount++;
}

+ 2
- 1
src/platforms/rcore_desktop_sdl.c View File

@ -1483,7 +1483,8 @@ void PollInputEvents(void)
// If key was up, add it to the key pressed queue
if ((CORE.Input.Keyboard.currentKeyState[key] == 0) && (CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE))
{
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].keycode = key;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].scancode = event.key.keysym.scancode;
CORE.Input.Keyboard.keyPressedQueueCount++;
}

+ 8
- 4
src/platforms/rcore_drm.c View File

@ -1299,14 +1299,16 @@ static void ProcessKeyboard(void)
{
CORE.Input.Keyboard.currentKeyState[257] = 1;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = 257; // Add keys pressed into queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].keycode = 257; // Add keys pressed into queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].scancode = -1;
CORE.Input.Keyboard.keyPressedQueueCount++;
}
else if (keysBuffer[i] == 0x7f) // raylib KEY_BACKSPACE
{
CORE.Input.Keyboard.currentKeyState[259] = 1;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = 257; // Add keys pressed into queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].keycode = 257; // Add keys pressed into queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].scancode = -1;
CORE.Input.Keyboard.keyPressedQueueCount++;
}
else
@ -1318,7 +1320,8 @@ static void ProcessKeyboard(void)
}
else CORE.Input.Keyboard.currentKeyState[(int)keysBuffer[i]] = 1;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = keysBuffer[i]; // Add keys pressed into queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].keycode = keysBuffer[i]; // Add keys pressed into queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].scancode = -1;
CORE.Input.Keyboard.keyPressedQueueCount++;
}
}
@ -1610,7 +1613,8 @@ static void PollKeyboardEvents(void)
{
if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_CHAR_PRESSED_QUEUE)
{
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = keycode;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].keycode = keycode;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].scancode = (int)event.code;
CORE.Input.Keyboard.keyPressedQueueCount++;
}

+ 2
- 1
src/platforms/rcore_web.c View File

@ -1486,7 +1486,8 @@ static void KeyCallback(GLFWwindow *window, int key, int scancode, int action, i
if ((CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE) && (action == GLFW_PRESS))
{
// Add character to the queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = key;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].keycode = key;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].scancode = scancode;
CORE.Input.Keyboard.keyPressedQueueCount++;
}

+ 1
- 0
src/raylib.h View File

@ -1177,6 +1177,7 @@ RLAPI bool IsKeyReleased(int key); // Check if a key
RLAPI bool IsKeyUp(int key); // Check if a key is NOT being pressed
RLAPI int GetKeyPressed(void); // Get key pressed (keycode), call it multiple times for keys 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 int GetKeyPressedPro(int* scanCode); // Get key pressed (keycode), and optional scancode, call it multiple times for keys queued, returns 0 when the queue is empty
RLAPI void SetExitKey(int key); // Set a custom key to exit program (default is ESC)
// Input-related functions: gamepads

+ 17
- 6
src/rcore.c View File

@ -268,6 +268,7 @@ __declspec(dllimport) unsigned int __stdcall timeEndPeriod(unsigned int uPeriod)
//----------------------------------------------------------------------------------
typedef struct { int x; int y; } Point;
typedef struct { unsigned int width; unsigned int height; } Size;
typedef struct { int keycode; int scancode; } KeyCodes;
// Core global state context data
typedef struct CoreData {
@ -310,7 +311,7 @@ typedef struct CoreData {
// NOTE: Since key press logic involves comparing prev vs cur key state, we need to handle key repeats specially
char keyRepeatInFrame[MAX_KEYBOARD_KEYS]; // Registers key repeats for current frame
kt">int keyPressedQueue[MAX_KEY_PRESSED_QUEUE]; // Input keys queue
n">KeyCodes keyPressedQueue[MAX_KEY_PRESSED_QUEUE]; // Input keys queue
int keyPressedQueueCount; // Input keys queue count
int charPressedQueue[MAX_CHAR_PRESSED_QUEUE]; // Input characters queue (unicode)
@ -3052,7 +3053,8 @@ void PlayAutomationEvent(AutomationEvent event)
if (CORE.Input.Keyboard.keyPressedQueueCount < MAX_KEY_PRESSED_QUEUE)
{
// Add character to the queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount] = event.params[0];
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].keycode = event.params[0];
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount].scancode = -1;
CORE.Input.Keyboard.keyPressedQueueCount++;
}
}
@ -3180,28 +3182,37 @@ bool IsKeyUp(int key)
return up;
}
// Get the last key pressed
int GetKeyPressed(void)
// Get the last key and scancode pressed
int GetKeyPressedPro(int* scanCode)
{
int value = 0;
if (CORE.Input.Keyboard.keyPressedQueueCount > 0)
{
// Get character from the queue head
value = CORE.Input.Keyboard.keyPressedQueue[0];
value = CORE.Input.Keyboard.keyPressedQueue[0].keycode;
if (scanCode != NULL)
*scanCode = CORE.Input.Keyboard.keyPressedQueue[0].scancode;
// Shift elements 1 step toward the head
for (int i = 0; i < (CORE.Input.Keyboard.keyPressedQueueCount - 1); i++)
CORE.Input.Keyboard.keyPressedQueue[i] = CORE.Input.Keyboard.keyPressedQueue[i + 1];
// Reset last character in the queue
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount - 1] = 0;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount - 1].keycode = 0;
CORE.Input.Keyboard.keyPressedQueue[CORE.Input.Keyboard.keyPressedQueueCount - 1].scancode = -1;
CORE.Input.Keyboard.keyPressedQueueCount--;
}
return value;
}
// Get the last key pressed
int GetKeyPressed(void)
{
return GetKeyPressedPro(NULL);
}
// Get the last char pressed
int GetCharPressed(void)
{

Loading…
Cancel
Save