feat: Fullscreen, fix sending input when window not focused, fix iggy lib not being copied & request dedicated GPU

This commit is contained in:
str1k3r committed 2026-08-14 19:44:30 -04:00
1 parent 14cd85e7ed
commit 9d19fdc5f5
3 files changed
+111 -32

No files matched your search

@@ -47,7 +47,7 @@ foreach ($copy in $folderCopies) {
$fileCopies = @( $fileCopies = @(
@{ Source = Join-Path $ProjectDir "Windows64\4JLibs\4J_Input\Windows64\vendor\SDL\lib\x64\SDL3.dll"; Dest = "SDL3.dll" }, @{ 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 = 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) { foreach ($copy in $fileCopies) {
@@ -4,6 +4,7 @@
#include "stdafx.h" #include "stdafx.h"
#include <assert.h> #include <assert.h>
#include <shellapi.h>
#include "GameConfig\Minecraft.spa.h" #include "GameConfig\Minecraft.spa.h"
#include "..\MinecraftServer.h" #include "..\MinecraftServer.h"
#include "..\LocalPlayer.h" #include "..\LocalPlayer.h"
@@ -24,10 +25,6 @@
#include "..\..\Minecraft.World\ThreadName.h" #include "..\..\Minecraft.World\ThreadName.h"
#include "..\..\Minecraft.Client\StatsCounter.h" #include "..\..\Minecraft.Client\StatsCounter.h"
#include "..\ConnectScreen.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\Tesselator.h"
#include "..\..\Minecraft.Client\Options.h" #include "..\..\Minecraft.Client\Options.h"
#include "Sentient\SentientManager.h" #include "Sentient\SentientManager.h"
@@ -42,12 +39,11 @@
HINSTANCE hMyInst; HINSTANCE hMyInst;
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam); LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam);
WINDOWPLACEMENT g_wpPrev = { sizeof(g_wpPrev) };
char chGlobalText[256]; char chGlobalText[256];
uint16_t ui16GlobalText[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 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 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) //#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 #define NUM_PROFILE_SETTINGS 4
DWORD dwProfileSettingsA[NUM_PROFILE_VALUES]= 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 0,0,0,0,0
#endif
}; };
//------------------------------------------------------------------------------------- //str1k3r - request dedicated GPU from AMD and NVIDIA drivers
// Time Since fAppTime is a float, we need to keep the quadword app time extern "C"
// as a LARGE_INTEGER so that we don't lose precision after running {
// for a long time. __declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
//------------------------------------------------------------------------------------- __declspec(dllexport) unsigned long NvOptimusEnablement = 0x00000001;
}
BOOL g_isFullscreen = FALSE;
BOOL g_bWidescreen = TRUE; BOOL g_bWidescreen = TRUE;
BOOL g_bResolutionSetByCMD = FALSE; BOOL g_bResolutionSetByCMD = FALSE;
int g_iScreenWidth = 1920; int g_iScreenWidth = 1920;
int g_iScreenHeight = 1080; 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) void DefineActions(void)
{ {
// The app needs to define the actions required, and the possible mappings for these // 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 ); 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 // Clean up the objects we've created
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@@ -637,8 +688,6 @@ void CleanupDevice()
if( g_pd3dDevice ) g_pd3dDevice->Release(); if( g_pd3dDevice ) g_pd3dDevice->Release();
} }
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance, _In_opt_ HINSTANCE hPrevInstance,
_In_ LPTSTR lpCmdLine, _In_ LPTSTR lpCmdLine,
@@ -647,44 +696,46 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine); UNREFERENCED_PARAMETER(lpCmdLine);
if(lpCmdLine) Windows64LaunchArgs launchArgs = ParseLaunchArgs();
if(launchArgs.resolution != 0)
{ {
if(lpCmdLine[0] == '1') if(launchArgs.resolution == 1)
{ {
// 2160p // 2160p
g_iScreenWidth = 3840; g_iScreenWidth = 3840;
g_iScreenHeight = 2160; g_iScreenHeight = 2160;
g_bResolutionSetByCMD = TRUE; g_bResolutionSetByCMD = TRUE;
} }
else if(lpCmdLine[0] == '2') else if(launchArgs.resolution == 2)
{ {
// 1440p // 1440p
g_iScreenWidth = 2560; g_iScreenWidth = 2560;
g_iScreenHeight = 1440; g_iScreenHeight = 1440;
g_bResolutionSetByCMD = TRUE; g_bResolutionSetByCMD = TRUE;
} }
else if (lpCmdLine[0] == '3') else if (launchArgs.resolution == 3)
{ {
// 1080p // 1080p
g_iScreenWidth = 1920; g_iScreenWidth = 1920;
g_iScreenHeight = 1080; g_iScreenHeight = 1080;
g_bResolutionSetByCMD = TRUE; g_bResolutionSetByCMD = TRUE;
} }
else if(lpCmdLine[0] == '4') else if(launchArgs.resolution == 4)
{ {
// 720p // 720p
g_iScreenWidth = 1280; g_iScreenWidth = 1280;
g_iScreenHeight = 720; g_iScreenHeight = 720;
g_bResolutionSetByCMD = TRUE; g_bResolutionSetByCMD = TRUE;
} }
else if(lpCmdLine[0] == '5') else if(launchArgs.resolution == 5)
{ {
// 480p // 480p
g_iScreenWidth = 640; g_iScreenWidth = 640;
g_iScreenHeight = 480; g_iScreenHeight = 480;
g_bResolutionSetByCMD = TRUE; g_bResolutionSetByCMD = TRUE;
} }
else if(lpCmdLine[0] == '6') else if(launchArgs.resolution == 6)
{ {
// Vita Native, 544p // Vita Native, 544p
g_iScreenWidth = 960; g_iScreenWidth = 960;
@@ -693,7 +744,6 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
} }
} }
// Initialize global strings // Initialize global strings
MyRegisterClass(hInstance); MyRegisterClass(hInstance);
@@ -711,6 +761,11 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
return 0; return 0;
} }
if(launchArgs.fullscreen)
{
ToggleFullscreen();
}
#if 0 #if 0
// Main message loop // Main message loop
MSG msg = {0}; MSG msg = {0};
@@ -1001,7 +1056,10 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
app.UpdateTime(); app.UpdateTime();
PIXBeginNamedEvent(0,"Input manager tick"); PIXBeginNamedEvent(0,"Input manager tick");
InputManager.Tick(); if (GetFocus())
{
InputManager.Tick();
}
PIXEndNamedEvent(); PIXEndNamedEvent();
PIXBeginNamedEvent(0,"Profile manager tick"); PIXBeginNamedEvent(0,"Profile manager tick");
// ProfileManager.Tick(); // ProfileManager.Tick();
@@ -1192,6 +1250,18 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
#if 0 #if 0
PIXEndNamedEvent(); PIXEndNamedEvent();
#endif #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 // 4J-PB - Update the trial timer display if we are in the trial version
if(!ProfileManager.IsFullVersion()) if(!ProfileManager.IsFullVersion())
@@ -2,6 +2,9 @@
#include <d3d11.h> #include <d3d11.h>
static bool isF11Pressed = false;
static bool wasF11Pressed = false;
extern BOOL g_bWidescreen; extern BOOL g_bWidescreen;
extern int g_iScreenWidth; extern int g_iScreenWidth;
@@ -12,3 +15,9 @@ extern BOOL g_bResolutionSetByCMD;
extern ID3D11Device* g_pd3dDevice; extern ID3D11Device* g_pd3dDevice;
void CleanupDevice(); void CleanupDevice();
struct Windows64LaunchArgs
{
bool fullscreen;
int resolution;
};