From 5654347c5d511c53146fe4ce1710938b311d986e Mon Sep 17 00:00:00 2001 From: Greg V Date: Mon, 28 Sep 2020 04:50:57 +0300 Subject: Use glfwSetFramebufferSizeCallback instead of glfwSetWindowSizeCallback Framebuffer size is scaled by the display scale. This fixes the game being shrunk to the bottom left quarter of the window on Wayland HiDPI setups. Corresponding change in librw: glfwGetWindowSize -> glfwGetFramebufferSize. --- src/skel/glfw/glfw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index b9dbf5ac..f1b9c695 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -881,7 +881,7 @@ void psPostRWinit(void) RwEngineGetVideoModeInfo(&vm, GcurSelVM); glfwSetKeyCallback(PSGLOBAL(window), keypressCB); - glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB); + glfwSetFramebufferSizeCallback(PSGLOBAL(window), resizeCB); glfwSetScrollCallback(PSGLOBAL(window), scrollCB); glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB); glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB); -- cgit v1.2.3 From b95accb8ff6a594d1a920b94823b38be3515f149 Mon Sep 17 00:00:00 2001 From: Greg V Date: Mon, 28 Sep 2020 04:52:13 +0300 Subject: glfw: scale cursor position by the ratio of framebuffer to screen size This fixes the mouse being constrained to the top left quarter of the window on Wayland HiDPI setups. --- src/skel/glfw/glfw.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index f1b9c695..d7054b9c 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1397,8 +1397,11 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) { // TODO this only works in frontend(and luckily only frontend use this). Fun fact: if I get pos manually in game, glfw reports that it's > 32000 void cursorCB(GLFWwindow* window, double xpos, double ypos) { - FrontEndMenuManager.m_nMouseTempPosX = xpos; - FrontEndMenuManager.m_nMouseTempPosY = ypos; + int bufw, bufh, winw, winh; + glfwGetWindowSize(window, &winw, &winh); + glfwGetFramebufferSize(window, &bufw, &bufh); + FrontEndMenuManager.m_nMouseTempPosX = xpos * (bufw / winw); + FrontEndMenuManager.m_nMouseTempPosY = ypos * (bufh / winh); } void -- cgit v1.2.3 From 0205960a2fe13174b5dc17abf080b6821a3c883a Mon Sep 17 00:00:00 2001 From: Greg V Date: Mon, 28 Sep 2020 04:53:15 +0300 Subject: Use GLFW_CURSOR_DISABLED (glfw's native mouse restriction) On Wayland, clients cannot move the mouse pointer. Mouse constraints, as required for 3D camera movement, are an explicit specific thing, and glfw supports it with GLFW_CURSOR_DISABLED. Use DISABLED, unless we're in a menu in windowed mode, where HIDDEN is still appropriate. --- src/skel/glfw/glfw.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index d7054b9c..e954e04b 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1628,6 +1628,8 @@ main(int argc, char *argv[]) #endif { glfwPollEvents(); + glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, + (FrontEndMenuManager.m_bMenuActive && !PSGLOBAL(fullScreen)) ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED); if( ForegroundApp ) { switch ( gGameState ) -- cgit v1.2.3 From 7d03a6fe291ff72edcf517dda1de8aee40941019 Mon Sep 17 00:00:00 2001 From: Greg V Date: Mon, 28 Sep 2020 04:59:14 +0300 Subject: Use CLOCK_MONOTONIC_FAST when available (FreeBSD) CLOCK_MONOTONIC_FAST is the equivalent of Linux's CLOCK_MONOTONIC_RAW. --- src/skel/glfw/glfw.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index e954e04b..02546ffc 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -235,8 +235,10 @@ double psTimer(void) { struct timespec start; -#ifdef __linux__ +#if defined(CLOCK_MONOTONIC_RAW) clock_gettime(CLOCK_MONOTONIC_RAW, &start); +#elif defined(CLOCK_MONOTONIC_FAST) + clock_gettime(CLOCK_MONOTONIC_FAST, &start); #else clock_gettime(CLOCK_MONOTONIC, &start); #endif -- cgit v1.2.3 From a6aa782d6d5fa9a2165dafec5794a2e2cfbc653f Mon Sep 17 00:00:00 2001 From: erorcun Date: Sun, 18 Oct 2020 19:16:37 +0300 Subject: Fixes and style changes from miami --- src/skel/glfw/glfw.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index cdb73992..4d41a900 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -418,7 +418,7 @@ psInitialize(void) } else if ( verInfo.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ) { - if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion == 1 ) + if ( verInfo.dwMajorVersion > 4 || verInfo.dwMajorVersion == 4 && verInfo.dwMinorVersion != 0 ) { debug("Operating System is Win98\n"); _dwOperatingSystemVersion = OS_WIN98; @@ -1220,14 +1220,17 @@ void resizeCB(GLFWwindow* window, int width, int height) { * memory things don't work. */ /* redraw window */ - if (RwInitialised && (gGameState == GS_PLAYING_GAME #ifndef MASTER - || gGameState == GS_ANIMVIEWER -#endif - )) + if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER)) { - RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void*)TRUE); + RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE); } +#else + if (RwInitialised && gGameState == GS_PLAYING_GAME) + { + RsEventHandler(rsIDLE, (void *)TRUE); + } +#endif if (RwInitialised && height > 0 && width > 0) { RwRect r; -- cgit v1.2.3 From 3b1debaa0d5341bdb954654503424fb12b529894 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 16 Nov 2020 15:28:10 +0300 Subject: Fix mouse lock/high-dpi --- src/skel/glfw/glfw.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index d8d168c5..86abca64 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -885,7 +885,13 @@ void _InputInitialiseJoys() long _InputInitialiseMouse() { +#ifdef IMPROVED_VIDEOMODE + // May be windowed, transition will be handled in CMenuManager::SwitchMenuOnAndOff() glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); +#else + // Always fullscreen, disable mouse + glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_DISABLED); +#endif return 0; } @@ -1416,11 +1422,13 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) { // TODO this only works in frontend(and luckily only frontend use this). Fun fact: if I get pos manually in game, glfw reports that it's > 32000 void cursorCB(GLFWwindow* window, double xpos, double ypos) { - int bufw, bufh, winw, winh; - glfwGetWindowSize(window, &winw, &winh); - glfwGetFramebufferSize(window, &bufw, &bufh); - FrontEndMenuManager.m_nMouseTempPosX = xpos * (bufw / winw); - FrontEndMenuManager.m_nMouseTempPosY = ypos * (bufh / winh); + if (!FrontEndMenuManager.m_bMenuActive) + return; + + int winw, winh; + glfwGetWindowSize(PSGLOBAL(window), &winw, &winh); + FrontEndMenuManager.m_nMouseTempPosX = xpos * (RsGlobal.maximumWidth / winw); + FrontEndMenuManager.m_nMouseTempPosY = ypos * (RsGlobal.maximumHeight / winh); } void @@ -1648,8 +1656,6 @@ main(int argc, char *argv[]) #endif { glfwPollEvents(); - glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, - (FrontEndMenuManager.m_bMenuActive && !PSGLOBAL(fullScreen)) ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED); if( ForegroundApp ) { switch ( gGameState ) -- cgit v1.2.3 From f33ed2892a7a083d10c89b93b0122c6b4100a9a2 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 16 Nov 2020 15:49:00 +0300 Subject: Fix mouse lock/high-dpi 2 --- src/skel/glfw/glfw.cpp | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 86abca64..982e8641 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -885,13 +885,7 @@ void _InputInitialiseJoys() long _InputInitialiseMouse() { -#ifdef IMPROVED_VIDEOMODE - // May be windowed, transition will be handled in CMenuManager::SwitchMenuOnAndOff() glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); -#else - // Always fullscreen, disable mouse - glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_DISABLED); -#endif return 0; } -- cgit v1.2.3 From d05c50ea743f42bc9c426b7b6c2f9598b8bc7f94 Mon Sep 17 00:00:00 2001 From: Greg V Date: Mon, 28 Sep 2020 04:50:57 +0300 Subject: Use glfwSetFramebufferSizeCallback instead of glfwSetWindowSizeCallback Framebuffer size is scaled by the display scale. This fixes the game being shrunk to the bottom left quarter of the window on Wayland HiDPI setups. Corresponding change in librw: glfwGetWindowSize -> glfwGetFramebufferSize. --- src/skel/glfw/glfw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 26a3a509..73d6fb05 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -917,7 +917,7 @@ void psPostRWinit(void) RwEngineGetVideoModeInfo(&vm, GcurSelVM); glfwSetKeyCallback(PSGLOBAL(window), keypressCB); - glfwSetWindowSizeCallback(PSGLOBAL(window), resizeCB); + glfwSetFramebufferSizeCallback(PSGLOBAL(window), resizeCB); glfwSetScrollCallback(PSGLOBAL(window), scrollCB); glfwSetCursorPosCallback(PSGLOBAL(window), cursorCB); glfwSetCursorEnterCallback(PSGLOBAL(window), cursorEnterCB); -- cgit v1.2.3 From 7c1497a058cdf877a2e9fbc3ae607ad1cf733c61 Mon Sep 17 00:00:00 2001 From: Greg V Date: Mon, 28 Sep 2020 04:52:13 +0300 Subject: glfw: scale cursor position by the ratio of framebuffer to screen size This fixes the mouse being constrained to the top left quarter of the window on Wayland HiDPI setups. --- src/skel/glfw/glfw.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 73d6fb05..8d1b7d90 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1438,8 +1438,11 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) { // TODO this only works in frontend(and luckily only frontend use this). Fun fact: if I get pos manually in game, glfw reports that it's > 32000 void cursorCB(GLFWwindow* window, double xpos, double ypos) { - FrontEndMenuManager.m_nMouseTempPosX = xpos; - FrontEndMenuManager.m_nMouseTempPosY = ypos; + int bufw, bufh, winw, winh; + glfwGetWindowSize(window, &winw, &winh); + glfwGetFramebufferSize(window, &bufw, &bufh); + FrontEndMenuManager.m_nMouseTempPosX = xpos * (bufw / winw); + FrontEndMenuManager.m_nMouseTempPosY = ypos * (bufh / winh); } void -- cgit v1.2.3 From 1544acff059e8e064f9eda8bc4908334b95f6a96 Mon Sep 17 00:00:00 2001 From: Greg V Date: Mon, 28 Sep 2020 04:53:15 +0300 Subject: Use GLFW_CURSOR_DISABLED (glfw's native mouse restriction) On Wayland, clients cannot move the mouse pointer. Mouse constraints, as required for 3D camera movement, are an explicit specific thing, and glfw supports it with GLFW_CURSOR_DISABLED. Use DISABLED, unless we're in a menu in windowed mode, where HIDDEN is still appropriate. --- src/skel/glfw/glfw.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 8d1b7d90..1217fc70 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1670,6 +1670,8 @@ main(int argc, char *argv[]) #endif { glfwPollEvents(); + glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, + (FrontEndMenuManager.m_bMenuActive && !PSGLOBAL(fullScreen)) ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED); if( ForegroundApp ) { switch ( gGameState ) -- cgit v1.2.3 From 2ce9e540da10d4d52ec8bf1defa9ccd45312e3b3 Mon Sep 17 00:00:00 2001 From: Greg V Date: Mon, 28 Sep 2020 04:59:14 +0300 Subject: Use CLOCK_MONOTONIC_FAST when available (FreeBSD) CLOCK_MONOTONIC_FAST is the equivalent of Linux's CLOCK_MONOTONIC_RAW. --- src/skel/glfw/glfw.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 1217fc70..fbd40ba2 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -249,8 +249,10 @@ double psTimer(void) { struct timespec start; -#ifdef __linux__ +#if defined(CLOCK_MONOTONIC_RAW) clock_gettime(CLOCK_MONOTONIC_RAW, &start); +#elif defined(CLOCK_MONOTONIC_FAST) + clock_gettime(CLOCK_MONOTONIC_FAST, &start); #else clock_gettime(CLOCK_MONOTONIC, &start); #endif -- cgit v1.2.3 From 54214dd2c4da79945b9f6b8b3a31ba5ddb8a0b84 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 16 Nov 2020 15:28:10 +0300 Subject: Fix mouse lock/high-dpi --- src/skel/glfw/glfw.cpp | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index fbd40ba2..cac487b1 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -896,9 +896,12 @@ void _InputInitialiseJoys() } } +int lastCursorMode = GLFW_CURSOR_HIDDEN; long _InputInitialiseMouse(bool exclusive) { - glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, GLFW_CURSOR_HIDDEN); + // Disabled = keep cursor centered and hide + lastCursorMode = exclusive ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_HIDDEN; + glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, lastCursorMode); return 0; } @@ -907,10 +910,17 @@ void _InputShutdownMouse() // Not needed } +// Not "needs exclusive" on GLFW, but more like "needs to change mode" bool _InputMouseNeedsExclusive() { - // That was the cause of infamous mouse bug on Win. Not supported on glfw anyway - return false; + // That was the cause of infamous mouse bug on Win. + + RwVideoMode vm; + RwEngineGetVideoModeInfo(&vm, GcurSelVM); + + // If windowed, free the cursor on menu(where this func. is called and DISABLED-HIDDEN transition is done accordingly) + // If it's fullscreen, be sure that it didn't stuck on HIDDEN. + return !(vm.flags & rwVIDEOMODEEXCLUSIVE) || lastCursorMode == GLFW_CURSOR_HIDDEN; } void psPostRWinit(void) @@ -1440,11 +1450,13 @@ _InputTranslateShiftKeyUpDown(RsKeyCodes *rs) { // TODO this only works in frontend(and luckily only frontend use this). Fun fact: if I get pos manually in game, glfw reports that it's > 32000 void cursorCB(GLFWwindow* window, double xpos, double ypos) { - int bufw, bufh, winw, winh; - glfwGetWindowSize(window, &winw, &winh); - glfwGetFramebufferSize(window, &bufw, &bufh); - FrontEndMenuManager.m_nMouseTempPosX = xpos * (bufw / winw); - FrontEndMenuManager.m_nMouseTempPosY = ypos * (bufh / winh); + if (!FrontEndMenuManager.m_bMenuActive) + return; + + int winw, winh; + glfwGetWindowSize(PSGLOBAL(window), &winw, &winh); + FrontEndMenuManager.m_nMouseTempPosX = xpos * (RsGlobal.maximumWidth / winw); + FrontEndMenuManager.m_nMouseTempPosY = ypos * (RsGlobal.maximumHeight / winh); } void @@ -1672,8 +1684,6 @@ main(int argc, char *argv[]) #endif { glfwPollEvents(); - glfwSetInputMode(PSGLOBAL(window), GLFW_CURSOR, - (FrontEndMenuManager.m_bMenuActive && !PSGLOBAL(fullScreen)) ? GLFW_CURSOR_HIDDEN : GLFW_CURSOR_DISABLED); if( ForegroundApp ) { switch ( gGameState ) -- cgit v1.2.3 From 4ddc35634160da5779c46ab63a5b3d351af50b83 Mon Sep 17 00:00:00 2001 From: aap Date: Wed, 25 Nov 2020 22:49:50 +0100 Subject: memory heap starting to work --- src/skel/glfw/glfw.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 982e8641..2722a4df 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -40,6 +40,7 @@ #include "Sprite2d.h" #include "AnimViewer.h" #include "Font.h" +#include "MemoryHeap.h" #define MAX_SUBSYSTEMS (16) @@ -277,7 +278,11 @@ psMouseSetPos(RwV2d *pos) RwMemoryFunctions* psGetMemoryFunctions(void) { +#ifdef USE_CUSTOM_ALLOCATOR + return &memFuncs; +#else return nil; +#endif } /* @@ -1461,6 +1466,10 @@ main(int argc, char *argv[]) RwV2d pos; RwInt32 i; +#ifdef USE_CUSTOM_ALLOCATOR + InitMemoryMgr(); +#endif + #ifndef _WIN32 struct sigaction act; act.sa_sigaction = terminateHandler; -- cgit v1.2.3 From 18d0fd2e48ab093b953f26b67b769a2d8ab67040 Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 28 Nov 2020 15:13:06 +0200 Subject: Add multisampling to librw --- src/skel/glfw/glfw.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 2722a4df..617fee18 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -833,7 +833,10 @@ psSelectDevice() PSGLOBAL(fullScreen) = !FrontEndMenuManager.m_nPrefsWindowed; #endif - + +#ifdef MULTISAMPLING + RwD3D8EngineSetMultiSamplingLevels(1 << FrontEndMenuManager.m_nPrefsMSAALevel); +#endif return TRUE; } -- cgit v1.2.3 From a8035b64662e9b9fe6689ec60e5087ff95bc2672 Mon Sep 17 00:00:00 2001 From: aap Date: Sat, 28 Nov 2020 16:16:15 +0100 Subject: moved some stuff to MemoryMgr --- src/skel/glfw/glfw.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 2722a4df..0bde1282 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -40,7 +40,7 @@ #include "Sprite2d.h" #include "AnimViewer.h" #include "Font.h" -#include "MemoryHeap.h" +#include "MemoryMgr.h" #define MAX_SUBSYSTEMS (16) -- cgit v1.2.3 From b1a431a740c9bde92e9169c041909cebfa705ae5 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sat, 28 Nov 2020 17:57:10 +0100 Subject: add -console cmdline arg instead of #if 0/1 --- src/skel/glfw/glfw.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 617fee18..c4a3cad1 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1453,12 +1453,14 @@ WinMain(HINSTANCE instance, RwChar** argv; SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE); -#if 0 - // TODO: make this an option somewhere - AllocConsole(); - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); +#ifndef MASTER + if (strstr(cmdLine, "-console")) + { + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + } #endif #else -- cgit v1.2.3 From d5bc382cb51c5ef5af618377d190e6f34e893314 Mon Sep 17 00:00:00 2001 From: aap Date: Sun, 29 Nov 2020 12:26:34 +0100 Subject: GTA_VERSION define and some config.h cleanup --- src/skel/glfw/glfw.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 56877d37..cad84b8a 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -389,7 +389,7 @@ psInitialize(void) InitialiseLanguage(); -#ifndef GTA3_1_1_PATCH +#if GTA_VERSION < GTA3_PC_11 FrontEndMenuManager.LoadSettings(); #endif @@ -443,7 +443,7 @@ psInitialize(void) #ifndef PS2_MENU -#ifdef GTA3_1_1_PATCH +#if GTA_VERSION >= GTA3_PC_11 FrontEndMenuManager.LoadSettings(); #endif -- cgit v1.2.3 From b8d3d8f5e460db06d9475a39c0bfb8fc733be872 Mon Sep 17 00:00:00 2001 From: withmorten Date: Sat, 28 Nov 2020 17:57:10 +0100 Subject: add -console cmdline arg instead of #if 0/1 # Conflicts: # src/skel/glfw/glfw.cpp # src/skel/win/win.cpp --- src/skel/glfw/glfw.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index cac487b1..bc213c78 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1479,12 +1479,14 @@ WinMain(HINSTANCE instance, RwChar** argv; SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, nil, SPIF_SENDCHANGE); -#if 1 - // TODO: make this an option somewhere - AllocConsole(); - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); +#ifndef MASTER + if (strstr(cmdLine, "-console")) + { + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + } #endif #else -- cgit v1.2.3 From 16abbad6b224dd16867c4c54bbe45a6bc5a0461d Mon Sep 17 00:00:00 2001 From: Sergeanur Date: Sat, 28 Nov 2020 15:13:06 +0200 Subject: Add multisampling to librw # Conflicts: # src/core/config.h # vendor/librw --- src/skel/glfw/glfw.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index bc213c78..a20c1cc6 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -841,7 +841,10 @@ psSelectDevice() PSGLOBAL(fullScreen) = !FrontEndMenuManager.m_nPrefsWindowed; #endif - + +#ifdef MULTISAMPLING + RwD3D8EngineSetMultiSamplingLevels(1 << FrontEndMenuManager.m_nPrefsMSAALevel); +#endif return TRUE; } -- cgit v1.2.3 From ab3e810a95f60a97b2482f714608e88ac14f118b Mon Sep 17 00:00:00 2001 From: erorcun Date: Thu, 3 Dec 2020 05:22:58 +0300 Subject: AnimViewer done, comment cleanup --- src/skel/glfw/glfw.cpp | 67 +++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 39 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index a20c1cc6..c219e711 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1259,17 +1259,11 @@ void resizeCB(GLFWwindow* window, int width, int height) { * memory things don't work. */ /* redraw window */ -#ifndef MASTER - if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER)) - { - RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE); - } -#else + if (RwInitialised && gGameState == GS_PLAYING_GAME) { RsEventHandler(rsIDLE, (void *)TRUE); } -#endif if (RwInitialised && height > 0 && width > 0) { RwRect r; @@ -1644,18 +1638,6 @@ main(int argc, char *argv[]) FrontEndMenuManager.DrawMemoryCardStartUpMenus(); } #endif - - if (TurnOnAnimViewer) - { -#ifndef MASTER - CAnimViewer::Initialise(); -#ifndef PS2_MENU - FrontEndMenuManager.m_bGameNotLoaded = false; -#endif - gGameState = GS_ANIMVIEWER; - TurnOnAnimViewer = false; -#endif - } initkeymap(); @@ -1675,6 +1657,18 @@ main(int argc, char *argv[]) * Enter the message processing loop... */ +#ifndef MASTER + if (gbModelViewer) { + // This is TheModelViewer in LCS + LoadingScreen("Loading the ModelViewer", NULL, GetRandomSplashScreen()); + CAnimViewer::Initialise(); + CTimer::Update(); +#ifndef PS2_MENU + FrontEndMenuManager.m_bGameNotLoaded = false; +#endif + } +#endif + #ifdef PS2_MENU if (TheMemoryCard.m_bWantToLoad) LoadSplash(GetLevelSplashScreen(CGame::currLevel)); @@ -1689,7 +1683,13 @@ main(int argc, char *argv[]) #endif { glfwPollEvents(); - if( ForegroundApp ) +#ifndef MASTER + if (gbModelViewer) { + // This is TheModelViewerCore in LCS + TheModelViewer(); + } else +#endif + if ( ForegroundApp ) { switch ( gGameState ) { @@ -1893,18 +1893,6 @@ main(int argc, char *argv[]) } break; } -#ifndef MASTER - case GS_ANIMVIEWER: - { - float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); - if (RwInitialised) - { - if (!FrontEndMenuManager.m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms) - RsEventHandler(rsANIMVIEWER, (void*)TRUE); - } - break; - } -#endif } } else @@ -1976,12 +1964,13 @@ main(int argc, char *argv[]) } else { - if ( gGameState == GS_PLAYING_GAME ) - CGame::ShutDown(); #ifndef MASTER - else if ( gGameState == GS_ANIMVIEWER ) + if ( gbModelViewer ) CAnimViewer::Shutdown(); + else #endif + if ( gGameState == GS_PLAYING_GAME ) + CGame::ShutDown(); CTimer::Stop(); @@ -2002,13 +1991,13 @@ main(int argc, char *argv[]) #endif } - - if ( gGameState == GS_PLAYING_GAME ) - CGame::ShutDown(); #ifndef MASTER - else if ( gGameState == GS_ANIMVIEWER ) + if ( gbModelViewer ) CAnimViewer::Shutdown(); + else #endif + if ( gGameState == GS_PLAYING_GAME ) + CGame::ShutDown(); DMAudio.Terminate(); -- cgit v1.2.3 From 122c7aa40dda35107312fe91e0c61852c3056ddc Mon Sep 17 00:00:00 2001 From: erorcun Date: Wed, 9 Dec 2020 03:41:45 +0300 Subject: Use SDL gamepad mapping in environment by @ZLau92, implement @Sergeanur 's idea to use PPSSPP's DB if available, disable DEV() messages by default --- src/skel/glfw/glfw.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 7354c90a..3ebff16a 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -70,9 +70,6 @@ static psGlobalType PsGlobal; #define PSGLOBAL(var) (((psGlobalType *)(RsGlobal.ps))->var) -#undef MAKEPOINTS -#define MAKEPOINTS(l) (*((POINTS /*FAR*/ *)&(l))) - size_t _dwMemAvailPhys; RwUInt32 gGameState; @@ -870,6 +867,36 @@ void _InputInitialiseJoys() PSGLOBAL(joy1id) = -1; PSGLOBAL(joy2id) = -1; + // Load our gamepad mappings. +#define SDL_GAMEPAD_DB_PATH "gamecontrollerdb.txt" + FILE *f = fopen(SDL_GAMEPAD_DB_PATH, "rb"); + if (f) { + fseek(f, 0, SEEK_END); + size_t fsize = ftell(f); + fseek(f, 0, SEEK_SET); + + char *db = (char*)malloc(fsize + 1); + if (fread(db, 1, fsize, f) == fsize) { + db[fsize] = '\0'; + + if (glfwUpdateGamepadMappings(db) == GLFW_FALSE) + Error("glfwUpdateGamepadMappings didn't succeed, check " SDL_GAMEPAD_DB_PATH ".\n"); + } else + Error("fread on " SDL_GAMEPAD_DB_PATH " wasn't successful.\n"); + + free(db); + fclose(f); + } else + printf("You don't seem to have copied " SDL_GAMEPAD_DB_PATH " file from re3/gamefiles to GTA3 directory. Some gamepads may not be recognized.\n"); + +#undef SDL_GAMEPAD_DB_PATH + + // But always overwrite it with the one in SDL_GAMECONTROLLERCONFIG. + char const* EnvControlConfig = getenv("SDL_GAMECONTROLLERCONFIG"); + if (EnvControlConfig != nil) { + glfwUpdateGamepadMappings(EnvControlConfig); + } + for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) { if (glfwJoystickPresent(i) && !IsThisJoystickBlacklisted(i)) { if (PSGLOBAL(joy1id) == -1) -- cgit v1.2.3 From e1044a79478a3e25bfc44e699eb1f419275e9a0f Mon Sep 17 00:00:00 2001 From: erorcun Date: Wed, 9 Dec 2020 04:57:45 +0300 Subject: AnimViewer fixes, commentary from miami --- src/skel/glfw/glfw.cpp | 66 +++++++++++++++++++++----------------------------- 1 file changed, 28 insertions(+), 38 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index 3ebff16a..b7c4810e 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1257,17 +1257,11 @@ void resizeCB(GLFWwindow* window, int width, int height) { * memory things don't work. */ /* redraw window */ -#ifndef MASTER - if (RwInitialised && (gGameState == GS_PLAYING_GAME || gGameState == GS_ANIMVIEWER)) - { - RsEventHandler((gGameState == GS_PLAYING_GAME ? rsIDLE : rsANIMVIEWER), (void *)TRUE); - } -#else + if (RwInitialised && gGameState == GS_PLAYING_GAME) { RsEventHandler(rsIDLE, (void *)TRUE); } -#endif if (RwInitialised && height > 0 && width > 0) { RwRect r; @@ -1646,18 +1640,6 @@ main(int argc, char *argv[]) FrontEndMenuManager.DrawMemoryCardStartUpMenus(); } #endif - - if (TurnOnAnimViewer) - { -#ifndef MASTER - CAnimViewer::Initialise(); -#ifndef PS2_MENU - FrontEndMenuManager.m_bGameNotLoaded = false; -#endif - gGameState = GS_ANIMVIEWER; - TurnOnAnimViewer = false; -#endif - } initkeymap(); @@ -1677,6 +1659,18 @@ main(int argc, char *argv[]) * Enter the message processing loop... */ +#ifndef MASTER + if (gbModelViewer) { + // This is TheModelViewer in LCS, but not compiled on III Mobile. + LoadingScreen("Loading the ModelViewer", NULL, GetRandomSplashScreen()); + CAnimViewer::Initialise(); + CTimer::Update(); +#ifndef PS2_MENU + FrontEndMenuManager.m_bGameNotLoaded = false; +#endif + } +#endif + #ifdef PS2_MENU if (TheMemoryCard.m_bWantToLoad) LoadSplash(GetLevelSplashScreen(CGame::currLevel)); @@ -1691,7 +1685,13 @@ main(int argc, char *argv[]) #endif { glfwPollEvents(); - if( ForegroundApp ) +#ifndef MASTER + if (gbModelViewer) { + // This is TheModelViewerCore in LCS, but TheModelViewer on other state-machine III-VCs. + TheModelViewer(); + } else +#endif + if ( ForegroundApp ) { switch ( gGameState ) { @@ -1894,18 +1894,6 @@ main(int argc, char *argv[]) } break; } -#ifndef MASTER - case GS_ANIMVIEWER: - { - float ms = (float)CTimer::GetCurrentTimeInCycles() / (float)CTimer::GetCyclesPerMillisecond(); - if (RwInitialised) - { - if (!CMenuManager::m_PrefsFrameLimiter || (1000.0f / (float)RsGlobal.maxFPS) < ms) - RsEventHandler(rsANIMVIEWER, (void*)TRUE); - } - break; - } -#endif } } else @@ -1977,12 +1965,13 @@ main(int argc, char *argv[]) } else { - if ( gGameState == GS_PLAYING_GAME ) - CGame::ShutDown(); #ifndef MASTER - else if ( gGameState == GS_ANIMVIEWER ) + if ( gbModelViewer ) CAnimViewer::Shutdown(); + else #endif + if ( gGameState == GS_PLAYING_GAME ) + CGame::ShutDown(); CTimer::Stop(); @@ -2004,12 +1993,13 @@ main(int argc, char *argv[]) } - if ( gGameState == GS_PLAYING_GAME ) - CGame::ShutDown(); #ifndef MASTER - else if ( gGameState == GS_ANIMVIEWER ) + if ( gbModelViewer ) CAnimViewer::Shutdown(); + else #endif + if ( gGameState == GS_PLAYING_GAME ) + CGame::ShutDown(); DMAudio.Terminate(); -- cgit v1.2.3 From cf4aedd97cda528dd77bfce06eb3e46a7382ced1 Mon Sep 17 00:00:00 2001 From: erorcun Date: Wed, 9 Dec 2020 03:41:45 +0300 Subject: Use SDL gamepad mapping in environment by @ZLau92, implement @Sergeanur 's idea to use PPSSPP's DB if available, disable DEV() messages by default --- src/skel/glfw/glfw.cpp | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index c219e711..a73db217 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -70,9 +70,6 @@ static psGlobalType PsGlobal; #define PSGLOBAL(var) (((psGlobalType *)(RsGlobal.ps))->var) -#undef MAKEPOINTS -#define MAKEPOINTS(l) (*((POINTS /*FAR*/ *)&(l))) - size_t _dwMemAvailPhys; RwUInt32 gGameState; @@ -878,6 +875,36 @@ void _InputInitialiseJoys() PSGLOBAL(joy1id) = -1; PSGLOBAL(joy2id) = -1; + // Load our gamepad mappings. +#define SDL_GAMEPAD_DB_PATH "gamecontrollerdb.txt" + FILE *f = fopen(SDL_GAMEPAD_DB_PATH, "rb"); + if (f) { + fseek(f, 0, SEEK_END); + size_t fsize = ftell(f); + fseek(f, 0, SEEK_SET); + + char *db = (char*)malloc(fsize + 1); + if (fread(db, 1, fsize, f) == fsize) { + db[fsize] = '\0'; + + if (glfwUpdateGamepadMappings(db) == GLFW_FALSE) + Error("glfwUpdateGamepadMappings didn't succeed, check " SDL_GAMEPAD_DB_PATH ".\n"); + } else + Error("fread on " SDL_GAMEPAD_DB_PATH " wasn't successful.\n"); + + free(db); + fclose(f); + } else + printf("You don't seem to have copied " SDL_GAMEPAD_DB_PATH " file from re3/gamefiles to GTA3 directory. Some gamepads may not be recognized.\n"); + +#undef SDL_GAMEPAD_DB_PATH + + // But always overwrite it with the one in SDL_GAMECONTROLLERCONFIG. + char const* EnvControlConfig = getenv("SDL_GAMECONTROLLERCONFIG"); + if (EnvControlConfig != nil) { + glfwUpdateGamepadMappings(EnvControlConfig); + } + for (int i = 0; i <= GLFW_JOYSTICK_LAST; i++) { if (glfwJoystickPresent(i) && !IsThisJoystickBlacklisted(i)) { if (PSGLOBAL(joy1id) == -1) -- cgit v1.2.3 From 0f5893ed6046caa92460d73950bf782d2a200e97 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 14 Dec 2020 02:46:55 +0300 Subject: Fix language initialization call order --- src/skel/glfw/glfw.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index a73db217..418f93e4 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1231,15 +1231,15 @@ void InitialiseLanguage() } } - TheText.Unload(); - TheText.Load(); - #ifndef _WIN32 // TODO this is needed for strcasecmp to work correctly across all languages, but can these cause other problems?? setlocale(LC_CTYPE, "C"); setlocale(LC_COLLATE, "C"); setlocale(LC_NUMERIC, "C"); #endif + + TheText.Unload(); + TheText.Load(); } /* -- cgit v1.2.3 From 0448ae662fd777f7640a0f4486a731a6269e1997 Mon Sep 17 00:00:00 2001 From: erorcun Date: Mon, 14 Dec 2020 02:46:55 +0300 Subject: Fix language initialization call order --- src/skel/glfw/glfw.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/skel/glfw') diff --git a/src/skel/glfw/glfw.cpp b/src/skel/glfw/glfw.cpp index b7c4810e..93bfde5a 100644 --- a/src/skel/glfw/glfw.cpp +++ b/src/skel/glfw/glfw.cpp @@ -1202,15 +1202,15 @@ void InitialiseLanguage() } } - TheText.Unload(); - TheText.Load(); - #ifndef _WIN32 // TODO this is needed for strcasecmp to work correctly across all languages, but can these cause other problems?? setlocale(LC_CTYPE, "C"); setlocale(LC_COLLATE, "C"); setlocale(LC_NUMERIC, "C"); #endif + + TheText.Unload(); + TheText.Load(); } /* -- cgit v1.2.3