2 Commits

2 changed files with 47 additions and 10 deletions

View File

@ -1806,8 +1806,9 @@ static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara
//case WM_QUIT: // Application closing, not related to window //case WM_QUIT: // Application closing, not related to window
case WM_KILLFOCUS: case WM_KILLFOCUS:
{ {
memset(CORE.Input.Keyboard.previousKeyState, 0, sizeof(CORE.Input.Keyboard.previousKeyState));
memset(CORE.Input.Keyboard.currentKeyState, 0, sizeof(CORE.Input.Keyboard.currentKeyState)); memset(CORE.Input.Keyboard.currentKeyState, 0, sizeof(CORE.Input.Keyboard.currentKeyState));
memset(CORE.Input.Mouse.currentButtonState, 0, sizeof(CORE.Input.Mouse.currentButtonState));
memset(CORE.Input.Touch.currentTouchState, 0, sizeof(CORE.Input.Touch.currentTouchState));
} break; } break;
case WM_SIZING: // Sent to a window that the user is resizing case WM_SIZING: // Sent to a window that the user is resizing
{ {
@ -2287,9 +2288,45 @@ static void HandleKey(WPARAM wparam, LPARAM lparam, char state)
// Handle mouse button input event // Handle mouse button input event
static void HandleMouseButton(int button, char state) static void HandleMouseButton(int button, char state)
{ {
if (state == 1)
{
// Capture the mouse on MOUSEDOWN events and no other buttons are pressed
bool allMouseButtonsReleased = true;
for (unsigned int i = 0; i < MAX_MOUSE_BUTTONS; i++)
{
if (CORE.Input.Mouse.currentButtonState[i] != 0)
{
allMouseButtonsReleased = false;
break;
}
}
if (allMouseButtonsReleased)
{
SetCapture(platform.hwnd);
}
}
// Register current mouse button state // Register current mouse button state
CORE.Input.Mouse.currentButtonState[button] = state; CORE.Input.Mouse.currentButtonState[button] = state;
CORE.Input.Touch.currentTouchState[button] = state; CORE.Input.Touch.currentTouchState[button] = state;
if (state == 0)
{
// Release mouse capture when all mouse buttons are released
bool allMouseButtonsReleased = true;
for (unsigned int i = 0; i < MAX_MOUSE_BUTTONS; i++)
{
if (CORE.Input.Mouse.currentButtonState[i] != 0)
{
allMouseButtonsReleased = false;
break;
}
}
if (allMouseButtonsReleased)
{
ReleaseCapture();
}
}
} }
// Handle raw input event // Handle raw input event

View File

@ -1862,7 +1862,7 @@ void TraceLog(int logType, const char *text, ...)
va_list args; va_list args;
va_start(args, text); va_start(args, text);
if (traceLog) if (traceLog != NULL)
{ {
traceLog(logType, text, args); traceLog(logType, text, args);
va_end(args); va_end(args);
@ -1948,7 +1948,7 @@ unsigned char *LoadFileData(const char *fileName, int *dataSize)
if (fileName != NULL) if (fileName != NULL)
{ {
if (loadFileData) return loadFileData(fileName, dataSize); if (loadFileData != NULL) return loadFileData(fileName, dataSize);
FILE *file = fopen(fileName, "rb"); FILE *file = fopen(fileName, "rb");
@ -2012,7 +2012,7 @@ bool SaveFileData(const char *fileName, const void *data, int dataSize)
if (fileName != NULL) if (fileName != NULL)
{ {
if (saveFileData) return saveFileData(fileName, data, dataSize); if (saveFileData != NULL) return saveFileData(fileName, data, dataSize);
FILE *file = fopen(fileName, "wb"); FILE *file = fopen(fileName, "wb");
@ -2097,7 +2097,7 @@ char *LoadFileText(const char *fileName)
if (fileName != NULL) if (fileName != NULL)
{ {
if (loadFileText) return loadFileText(fileName); if (loadFileText != NULL) return loadFileText(fileName);
FILE *file = fopen(fileName, "rt"); FILE *file = fopen(fileName, "rt");
@ -2153,7 +2153,7 @@ bool SaveFileText(const char *fileName, const char *text)
if (fileName != NULL) if (fileName != NULL)
{ {
if (saveFileText) return saveFileText(fileName, text); if (saveFileText != NULL) return saveFileText(fileName, text);
FILE *file = fopen(fileName, "wt"); FILE *file = fopen(fileName, "wt");
@ -2422,7 +2422,7 @@ bool IsFileHidden(const char *filePath)
if ((attribs != -1) && ((attribs & 0x2UL) != 0)) result = true; if ((attribs != -1) && ((attribs & 0x2UL) != 0)) result = true;
#else #else
const char *basePath = strrchr(filePath, '/'); const char *basePath = strrchr(filePath, '/');
basePath = (basePath? basePath + 1 : filePath); basePath = ((basePath != NULL)? basePath + 1 : filePath);
if ((basePath[0] == '.') && (strcmp(basePath, ".") != 0) && (strcmp(basePath, "..") != 0)) result = true; if ((basePath[0] == '.') && (strcmp(basePath, ".") != 0) && (strcmp(basePath, "..") != 0)) result = true;
#endif #endif
@ -2494,7 +2494,7 @@ const char *GetFileExtension(const char *fileName)
{ {
const char *dot = strrchr(fileName, '.'); const char *dot = strrchr(fileName, '.');
if (!dot || (dot == fileName)) return NULL; if ((dot == NULL) || (dot == fileName)) return NULL;
return dot; return dot;
} }
@ -2504,7 +2504,7 @@ static const char *strprbrk(const char *text, const char *charset)
{ {
const char *latestMatch = NULL; const char *latestMatch = NULL;
for (; (text != NULL) && (text = strpbrk(text, charset)); latestMatch = text++) { } for (; (text != NULL) && ((text = strpbrk(text, charset)) != NULL); latestMatch = text++) { }
return latestMatch; return latestMatch;
} }
@ -2575,7 +2575,7 @@ const char *GetDirectoryPath(const char *filePath)
} }
lastSlash = strprbrk(filePath, "\\/"); lastSlash = strprbrk(filePath, "\\/");
if (lastSlash) if (lastSlash != NULL)
{ {
if (lastSlash == filePath) if (lastSlash == filePath)
{ {