Free fork of NotProton: Windows Steam games in Mac Steam, on CodeWeavers' Wine and Apple's Game Porting Toolkit
Swift apple-silicond3dmetaldxmtdxvkgame-porting-toolkitgptkmac-gamingmacosmetalfxrosetta-2steamsteam-playwinewinecx
fix(winecx): Ravenswatch borderless size, Steam-owned controller permission, pad mappings
raymondchins8474b75790f2
diff --git a/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift b/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swiftindex e1f7eb0..faf657a 100644--- a/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift+++ b/app/Sources/NotProtonApp/Model/FreeEngineWinecx.swift@@ -96,7 +96,7 @@ enum FreeEngineWinecx {"d3d12.dll": "c6e285308bb3241efca3d94da4746b16a526a9fb5113f61922e7bd86694bebf9","dxgi.dll": "f1f24da777c65a583b29f74475c6a9464da35068d75def6cee806268def9ecbb",],- macDriver: "c611031855e596b2aeb2d2ea2c2ddef8cb843376d85ccf8bbe10c4fc727a527e",+ macDriver: "76d8f93839386f37e8badf0c82bb31b5ead22ac580f17896f9d2a729af0fc147",// winebus.so: winecx 5b45f45 built with SONAME_LIBSDL2 (docs/WINECX.md). libSDL2:// SDL 2.32.8 (zlib license, NOTICE), the WineHQ engine runner's copy signed ad hoc,// since a release build strips unsigned Mach-O resources and would break the pin.diff --git a/app/Sources/NotProtonApp/Resources/winemac-winecx-11.15.so b/app/Sources/NotProtonApp/Resources/winemac-winecx-11.15.soindex 190c946..c21290c 100755Binary files a/app/Sources/NotProtonApp/Resources/winemac-winecx-11.15.so and b/app/Sources/NotProtonApp/Resources/winemac-winecx-11.15.so differdiff --git a/docs/STATE.md b/docs/STATE.mdindex 3ebd767..c27af90 100644--- a/docs/STATE.md+++ b/docs/STATE.md@@ -6,11 +6,13 @@ Branch `integrate` = working fork state; nothing pushed except the `dxmt-e94c312- 14+ Windows-only games reach a full-screen window; Spider-Man 2 plays (77.9 fps, loads save). See compat/games.json.- Retina: D3DMetal back buffers sized in pixels (winemac patch, 233353d).- Xbox controllers: SDL-enabled winebus (9a0cbf5). Do NOT set winebus `Hidraw=1` for pads; it bypasses SDL.+- Controllers need no per-game Input Monitoring grant: the run script starts the launcher bundle directly instead of via `open`, so TCC attributes HID access to Steam (verified: all `kTCCServiceListenEvent` requests from Horizon `responsible=com.valvesoftware.steam`, authValue=2). `NOTPROTON_LAUNCH_SERVICES=1` restores the old `open` launch.+- Pads SDL doesn't know: `~/Library/Application Support/notproton/gamecontrollerdb.txt` is exported as `SDL_GAMECONTROLLERCONFIG`. GameSir G7 Pro dongle (3537:1022) mapping lives there; SDL IOKit axis order is X,Y,Z,Rz,Accel,Brake (browser Gamepad API numbers them differently). Never use the winebus registry `map` key: its loader (main.c:1101, writes `mappings[count]` after `count++`) crashes winebus and kills every pad.- Many games need `ROSETTA_ADVERTISE_AVX=1` (set in user gamefixes/default.conf and per-game Steam launch options).## Blockers / open- NotProton can't deploy to Steam: App Management permission is lost on every ad-hoc rebuild (`run failed: cannot write /Applications/Steam.app/Contents/MacOS`). User must re-allow NotProton in Privacy & Security > App Management. Long-term: sign builds with a stable identity.-- Ravenswatch: black band at top + bottom cropped; game sizes buffers from 1512x876 pt (982 − notch/menu bar). WIP on branch `wip/retina-notch` (unverified). Live runner has the verified winemac (c6110318…).+- Ravenswatch: fixed by winemac 76d8f938… (CW HACK 22435 in winecx-d3dmetal-retina.patch: queue D3DMetal client view frames before WM_SIZE so ResizeBuffers sees the borderless size; 3024x1964 confirmed by user via Metal HUD 2026-10-10).- Borderlands 4: hangs before first frame (exception storm, likely Denuvo under Rosetta). Not solved.- The Last of Us Part I: not crashing; probably long first shader build. Skipped by user.- DOOM: The Dark Ages / Indiana Jones need hardware ray tracing (MoltenVK has none); Half-Life: Alyx is VR.diff --git a/docs/WINECX.md b/docs/WINECX.mdindex b14b275..e0c5229 100644--- a/docs/WINECX.md+++ b/docs/WINECX.md@@ -79,7 +79,9 @@ between 0.80 and master.The engine's `winemac.so` is still replaced, for D3DMetal: winecx's own let D3DMetal size aswapchain from its view's frame in points, so with High Resolution (Retina) on, a game got a-half-size drawable and showed only the top-left quarter. NotProton installs+half-size drawable and showed only the top-left quarter, and a `ResizeBuffers` from+`WM_SIZE` read the view's frame before it had followed the window, so the swapchain kept+its old size (Ravenswatch: 3024x1752 stretched over a 3024x1964 screen). NotProton installs`winemac-winecx-11.15.so`, built from winecx `5b45f45` with`winemac-patch/winecx-d3dmetal-retina.patch` (`winemac-patch/README.md`), pinned as`FreeEngineWinecx.current.macDriver`.diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex 8ac24a1..86e26ba 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -146,6 +146,24 @@ case "$app_id" in ''|0) app_id=$(basename "$STEAM_COMPAT_DATA_PATH" 2>/dev/null)case "$app_id" in ''|*[!0-9]*) app_id=0 ;; esacecho "app_id=$app_id (STEAM_COMPAT_APP_ID=$STEAM_COMPAT_APP_ID)" >> "$log" 2>&1 || true+# SDL has no built-in mapping for some pads (GameSir G7 Pro dongle, 3537:1022), so+# winebus hands games their raw button order. Mappings in gamecontrollerdb.txt reach+# winebus through the environment; its registry "map" loader crashes in this Wine.+pad_db="$HOME/Library/Application Support/notproton/gamecontrollerdb.txt"+if [ -f "$pad_db" ]; then+ pad_maps=$(sed -e '/^[[:space:]]*#/d' -e '/^[[:space:]]*$/d' "$pad_db")+ if [ -n "$pad_maps" ]; then+ if [ -n "$SDL_GAMECONTROLLERCONFIG" ]; then+ SDL_GAMECONTROLLERCONFIG="$SDL_GAMECONTROLLERCONFIG+$pad_maps"+ else+ SDL_GAMECONTROLLERCONFIG="$pad_maps"+ fi+ export SDL_GAMECONTROLLERCONFIG+ echo "controllers: $(printf '%s\n' "$pad_maps" | wc -l | tr -d ' ') mapping(s) from $pad_db" >> "$log" 2>&1 || true+ fi+fi+# Per-game fixes: the shipped gamefixes-default/<appid>.conf, then the user's# gamefixes/<appid>.conf, the later file winning per key. KEY=VALUE lines are checked# against an allow-list and never sourced, and the launch options win over both files.@@ -1929,7 +1947,7 @@ elseecho "=== client staged no overlay renderer, overlay disabled ===" >> "$log" 2>&1 || truefiset -- --args "$shim_exe" "$@"-for name in $(env | sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|WINE_LARGE_ADDRESS_AWARE|WINE_CPU_TOPOLOGY|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|MVK_|VKD3D_|STAGING_|MTL_|ROSETTA_)[A-Z0-9_]*)=.*/\1/p'); do+for name in $(env | sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|SDL_GAMECONTROLLERCONFIG|WINE_LARGE_ADDRESS_AWARE|WINE_CPU_TOPOLOGY|Steam[A-Za-z0-9]*|(CX_GRAPHICS|D3DM_|DXMT_|DXVK_|MVK_|VKD3D_|STAGING_|MTL_|ROSETTA_)[A-Z0-9_]*)=.*/\1/p'); doeval "value=\$$name"# shellcheck disable=SC2154 # eval assigns value on the line aboveset -- --env "$name=$value" "$@"@@ -1953,7 +1971,38 @@ set -- \lsregister="/System/Library/Frameworks/CoreServices.framework/Versions/A"lsregister="$lsregister/Frameworks/LaunchServices.framework/Support/lsregister"[ -x "$lsregister" ] && "$lsregister" -f "$loader_app" >> "$log" 2>&1 || true-open -n -W -a "$loader_app" "$@" >> "$log" 2>&1 &+if [ "${NOTPROTON_LAUNCH_SERVICES:-0}" = "1" ]; then+ open -n -W -a "$loader_app" "$@" >> "$log" 2>&1 &+else+ # A bundle started by `open` is its own TCC responsible process, so every game+ # needed a separate Input Monitoring grant before controllers worked. Started+ # from here it stays attributed to Steam, which already holds that grant, and+ # macOS still takes the Dock name and icon from the enclosing bundle. env -i+ # with the same --env list keeps the environment `open` would have given it.+ count=$#+ i=0+ mode=vars+ while [ "$i" -lt "$count" ]; do+ arg=$1+ shift+ i=$((i + 1))+ case "$mode:$arg" in+ vars:--env)+ set -- "$@" "$1"+ shift+ i=$((i + 1))+ ;;+ vars:--args)+ mode=args+ set -- "$@" "$loader_macos/launcher"+ ;;+ args:*) set -- "$@" "$arg" ;;+ esac+ done+ echo "launching bundle directly so input permission stays with Steam" >> "$log" 2>&1 || true+ env -i HOME="$HOME" USER="$USER" LOGNAME="$LOGNAME" SHELL="$SHELL" TMPDIR="$TMPDIR" \+ __CF_USER_TEXT_ENCODING="$__CF_USER_TEXT_ENCODING" "$@" >> "$log" 2>&1 &+fiopen_pid=$!status=0seen=0diff --git a/scripts/steam-launch-options.py b/scripts/steam-launch-options.pynew file mode 100644index 0000000..325bda8--- /dev/null+++ b/scripts/steam-launch-options.py@@ -0,0 +1,47 @@+#!/usr/bin/env python3+"""Prepend a token to the Steam launch options of the given app IDs.++usage: steam-launch-options.py <localconfig.vdf> <TOKEN> <appid...>++Edits userdata/<id>/config/localconfig.vdf in place. Run it only while Steam+is fully closed (Steam rewrites the file on exit). A token already present is+left alone; an app with no launch options gets "<TOKEN> %command%".+"""+import re+import sys++path, token = sys.argv[1], sys.argv[2]+ids = set(sys.argv[3:])+lines = open(path, encoding="utf-8").read().split("\n")+out, done, in_apps, i = [], set(), False, 0+while i < len(lines):+ line = lines[i]+ out.append(line)+ if line == '\t\t\t\t"apps"':+ in_apps = True+ m = re.fullmatch(r'\t{5}"(\d+)"', line)+ if in_apps and m and m.group(1) in ids and i + 1 < len(lines) and lines[i + 1] == "\t\t\t\t\t{":+ out.append(lines[i + 1])+ i += 2+ block = []+ while i < len(lines) and lines[i] != "\t\t\t\t\t}":+ block.append(lines[i])+ i += 1+ found = False+ for k, b in enumerate(block):+ mm = re.fullmatch(r'(\t{6}"LaunchOptions"\t\t")(.*)(")', b)+ if mm:+ found = True+ val = mm.group(2)+ if token not in val.split():+ rest = val if "%command%" in val else (val + " %command%").strip()+ val = f"{token} {rest}"+ block[k] = mm.group(1) + val + mm.group(3)+ if not found:+ block.append(f'\t\t\t\t\t\t"LaunchOptions"\t\t"{token} %command%"')+ out.extend(block)+ done.add(m.group(1))+ continue+ i += 1+open(path, "w", encoding="utf-8").write("\n".join(out))+print("updated", sorted(done), "missing", sorted(ids - done))diff --git a/winemac-patch/README.md b/winemac-patch/README.mdindex bec3179..6dced40 100644--- a/winemac-patch/README.md+++ b/winemac-patch/README.md@@ -28,6 +28,17 @@ pixels, which are backing pixels in Retina mode, so a 1512x876-point window gothands D3DMetal a proxy view whose `-frame` is in Win32 pixels (`cgrect_win_from_mac`) andforwards everything else; DXMT never asks for `frame`.+D3DMetal reads that frame again for `ResizeBuffers`, which games call from `WM_SIZE`. Its+client surfaces (`data->d3dmetal_client_surfaces`, CW HACK 22435) are not on win32u's list,+so `update_client_surfaces()` skipped them and their view only followed the window on the+next present: D3DMetal read the old frame and kept the old size. Ravenswatch creates its+swapchain while its window is maximized (client 3024x1752: the work area under the menu bar+and above the Dock, minus the caption), then goes borderless 3024x1964 and resizes from+`WM_SIZE`; the drawable stayed 3024x1752 and the image was stretched. The patch has+`macdrv_WindowPosChanged()` queue those surfaces' view frames before `WM_SIZE` is sent, and+the proxy reads `-frame` on the main thread behind them. With it the drawable follows to+3024x1964.+To rebuild `app/Sources/NotProtonApp/Resources/winemac-winecx-11.15.so` from winecx`5b45f45` (runtime 4.5.125), natively, with the CI's flags:diff --git a/winemac-patch/winecx-d3dmetal-retina.patch b/winemac-patch/winecx-d3dmetal-retina.patchindex 3065590..5e51e6d 100644--- a/winemac-patch/winecx-d3dmetal-retina.patch+++ b/winemac-patch/winecx-d3dmetal-retina.patch@@ -36,10 +36,10 @@ index b5a03f6..a45aed5 100644static void my_OnMainThread(dispatch_block_t b)diff --git a/dlls/winemac.drv/d3dmetal_objc.m b/dlls/winemac.drv/d3dmetal_objc.m-index 9b4a054..a470b79 100644+index 9b4a054..37b04df 100644--- a/dlls/winemac.drv/d3dmetal_objc.m+++ b/dlls/winemac.drv/d3dmetal_objc.m-@@ -72,4 +72,95 @@ @implementation WineMetalLayer+@@ -72,4 +72,104 @@ @implementation WineMetalLayer@end@@ -80,9 +80,18 @@ index 9b4a054..a470b79 100644+ return view;+ }+++ /* Read on the main thread, behind the frame updates macdrv has already queued++ * there: ResizeBuffers runs in the game's WM_SIZE handler, right after++ * macdrv_WindowPosChanged() queued the view's new frame. */+ - (NSRect) frame+ {-+ return cgrect_win_from_mac([view frame]);++ __block NSRect frame;++++ if ([NSThread isMainThread])++ frame = [view frame];++ else++ OnMainThread(^{ frame = [view frame]; });++ return cgrect_win_from_mac(frame);+ }++ - (id) forwardingTargetForSelector:(SEL)selector@@ -149,3 +158,43 @@ index c6552ba..2551ab1 100644extern macdrv_metal_swapchain macdrv_create_view_swapchain(macdrv_view v);extern macdrv_metal_swapchain macdrv_create_offscreen_swapchain(void* hwnd, void* client_hwnd, CGRect container, CGRect frame);extern void macdrv_swapchain_set_frame(macdrv_metal_swapchain swapchain, CGRect container, CGRect frame);+diff --git a/dlls/winemac.drv/window.c b/dlls/winemac.drv/window.c+index abddfe4..97cdfd4 100644+--- a/dlls/winemac.drv/window.c++++ b/dlls/winemac.drv/window.c+@@ -1872,7 +1872,34 @@ void macdrv_WindowPosChanged(HWND hwnd, HWND insert_after, HWND owner_hint, UINT+ }++ done:+- release_win_data(data);++ /* CW HACK 22435: D3DMetal's client surfaces are not on win32u's list, so++ * update_client_surfaces() skips them and their views only caught up with the++ * window on the next present. A game that answers WM_SIZE with ResizeBuffers++ * then had D3DMetal read the old view frame and keep the old backbuffer size++ * (Ravenswatch: maximized 3024x1752 kept after going 3024x1964 borderless).++ * Queue their view frames now, before WM_SIZE; win32u locks the surfaces before++ * the window data, so the update runs after release_win_data(). */++ {++ CFIndex i, count = data->d3dmetal_client_surfaces ? CFArrayGetCount(data->d3dmetal_client_surfaces) : 0;++ struct client_surface **surfaces = count ? malloc(count * sizeof(*surfaces)) : NULL;++++ if (!surfaces) count = 0;++ for (i = 0; i < count; i++)++ {++ struct macdrv_client_surface *surface =++ (struct macdrv_client_surface *)CFArrayGetValueAtIndex(data->d3dmetal_client_surfaces, i);++ surfaces[i] = &surface->client;++ client_surface_add_ref(surfaces[i]);++ }++ release_win_data(data);++++ for (i = 0; i < count; i++)++ {++ client_surface_update(surfaces[i]);++ client_surface_release(surfaces[i]);++ }++ free(surfaces);++ }+ }++