From 9d19fdc5f56895e7a742b5b2f7c4431dda1cef71 Mon Sep 17 00:00:00 2001 From: str1k3r <115313679+S1l3ntStr1ke87@users.noreply.github.com> Date: Fri, 14 Aug 2026 19:44:30 -0400 Subject: [PATCH] feat: Fullscreen, fix sending input when window not focused, fix iggy lib not being copied & request dedicated GPU --- .../Common/Buildsteps/Windows64-postbuild.ps1 | 2 +- .../Windows64/Windows64_Minecraft.cpp | 132 ++++++++++++++---- .../Windows64/Windows64_Minecraft.h | 11 +- 3 files changed, 112 insertions(+), 33 deletions(-) diff --git a/Minecraft.Client/Common/Buildsteps/Windows64-postbuild.ps1 b/Minecraft.Client/Common/Buildsteps/Windows64-postbuild.ps1 index d512ad32..3a744a40 100644 --- a/Minecraft.Client/Common/Buildsteps/Windows64-postbuild.ps1 +++ b/Minecraft.Client/Common/Buildsteps/Windows64-postbuild.ps1 @@ -47,7 +47,7 @@ foreach ($copy in $folderCopies) { $fileCopies = @( @{ Source = Join-Path $ProjectDir "Windows64\4JLibs\4J_Input\Windows64\vendor\SDL\lib\x64\SDL3.dll"; Dest = "SDL3.dll" }, @{ Source = Join-Path $PSScriptRoot "Contents\Windows64\mss64.dll"; Dest = "mss64.dll" }, - @{ Source = "Windows64\redist64\iggy_w64.dll"; Dest = "iggy_w64.dll" } + @{ Source = "Windows64\Iggy\lib\redist64\iggy_w64.dll"; Dest = "iggy_w64.dll" } ) foreach ($copy in $fileCopies) { diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index e952391b..861b22ad 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -4,6 +4,7 @@ #include "stdafx.h" #include +#include #include "GameConfig\Minecraft.spa.h" #include "..\MinecraftServer.h" #include "..\LocalPlayer.h" @@ -24,10 +25,6 @@ #include "..\..\Minecraft.World\ThreadName.h" #include "..\..\Minecraft.Client\StatsCounter.h" #include "..\ConnectScreen.h" -//#include "Social\SocialManager.h" -//#include "Leaderboards\LeaderboardManager.h" -//#include "XUI\XUI_Scene_Container.h" -//#include "NetworkManager.h" #include "..\..\Minecraft.Client\Tesselator.h" #include "..\..\Minecraft.Client\Options.h" #include "Sentient\SentientManager.h" @@ -42,12 +39,11 @@ HINSTANCE hMyInst; LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam); +WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) }; + char chGlobalText[256]; uint16_t ui16GlobalText[256]; -#define THEME_NAME "584111F70AAAAAAA" -#define THEME_FILESIZE 2797568 - //#define THREE_MB 3145728 // minimum save size (checking for this on a selected device) //#define FIVE_MB 5242880 // minimum save size (checking for this on a selected device) //#define FIFTY_TWO_MB (1024*1024*52) // Maximum TCR space required for a save (checking for this on a selected device) @@ -58,29 +54,51 @@ uint16_t ui16GlobalText[256]; #define NUM_PROFILE_SETTINGS 4 DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= { -#ifdef _XBOX - XPROFILE_OPTION_CONTROLLER_VIBRATION, - XPROFILE_GAMER_YAXIS_INVERSION, - XPROFILE_GAMER_CONTROL_SENSITIVITY, - XPROFILE_GAMER_ACTION_MOVEMENT_CONTROL, - XPROFILE_TITLE_SPECIFIC1, -#else 0,0,0,0,0 -#endif }; -//------------------------------------------------------------------------------------- -// Time Since fAppTime is a float, we need to keep the quadword app time -// as a LARGE_INTEGER so that we don't lose precision after running -// for a long time. -//------------------------------------------------------------------------------------- +//str1k3r - request dedicated GPU from AMD and NVIDIA drivers +extern "C" +{ + __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1; + __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001; +} +BOOL g_isFullscreen = FALSE; BOOL g_bWidescreen = TRUE; BOOL g_bResolutionSetByCMD = FALSE; int g_iScreenWidth = 1920; int g_iScreenHeight = 1080; +static Windows64LaunchArgs ParseLaunchArgs() +{ + Windows64LaunchArgs args = {}; + args.resolution = 0; + + int argc = 0; + LPWSTR* argv = CommandLineToArgvW(GetCommandLineW(), &argc); + if (argv == nullptr) + return args; + + if (argc > 1 && lstrlenW(argv[1]) == 1) + { + if (argv[1][0] >= L'1' && argv[1][0] <= L'6') + args.resolution = argv[1][0] - L'0'; + } + + for (int i = 1; i < argc; ++i) + { + if (_wcsicmp(argv[i], L"-fullscreen") == 0) + { + args.fullscreen = true; + } + } + + LocalFree(argv); + return args; +} + void DefineActions(void) { // The app needs to define the actions required, and the possible mappings for these @@ -624,6 +642,39 @@ void Render() g_pSwapChain->Present( 0, 0 ); } +//-------------------------------------------------------------------------------------- +// Toggle borderless fullscreen +// Credits to the smartCMD repo for this +// This is the proper way to do this therefore we just took it +//-------------------------------------------------------------------------------------- +void ToggleFullscreen() +{ + const DWORD dwStyle = GetWindowLong(g_hWnd, GWL_STYLE); + if (!g_isFullscreen) + { + MONITORINFO mi = { sizeof(mi) }; + if (GetWindowPlacement(g_hWnd, &g_wpPrev) && + GetMonitorInfo(MonitorFromWindow(g_hWnd, MONITOR_DEFAULTTOPRIMARY), &mi)) + { + SetWindowLong(g_hWnd, GWL_STYLE, dwStyle & ~WS_OVERLAPPEDWINDOW); + SetWindowPos(g_hWnd, HWND_TOP, + mi.rcMonitor.left, mi.rcMonitor.top, + mi.rcMonitor.right - mi.rcMonitor.left, + mi.rcMonitor.bottom - mi.rcMonitor.top, + SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + } + } + else + { + SetWindowLong(g_hWnd, GWL_STYLE, dwStyle | WS_OVERLAPPEDWINDOW); + SetWindowPlacement(g_hWnd, &g_wpPrev); + SetWindowPos(g_hWnd, nullptr, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_FRAMECHANGED); + } + g_isFullscreen = !g_isFullscreen; +} + + //-------------------------------------------------------------------------------------- // Clean up the objects we've created //-------------------------------------------------------------------------------------- @@ -637,8 +688,6 @@ void CleanupDevice() if( g_pd3dDevice ) g_pd3dDevice->Release(); } - - int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, @@ -647,44 +696,46 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); - if(lpCmdLine) + Windows64LaunchArgs launchArgs = ParseLaunchArgs(); + + if(launchArgs.resolution != 0) { - if(lpCmdLine[0] == '1') + if(launchArgs.resolution == 1) { // 2160p g_iScreenWidth = 3840; g_iScreenHeight = 2160; g_bResolutionSetByCMD = TRUE; } - else if(lpCmdLine[0] == '2') + else if(launchArgs.resolution == 2) { // 1440p g_iScreenWidth = 2560; g_iScreenHeight = 1440; g_bResolutionSetByCMD = TRUE; } - else if (lpCmdLine[0] == '3') + else if (launchArgs.resolution == 3) { // 1080p g_iScreenWidth = 1920; g_iScreenHeight = 1080; g_bResolutionSetByCMD = TRUE; } - else if(lpCmdLine[0] == '4') + else if(launchArgs.resolution == 4) { // 720p g_iScreenWidth = 1280; g_iScreenHeight = 720; g_bResolutionSetByCMD = TRUE; } - else if(lpCmdLine[0] == '5') + else if(launchArgs.resolution == 5) { // 480p g_iScreenWidth = 640; g_iScreenHeight = 480; g_bResolutionSetByCMD = TRUE; } - else if(lpCmdLine[0] == '6') + else if(launchArgs.resolution == 6) { // Vita Native, 544p g_iScreenWidth = 960; @@ -693,7 +744,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, } } - // Initialize global strings MyRegisterClass(hInstance); @@ -711,6 +761,11 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, return 0; } + if(launchArgs.fullscreen) + { + ToggleFullscreen(); + } + #if 0 // Main message loop MSG msg = {0}; @@ -1001,7 +1056,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, app.UpdateTime(); PIXBeginNamedEvent(0,"Input manager tick"); - InputManager.Tick(); + if (GetFocus()) + { + InputManager.Tick(); + } PIXEndNamedEvent(); PIXBeginNamedEvent(0,"Profile manager tick"); // ProfileManager.Tick(); @@ -1192,6 +1250,18 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, #if 0 PIXEndNamedEvent(); #endif + isF11Pressed = (GetAsyncKeyState(VK_F11) & 0x8000) != 0; + + if(isF11Pressed && !wasF11Pressed && GetFocus()) + { + ToggleFullscreen(); + } + else if(isF11Pressed && !wasF11Pressed && GetFocus()) + { + ToggleFullscreen(); + } + + wasF11Pressed = isF11Pressed; // 4J-PB - Update the trial timer display if we are in the trial version if(!ProfileManager.IsFullVersion()) diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.h b/Minecraft.Client/Windows64/Windows64_Minecraft.h index 673d8261..ef912fbb 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.h +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.h @@ -2,6 +2,9 @@ #include +static bool isF11Pressed = false; +static bool wasF11Pressed = false; + extern BOOL g_bWidescreen; extern int g_iScreenWidth; @@ -11,4 +14,10 @@ extern BOOL g_bResolutionSetByCMD; extern ID3D11Device* g_pd3dDevice; -void CleanupDevice(); \ No newline at end of file +void CleanupDevice(); + +struct Windows64LaunchArgs +{ + bool fullscreen; + int resolution; +}; \ No newline at end of file