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
feat(panel): frame generation controls and a panel for native macOS games
raymondchins6489be18697a
diff --git a/docs/GAMEFIXES.md b/docs/GAMEFIXES.mdindex 8b3bef1..fe62031 100644--- a/docs/GAMEFIXES.md+++ b/docs/GAMEFIXES.md@@ -26,7 +26,11 @@ logged, when:| `DLLOVERRIDES` | Wine syntax, e.g. `dinput8=n,b;xinput1_3=n` | Added to `WINEDLLOVERRIDES` after the backend's entries and before the launch options' || `MSYNC` | `0`, `1` | `1` turns msync on when the engine supports it; `0` turns it off || `RETINA` | `0`, `1` | Same as `NOTPROTON_RETINA` (High Resolution) |-| `FRAMEGEN` | `0`, `1` | Same as `NOTPROTON_FRAMEGEN=1`: experimental MetalFX frame interpolation (2x) in overlay-shim, adds up to half a frame of latency |+| `FRAMEGEN` | `0`, `1`, `2`, `3`, `adaptive` | Same as `NOTPROTON_FRAMEGEN`: experimental frame generation in overlay-shim, adds up to half a frame of latency. `2` and `3` multiply the frame rate, `adaptive` fills up to the display refresh, `1` is the same as `2`, `0` is off (the default) |+| `FRAMEGEN_QUALITY` | `performance`, `balanced`, `quality` | Same as `NOTPROTON_FRAMEGEN_QUALITY`. `balanced` when unset |+| `FRAMEGEN_UI` | `0`, `1` | Same as `NOTPROTON_FRAMEGEN_UI`, Protect UI: keeps static HUD and menus sharp. On when unset |+| `FRAMEGEN_FALLBACK` | `0`, `1` | Same as `NOTPROTON_FRAMEGEN_FALLBACK`, Fast-motion fallback: skips generated frames that would smear. On when unset |+| `FRAMEGEN_ENGINE` | `own`, `metalfx` | Same as `NOTPROTON_FRAMEGEN_ENGINE`: the built-in optical flow (`own`, the default) or MetalFX frame interpolation || `NVAPI` | `0`, `1` | `1` turns on Apple's `nvapi64` on an engine with a linked Game Porting Toolkit, for `d3dmetal` only. Off by default, since an nvapi that answers sends some games down NVIDIA-only paths || `DXMT_*`, `DXVK_*`, `MVK_*`, `VKD3D_*`, `D3DM_*`, `STAGING_*` | any | Exported as is || `MTL_HUD_ENABLED`, `WINEDEBUG`, `WINE_LARGE_ADDRESS_AWARE`, `WINE_CPU_TOPOLOGY` | any | Exported as is |@@ -130,3 +134,18 @@ DXMT_METALFX_SPATIAL_SWAPCHAIN=1MSYNC=0RETINA=1```++## Native macOS games++A Mac build with no compatibility tool pinned runs through `~/.notproton/np-native`, not the+`run` script, so the files above do not apply to it. np-native reads its own two files,+with variable names as they are (`NOTPROTON_FRAMEGEN=2`, `NP_PAD_MODE=hid`, `MTL_HUD_ENABLED=1`):++1. `~/Library/Application Support/notproton/gamefixes/native-default.conf`, for every native game+2. `~/Library/Application Support/notproton/gamefixes/native/<appid>.conf`, which wins per key++The Steam panel for such a game shows the Metal HUD, Frame Generation and the controller+layer (`NP_PAD_MODE`: `hid`, `gc` or `off`). It writes the launch options as+`<home>/.notproton/np-native VAR=VALUE ... %command% <game args>`, and rewrites the older+`/usr/bin/arch -arm64 -x86_64 -e VAR=VALUE ... %command%` form into that one, dropping its+`DYLD_INSERT_LIBRARIES`.diff --git a/dylib/feats/compat_run.sh b/dylib/feats/compat_run.shindex f264c9f..9686e34 100755--- a/dylib/feats/compat_run.sh+++ b/dylib/feats/compat_run.sh@@ -256,8 +256,15 @@ gamefix_reason() {case "$1" inBACKEND)case "$2" in dxmt|dxvk|wined3d|d3dmetal) ;; *) echo "not dxmt, dxvk, wined3d or d3dmetal" ;; esac ;;- MSYNC|RETINA|NVAPI|FRAMEGEN)+ MSYNC|RETINA|NVAPI|FRAMEGEN_UI|FRAMEGEN_FALLBACK)case "$2" in 0|1) ;; *) echo "not 0 or 1" ;; esac ;;+ FRAMEGEN)+ # 1 is the 2x of the first release.+ case "$2" in 0|1|2|3|adaptive) ;; *) echo "not 0, 1, 2, 3 or adaptive" ;; esac ;;+ FRAMEGEN_QUALITY)+ case "$2" in performance|balanced|quality) ;; *) echo "not performance, balanced or quality" ;; esac ;;+ FRAMEGEN_ENGINE)+ case "$2" in own|metalfx) ;; *) echo "not own or metalfx" ;; esac ;;DLLOVERRIDES)valid_dll_overrides "$2" || echo "not Wine override syntax" ;;ARGS)@@ -340,7 +347,8 @@ load_gamefixes() {gamefix_log "ARGS not applied, $verb is not the game launch"fi ;;RETINA) gamefix_apply_env NOTPROTON_RETINA "$value" "$from" ;;- FRAMEGEN) gamefix_apply_env NOTPROTON_FRAMEGEN "$value" "$from" ;;+ FRAMEGEN|FRAMEGEN_QUALITY|FRAMEGEN_UI|FRAMEGEN_FALLBACK|FRAMEGEN_ENGINE)+ gamefix_apply_env "NOTPROTON_$key" "$value" "$from" ;;*) gamefix_apply_env "$key" "$value" "$from" ;;esacdone@@ -1974,7 +1982,7 @@ if [ -n "\$STEAM_DYLD_INSERT_LIBRARIES" ]; thenelseexport DYLD_INSERT_LIBRARIES="\$STEAM_DYLD_INSERT_LIBRARIES"fi-elif [ -f "\$shim" ] && [ "\${NOTPROTON_FRAMEGEN:-0}" != 0 ]; then+elif [ -f "\$shim" ] && [ "\${NOTPROTON_FRAMEGEN:-0}" != 0 ] && [ "\$NOTPROTON_FRAMEGEN" != off ]; then# Frame generation lives in the shim, so it loads without the Steam overlay too.export DYLD_INSERT_LIBRARIES="\$shim"export NOTPROTON_OVERLAY_SHIM="\$shim"@@ -2114,7 +2122,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|SDL_GAMECONTROLLERCONFIG(_FILE)?|SDL_JOYSTICK_MFI|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_]*|NOTPROTON_FRAMEGEN)=.*/\1/p'); do+for name in $(env | sed -nE 's/^(CX_APPLEGPTK_LIBD3DSHARED_PATH|SDL_GAMECONTROLLERCONFIG(_FILE)?|SDL_JOYSTICK_MFI|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_]*|NOTPROTON_FRAMEGEN(_[A-Z]+)?)=.*/\1/p'); doeval "value=\$$name"# shellcheck disable=SC2154 # eval assigns value on the line aboveset -- --env "$name=$value" "$@"diff --git a/dylib/feats/webpatch.c b/dylib/feats/webpatch.cindex 74cd789..1066391 100644--- a/dylib/feats/webpatch.c+++ b/dylib/feats/webpatch.c@@ -157,9 +157,9 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {"else{const w=wd();if(!c.length&&/^(if|then|else|elif|do|while|until|!|\\{)$/" \".test(o.slice(w.start,w.end)))cs.push(c=[]);else c.push(w)}}" \"const m=w=>/%command%/i.test(o.slice(w.start,w.end)),G=cs.find(c=>c.some(m));" \- "if(!G)return{p:0,e:[]};" \+ "if(!G)return{p:0,e:[],G:[],c:-1};" \"const n=G.findIndex(w=>m(w)||!/^[A-Za-z_]\\w*=/.test(o.slice(w.start,w.end)));" \- "return{p:G[0].start,e:G.slice(0,n<0?G.length:n)}})(),"+ "return{p:G[0].start,e:G.slice(0,n<0?G.length:n),G:G,c:G.findIndex(m)}})(),"// CrossOver options panel. Not in great shape, but it'll do#define NP_CX_OPTIONS_CSS \@@ -173,22 +173,59 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {ARG "=>{" \"const t=" ARG ".details,o=t.strLaunchOptions||\"\"," \NP_CX_LAUNCH_PARSE \- "g=k=>{const p=E.e.filter(w=>o.startsWith(k+\"=\",w.start)).pop();" \- "return p?(p.value===null?o.slice(p.start+k.length+1,p.end):p.value.slice(k.length+1)):\"\"}," \+ "nat=t.unAppID<2147483648&&(t.vecPlatforms||[]).indexOf(\"osx\")>=0&&!t.strCompatToolName," \+ "wv=w=>w.value===null?o.slice(w.start,w.end):w.value," \+ "NE=E.c<0?[]:E.G.slice(0,E.c).filter(w=>/^[A-Za-z_]\\w*=/.test(wv(w)))," \+ "A=k=>(nat?NE.filter(w=>wv(w).startsWith(k+\"=\")):E.e.filter(w=>o.startsWith(k+\"=\",w.start))).pop()," \+ "g=k=>{const p=A(k);return p?wv(p).slice(k.length+1):\"\"}," \"qv=v=>/^[\\w.,:=\\/+@%-]*$/.test(v)?v:\"'\"+v.replace(/'/g,\"'\\\\''\")+\"'\"," \- "s=ps=>{const add=ps.filter(p=>p[1]).map(p=>p[0]+\"=\"+qv(p[1])).join(\" \");let r;" \+ "sl=ps=>{const add=ps.filter(p=>p[1]).map(p=>p[0]+\"=\"+qv(p[1])).join(\" \");let r;" \"if(!/%command%/i.test(o)){if(!add)return;r=add+\" %command%\"+(o.trim()?\" \"+o:\"\")}" \"else{let at=E.p;r=o.slice(0,at)+(add?add+\" \":\"\");" \"E.e.forEach(w=>{if(ps.some(p=>o.startsWith(p[0]+\"=\",w.start))){" \"r+=o.slice(at,w.start);at=w.end;while(o[at]===\" \"||o[at]===\"\\t\")at++}});r+=o.slice(at)}" \"SteamClient.Apps.SetAppLaunchOptions(t.unAppID,r.trim()===\"%command%\"?\"\":r)}," \+ /* Native games run through np-native, which also forces arm64: <launcher> VAR=VALUE ... \+ %command% <game args>. Assignments are read from any word before %command%, so the \+ older "/usr/bin/arch ... -e VAR=VALUE" form is understood, and rewritten without the \+ arch prefix and its DYLD_INSERT_LIBRARIES. */ \+ "sn=ps=>{const c=E.c<0?null:E.G[E.c]," \+ "L=Fx.h?Fx.h+\"/.notproton/np-native\":(c&&E.G.slice(0,E.c).map(wv)" \+ ".find(x=>/\\/\\.notproton\\/np-native$/.test(x)))||\"\";" \+ "if(!L||!c&&!ps.some(p=>p[1]))return;" \+ "const kn=w=>{const x=wv(w);return x.slice(0,x.indexOf(\"=\"))};" \+ "let vs=NE.filter(w=>kn(w)!==\"DYLD_INSERT_LIBRARIES\").map(w=>[kn(w),o.slice(w.start,w.end)]);" \+ "ps.forEach(p=>{const i=vs.findIndex(x=>x[0]===p[0]);vs=vs.filter(x=>x[0]!==p[0]);" \+ "if(p[1])vs.splice(i<0?vs.length:i,0,[p[0],p[0]+\"=\"+qv(p[1])])});" \+ "const h=[qv(L)].concat(vs.map(x=>x[1])).join(\" \");" \+ "SteamClient.Apps.SetAppLaunchOptions(t.unAppID," \+ "c?o.slice(0,E.p)+h+\" \"+o.slice(c.start):h+\" %command%\"+(o.trim()?\" \"+o.trim():\"\"))}," \+ "s=ps=>nat?sn(ps):sl(ps)," \"Fx=globalThis.MSCXFx||{}," \- "dv=k=>{const a=(Fx.a||{})[t.unAppID]||{},en=Fx.e||{},x=en[t.strCompatToolName]||en[\"\"]||{};" \+ "dv=k=>{if(nat){const a=(Fx.na||{})[t.unAppID]||{},n=Fx.ng||{};" \+ "return k in a?a[k]:k in n?n[k]:(Fx.d||{})[k]||\"\"}" \+ "const a=(Fx.a||{})[t.unAppID]||{},en=Fx.e||{},x=en[t.strCompatToolName]||en[\"\"]||{};" \"return k in a?a[k]:k in(Fx.g||{})?Fx.g[k]:k in x?x[k]:(Fx.d||{})[k]||\"\"}," \- "ev=k=>E.e.some(w=>o.startsWith(k+\"=\",w.start))?g(k):dv(k)," \+ "ev=k=>A(k)?g(k):dv(k)," \"T=(ks,l,on,off)=>(0," RT ".jsx)(" BARREL ".Yh,{className:\"MSCXRow\",label:l," \"checked:ev(ks[0])===on," \"onChange:v=>s(ks.map(k=>[k,v?(dv(k)===on?\"\":on):(dv(k)===on?(off||\"0\"):\"\")]))},ks[0])," \+ /* A labelled dropdown row. n turns a raw value, set or not, into an option's data, so \+ picking what the confs already give drops the argument instead of writing it. */ \+ "D=(k,l,O,n)=>(0," RT ".jsx)(" BARREL ".m,{label:l,strClassName:\"MSCXRow\",rgOptions:O," \+ "selectedOption:n(ev(k)),onChange:v=>s([[k,v.data===n(dv(k))?\"\":v.data]])},k)," \+ "lc=z=>x=>(x||z).toLowerCase()," \+ "fz=x=>{x=(x||\"\").toLowerCase();return x===\"1\"?\"2\":/^(0|off|false|no)?$/.test(x)?\"0\":x}," \+ "fo=fz(ev(\"NOTPROTON_FRAMEGEN\"))!==\"0\"," \+ "FG=()=>(0," RT ".jsxs)(" BARREL ".XY,{label:\"Frame Generation (Experimental. Adds input lag)\",children:[" \+ "D(\"NOTPROTON_FRAMEGEN\",\"Mode\",[{data:\"0\",label:\"Off\"},{data:\"2\",label:\"2x\"}," \+ "{data:\"3\",label:\"3x\"},{data:\"adaptive\",label:\"Adaptive (fills to display refresh)\"}],fz)," \+ "fo&&D(\"NOTPROTON_FRAMEGEN_QUALITY\",\"Quality\",[{data:\"performance\",label:\"Performance\"}," \+ "{data:\"balanced\",label:\"Balanced\"},{data:\"quality\",label:\"Quality\"}],lc(\"balanced\"))," \+ "fo&&T([\"NOTPROTON_FRAMEGEN_UI\"],\"Protect UI (keeps static HUD and menus sharp)\",\"1\",\"0\")," \+ "fo&&T([\"NOTPROTON_FRAMEGEN_FALLBACK\"],\"Fast-motion fallback (skips frames that would smear)\",\"1\",\"0\")," \+ "fo&&D(\"NOTPROTON_FRAMEGEN_ENGINE\",\"Engine\",[{data:\"own\",label:\"Built-in optical flow\"}," \+ "{data:\"metalfx\",label:\"MetalFX\"}],lc(\"own\"))]},\"fgn\")," \"b=g(\"CX_GRAPHICS_BACKEND\")," \"dm=\"\"===b||\"d3dmetal\"===b," \"dx=\"\"===b||\"dxmt\"===b," \@@ -209,8 +246,13 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {"{data:\"dxmt\",label:\"DXMT\"}," \"{data:\"dxvk\",label:\"DXVK\"}," \"{data:\"wined3d\",label:\"WineD3D\"}];" \- "if(t.unAppID<2147483648&&(t.vecPlatforms||[]).indexOf(\"osx\")>=0" \- "&&!t.strCompatToolName)return null;" \+ "if(nat)return(0," RT ".jsx)(\"div\",{className:\"MSCXPanel\",children:(0," RT ".jsxs)(" RT ".Fragment,{children:[" \+ "(0," RT ".jsx)(\"style\",{children:" NP_CX_OPTIONS_CSS "})," \+ "T([\"MTL_HUD_ENABLED\"],\"Metal HUD\",\"1\"),FG()," \+ "(0," RT ".jsx)(" BARREL ".XY,{label:\"Controllers\",children:" \+ "D(\"NP_PAD_MODE\",\"Controller layer\",[{data:\"\",label:\"Automatic\"},{data:\"hid\",label:\"Raw HID (Unity, SDL, Unreal)\"}," \+ "{data:\"gc\",label:\"GameController\"},{data:\"off\",label:\"Off\"}],lc(\"\"))},\"ctl\")" \+ "]})});" \"return(0," RT ".jsx)(\"div\",{className:\"MSCXPanel\",children:(0," RT ".jsxs)(" RT ".Fragment,{children:[" \"(0," RT ".jsx)(\"style\",{children:" NP_CX_OPTIONS_CSS "})," \"(0," RT ".jsxs)(" BARREL ".XY,{label:\"Graphics\",children:[" \@@ -232,8 +274,7 @@ static int out_expand(np_out_t *o, const char *replace, const np_cap_t *caps) {"children:(0," RT ".jsx)(" BARREL ".m,{rgOptions:U," \"selectedOption:sw?(U.find(u=>u.data&&+u.data===fn)||{data:String(fn)}).data:\"\"," \"onChange:v=>s([[\"DXMT_METALFX_SPATIAL_SWAPCHAIN\",v.data?\"1\":\"\"],[\"DXMT_CONFIG\",fx(v.data)]])})},\"usf\")," \- "(0," RT ".jsx)(" BARREL ".XY,{label:\"Frame Generation (Experimental. Adds input lag)\",children:" \- "T([\"NOTPROTON_FRAMEGEN\"],\"MetalFX frame interpolation (2x)\",\"1\",\"0\")},\"fgn\")," \+ "FG()," \"(0," RT ".jsx)(" BARREL ".XY,{label:\"Controllers (May break Steam Input. Not recommended)\",children:" \"T([\"NOTPROTON_RAW_CONTROLLERS\"],\"Let games read controllers directly\",\"1\",\"\")},\"ctl\")" \"]})})}"@@ -423,7 +464,9 @@ int np_webpatch_should_patch(const char *path) {// launch options > gamefixes/<appid>.conf > gamefixes-default/<appid>.conf >// gamefixes/default.conf > the engine, so the values below the launch options are handed to// the page as globalThis.MSCXFx when Steam loads it (a later conf edit shows after a restart).-#define NP_FX_MAX 4096+// Native games go through np-native instead, which reads gamefixes/native/<appid>.conf over+// gamefixes/native-default.conf with variable names as they are; those land in ng and na.+#define NP_FX_MAX 16384static const char *fx_panel_key(const char *key) {static const char *const same[] = {@@ -431,11 +474,27 @@ static const char *fx_panel_key(const char *key) {};if (strcmp(key, "RETINA") == 0) return "NOTPROTON_RETINA";if (strcmp(key, "MSYNC") == 0) return "WINEMSYNC";+ if (strcmp(key, "FRAMEGEN") == 0) return "NOTPROTON_FRAMEGEN";+ if (strcmp(key, "FRAMEGEN_QUALITY") == 0) return "NOTPROTON_FRAMEGEN_QUALITY";+ if (strcmp(key, "FRAMEGEN_UI") == 0) return "NOTPROTON_FRAMEGEN_UI";+ if (strcmp(key, "FRAMEGEN_FALLBACK") == 0) return "NOTPROTON_FRAMEGEN_FALLBACK";+ if (strcmp(key, "FRAMEGEN_ENGINE") == 0) return "NOTPROTON_FRAMEGEN_ENGINE";for (size_t i = 0; i < sizeof(same) / sizeof(same[0]); i++)if (strcmp(key, same[i]) == 0) return same[i];return NULL;}+// np-native confs name the variables themselves.+static const char *fx_native_key(const char *key) {+ static const char *const keys[] = {+ "MTL_HUD_ENABLED", "NP_PAD_MODE", "NOTPROTON_FRAMEGEN", "NOTPROTON_FRAMEGEN_QUALITY",+ "NOTPROTON_FRAMEGEN_UI", "NOTPROTON_FRAMEGEN_FALLBACK", "NOTPROTON_FRAMEGEN_ENGINE",+ };+ for (size_t i = 0; i < sizeof(keys) / sizeof(keys[0]); i++)+ if (strcmp(key, keys[i]) == 0) return keys[i];+ return NULL;+}+// Characters that go into a JSON string unescaped, up to max of them.static int fx_word(const char *v, size_t max) {size_t n = strlen(v);@@ -452,7 +511,7 @@ static int fx_word(const char *v, size_t max) {static int fx_safe(const char *v) { return fx_word(v, 16); }typedef struct { char key[32]; char val[20]; } fx_pair_t;-typedef struct { fx_pair_t p[8]; size_t n; } fx_set_t;+typedef struct { fx_pair_t p[16]; size_t n; } fx_set_t;static void fx_set(fx_set_t *set, const char *key, const char *val) {for (size_t i = 0; i < set->n; i++)@@ -464,21 +523,42 @@ static void fx_set(fx_set_t *set, const char *key, const char *val) {}}+static char *fx_trim(char *b) {+ while (*b == ' ' || *b == '\t') b++;+ char *e = b + strlen(b);+ while (e > b && (e[-1] == '\n' || e[-1] == '\r' || e[-1] == ' ' || e[-1] == '\t')) *--e = '\0';+ return b;+}+// Same line rules as the run script's gamefix_read: KEY=VALUE, # comments, blank lines.-static void fx_read(const char *path, fx_set_t *set) {+// A native conf follows np-native's load_conf: "export " allowed, whitespace around the =+// and one pair of matching quotes around the value dropped.+static void fx_read(const char *path, fx_set_t *set, int native) {FILE *f = fopen(path, "r");if (!f) return;char line[256];while (fgets(line, sizeof(line), f)) {- char *b = line, *e;- while (*b == ' ' || *b == '\t') b++;- e = b + strlen(b);- while (e > b && (e[-1] == '\n' || e[-1] == '\r' || e[-1] == ' ' || e[-1] == '\t')) *--e = '\0';+ char *b = fx_trim(line);+ if (native && strncmp(b, "export ", 7) == 0) b = fx_trim(b + 7);char *eq = strchr(b, '=');if (*b == '#' || !eq) continue;*eq = '\0';- const char *key = fx_panel_key(b);- if (key && fx_safe(eq + 1)) fx_set(set, key, eq + 1);+ char *val = eq + 1;+ const char *key;+ if (native) {+ char *k = b + strlen(b);+ while (k > b && (k[-1] == ' ' || k[-1] == '\t')) *--k = '\0';+ val = fx_trim(val);+ size_t vl = strlen(val);+ if (vl >= 2 && (val[0] == '"' || val[0] == '\'') && val[vl - 1] == val[0]) {+ val[vl - 1] = '\0';+ val++;+ }+ key = fx_native_key(b);+ } else {+ key = fx_panel_key(b);+ }+ if (key && fx_safe(val)) fx_set(set, key, val);}fclose(f);}@@ -498,6 +578,26 @@ static int fx_json_set(char *buf, size_t cap, size_t *len, const fx_set_t *set)return 1;}+// A JSON string, for values that can hold any character (the home directory).+static int fx_json_str(char *buf, size_t cap, size_t *len, const char *v) {+ if (*len + 1 >= cap) return 0;+ buf[(*len)++] = '"';+ for (; *v; v++) {+ unsigned char c = (unsigned char)*v;+ char esc[8];+ int n;+ if (c == '"' || c == '\\') n = snprintf(esc, sizeof(esc), "\\%c", c);+ else if (c < 0x20 || c == 0x7f) n = snprintf(esc, sizeof(esc), "\\u%04x", c);+ else { esc[0] = (char)c; esc[1] = '\0'; n = 1; }+ if (n < 0 || *len + (size_t)n + 1 >= cap) return 0;+ memcpy(buf + *len, esc, (size_t)n);+ *len += (size_t)n;+ }+ buf[(*len)++] = '"';+ buf[*len] = '\0';+ return 1;+}+static int fx_appid(const char *name, char *out, size_t cap) {size_t n = 0;while (name[n] >= '0' && name[n] <= '9') n++;@@ -507,32 +607,16 @@ static int fx_appid(const char *name, char *out, size_t cap) {return 1;}-static int fx_build(char *buf, size_t cap) {- const char *home = getenv("HOME");- if (!home || !*home) return 0;- char root[512], path[768];- snprintf(root, sizeof(root), "%s/Library/Application Support/notproton", home);-- // Steam's chunks end in "//# sourceMappingURL=..." with no newline after it, so the- // assignment starts a line of its own or the browser reads it as part of that comment.- size_t len = 0;- int n = snprintf(buf, cap, "\n;globalThis.MSCXFx={\"g\":");- if (n < 0 || (size_t)n >= cap) return 0;- len = (size_t)n;-- fx_set_t global = {0};- snprintf(path, sizeof(path), "%s/gamefixes/default.conf", root);- fx_read(path, &global);- if (!fx_json_set(buf, cap, &len, &global)) return 0;-- // Per-app: the shipped file first, the user's second, as the run script reads them.- n = snprintf(buf + len, cap - len, ",\"a\":{");- if (n < 0 || (size_t)n >= cap - len) return 0;- len += (size_t)n;- const char *dirs[2] = { "gamefixes-default", "gamefixes" };+// {"<appid>":{...},...} from the <appid>.conf files in dirs, later dirs winning per key.+static int fx_json_apps(char *buf, size_t cap, size_t *len, const char *root,+ const char *const *dirs, int ndirs, int native) {+ char path[768];+ int n = snprintf(buf + *len, cap - *len, "{");+ if (n < 0 || (size_t)n >= cap - *len) return 0;+ *len += (size_t)n;char seen[64][16];size_t nseen = 0;- for (int d = 0; d < 2; d++) {+ for (int d = 0; d < ndirs; d++) {snprintf(path, sizeof(path), "%s/%s", root, dirs[d]);DIR *dir = opendir(path);if (!dir) continue;@@ -546,22 +630,54 @@ static int fx_build(char *buf, size_t cap) {}closedir(dir);}+ int first = 1;for (size_t i = 0; i < nseen; i++) {fx_set_t app = {0};- for (int d = 0; d < 2; d++) {+ for (int d = 0; d < ndirs; d++) {snprintf(path, sizeof(path), "%s/%s/%s.conf", root, dirs[d], seen[i]);- fx_read(path, &app);+ fx_read(path, &app, native);}if (!app.n) continue;- n = snprintf(buf + len, cap - len, "%s\"%s\":", len && buf[len - 1] == '{' ? "" : ",", seen[i]);- if (n < 0 || (size_t)n >= cap - len) return 0;- len += (size_t)n;- if (!fx_json_set(buf, cap, &len, &app)) return 0;+ n = snprintf(buf + *len, cap - *len, "%s\"%s\":", first ? "" : ",", seen[i]);+ if (n < 0 || (size_t)n >= cap - *len) return 0;+ *len += (size_t)n;+ first = 0;+ if (!fx_json_set(buf, cap, len, &app)) return 0;}+ n = snprintf(buf + *len, cap - *len, "}");+ if (n < 0 || (size_t)n >= cap - *len) return 0;+ *len += (size_t)n;+ return 1;+}++static int fx_build(char *buf, size_t cap) {+ const char *home = getenv("HOME");+ if (!home || !*home) return 0;+ char root[512], path[768];+ snprintf(root, sizeof(root), "%s/Library/Application Support/notproton", home);++ // Steam's chunks end in "//# sourceMappingURL=..." with no newline after it, so the+ // assignment starts a line of its own or the browser reads it as part of that comment.+ size_t len = 0;+ int n = snprintf(buf, cap, "\n;globalThis.MSCXFx={\"g\":");+ if (n < 0 || (size_t)n >= cap) return 0;+ len = (size_t)n;++ fx_set_t global = {0};+ snprintf(path, sizeof(path), "%s/gamefixes/default.conf", root);+ fx_read(path, &global, 0);+ if (!fx_json_set(buf, cap, &len, &global)) return 0;++ // Per-app: the shipped file first, the user's second, as the run script reads them.+ n = snprintf(buf + len, cap - len, ",\"a\":");+ if (n < 0 || (size_t)n >= cap - len) return 0;+ len += (size_t)n;+ const char *dirs[2] = { "gamefixes-default", "gamefixes" };+ if (!fx_json_apps(buf, cap, &len, root, dirs, 2, 0)) return 0;// Engines: a tool whose description names msync runs with it on (tools: name, build,// arch, description, tab separated). "" stands for the default tool.- n = snprintf(buf + len, cap - len, "},\"e\":{");+ n = snprintf(buf + len, cap - len, ",\"e\":{");if (n < 0 || (size_t)n >= cap - len) return 0;len += (size_t)n;snprintf(path, sizeof(path), "%s/tools", root);@@ -590,8 +706,31 @@ static int fx_build(char *buf, size_t cap) {fclose(tools);}- // The run script reads controllers directly unless the launch options say otherwise.- n = snprintf(buf + len, cap - len, "},\"d\":{\"NOTPROTON_RAW_CONTROLLERS\":\"1\"}};");+ // The run script reads controllers directly unless the launch options say otherwise, and+ // overlay-shim keeps the UI sharp and falls back on fast motion unless told not to.+ n = snprintf(buf + len, cap - len, "},\"d\":{\"NOTPROTON_RAW_CONTROLLERS\":\"1\","+ "\"NOTPROTON_FRAMEGEN_UI\":\"1\",\"NOTPROTON_FRAMEGEN_FALLBACK\":\"1\"}");+ if (n < 0 || (size_t)n >= cap - len) return 0;+ len += (size_t)n;++ // Native games: np-native's own confs, and the home its launcher path is written under.+ n = snprintf(buf + len, cap - len, ",\"ng\":");+ if (n < 0 || (size_t)n >= cap - len) return 0;+ len += (size_t)n;+ fx_set_t native = {0};+ snprintf(path, sizeof(path), "%s/gamefixes/native-default.conf", root);+ fx_read(path, &native, 1);+ if (!fx_json_set(buf, cap, &len, &native)) return 0;+ n = snprintf(buf + len, cap - len, ",\"na\":");+ if (n < 0 || (size_t)n >= cap - len) return 0;+ len += (size_t)n;+ const char *ndirs[1] = { "gamefixes/native" };+ if (!fx_json_apps(buf, cap, &len, root, ndirs, 1, 1)) return 0;+ n = snprintf(buf + len, cap - len, ",\"h\":");+ if (n < 0 || (size_t)n >= cap - len) return 0;+ len += (size_t)n;+ if (!fx_json_str(buf, cap, &len, home)) return 0;+ n = snprintf(buf + len, cap - len, "};");if (n < 0 || (size_t)n >= cap - len) return 0;return 1;}diff --git a/dylib/tests/gamefixescheck.sh b/dylib/tests/gamefixescheck.shindex 09e30ad..70364c0 100644--- a/dylib/tests/gamefixescheck.sh+++ b/dylib/tests/gamefixescheck.sh@@ -18,6 +18,8 @@ bridge_line=$(grep 'export WINEDLLOVERRIDES=' "$SRC" | grep 'lsteamclient=b' | s[ -n "$bridge_line" ] || { echo "FAIL: the bridge WINEDLLOVERRIDES line not found"; exit 1; }forward=$(sed -n '/^for name in $(env /,/^done$/p' "$SRC")[ -n "$forward" ] || { echo "FAIL: the launcher environment loop not found"; exit 1; }+launcher_body=$(sed -n '/^cat > "\$loader_macos\/launcher" <<LAUNCHER$/,/^LAUNCHER$/p' "$SRC")+[ -n "$launcher_body" ] || { echo "FAIL: the launcher heredoc not found"; exit 1; }append_args=$(sed -n '/^if \[ -n "\$gamefix_args" \]; then$/,/^fi$/p' "$SRC")[ -n "$append_args" ] || { echo "FAIL: the ARGS append not found"; exit 1; }@@ -106,7 +108,8 @@ launch() {graphics_log "backend=$backend ($backend_from)"compose_dll_overrideseval "$bridge_line"- for v in backend WINEDLLOVERRIDES WINEMSYNC msync_from NOTPROTON_RETINA NOTPROTON_FRAMEGEN CX_GRAPHICS_BACKEND \+ for v in backend WINEDLLOVERRIDES WINEMSYNC msync_from NOTPROTON_RETINA NOTPROTON_FRAMEGEN \+ NOTPROTON_FRAMEGEN_QUALITY NOTPROTON_FRAMEGEN_UI NOTPROTON_FRAMEGEN_FALLBACK NOTPROTON_FRAMEGEN_ENGINE CX_GRAPHICS_BACKEND \DXVK_HUD VKD3D_CONFIG WINEDEBUG MTL_HUD_ENABLED gamefix_args; doeval "printf \"%s=%s\\n\" \$v \"\${$v-<unset>}\""done@@ -166,7 +169,8 @@ default_conf '# shipped fix' '' ' DXVK_HUD=fps ' "VKD3D_CONFIG=dxr$(printf '\r'WINEDEBUG=-all' 'PATH=/evil' 'DYLD_INSERT_LIBRARIES=/evil.dylib' 'lower=1' 'no equals sign' \"DXMT_A=\$(touch $case_dir/pwned)" 'DXMT_B=`touch pwned`' 'DXMT_C="quoted"' "DXMT_D='single'" \'BACKEND=vulkan' 'MSYNC=2' 'RETINA=yes' 'DLLOVERRIDES=dxgi=native' 'DLLOVERRIDES=;=n' \- 'DXMT_=1' 'MTL_HUD_ENABLED=1' 'FRAMEGEN=2'+ 'DXMT_=1' 'MTL_HUD_ENABLED=1' 'FRAMEGEN=4' 'FRAMEGEN_QUALITY=ultra' 'FRAMEGEN_UI=2' \+ 'FRAMEGEN_FALLBACK=yes' 'FRAMEGEN_ENGINE=fsr' 'FRAMEGEN_OTHER=1'launch waitforexitandrun "$case_dir/game/game.exe"is "a padded value is trimmed" "fps" "$(got DXVK_HUD)"is "a CRLF line ends cleanly" "dxr" "$(got VKD3D_CONFIG)"@@ -188,6 +192,13 @@ has "RETINA must be 0 or 1" "rejected RETINA: not 0 or 1" "$case_dir/log"has "a bad override order is rejected" "line 17 rejected DLLOVERRIDES: not Wine override syntax" "$case_dir/log"has "an override without a name is rejected" "line 18 rejected DLLOVERRIDES: not Wine override syntax" "$case_dir/log"has "a bare prefix is not a variable" "rejected DXMT_: not on the allow-list" "$case_dir/log"+has "FRAMEGEN must be a mode" "rejected FRAMEGEN: not 0, 1, 2, 3 or adaptive" "$case_dir/log"+has "FRAMEGEN_QUALITY must be a quality" "rejected FRAMEGEN_QUALITY: not performance, balanced or quality" "$case_dir/log"+has "FRAMEGEN_UI must be 0 or 1" "rejected FRAMEGEN_UI: not 0 or 1" "$case_dir/log"+has "FRAMEGEN_FALLBACK must be 0 or 1" "rejected FRAMEGEN_FALLBACK: not 0 or 1" "$case_dir/log"+has "FRAMEGEN_ENGINE must be an engine" "rejected FRAMEGEN_ENGINE: not own or metalfx" "$case_dir/log"+has "an unknown FRAMEGEN_ key is not on the allow-list" "rejected FRAMEGEN_OTHER: not on the allow-list" "$case_dir/log"+is "a rejected FRAMEGEN leaves frame generation unset" "<unset>" "$(got NOTPROTON_FRAMEGEN)"has "applied values are logged" "applied DXVK_HUD=fps from the default conf" "$case_dir/log"echo "== precedence: launch options > user conf > default conf > auto > default"@@ -502,14 +513,62 @@ launch waitforexitandrun "$case_dir/game/game.exe"is "FRAMEGEN maps to NOTPROTON_FRAMEGEN" "1" "$(got NOTPROTON_FRAMEGEN)"launch waitforexitandrun "$case_dir/game/game.exe" NOTPROTON_FRAMEGEN=0is "the frame generation launch option wins" "0" "$(got NOTPROTON_FRAMEGEN)"+for mode in 0 2 3 adaptive; do+ new_case+ full_engine+ user_conf "FRAMEGEN=$mode"+ launch waitforexitandrun "$case_dir/game/game.exe"+ is "FRAMEGEN=$mode is accepted" "$mode" "$(got NOTPROTON_FRAMEGEN)"+done+new_case+full_engine+default_conf 'FRAMEGEN_QUALITY=performance' 'FRAMEGEN_UI=1' 'FRAMEGEN_FALLBACK=1' 'FRAMEGEN_ENGINE=own'+user_conf 'FRAMEGEN=2' 'FRAMEGEN_QUALITY=quality' 'FRAMEGEN_UI=0' 'FRAMEGEN_FALLBACK=0' 'FRAMEGEN_ENGINE=metalfx'+launch waitforexitandrun "$case_dir/game/game.exe"+is "FRAMEGEN_QUALITY maps to NOTPROTON_FRAMEGEN_QUALITY, user over default" "quality" "$(got NOTPROTON_FRAMEGEN_QUALITY)"+is "FRAMEGEN_UI maps to NOTPROTON_FRAMEGEN_UI" "0" "$(got NOTPROTON_FRAMEGEN_UI)"+is "FRAMEGEN_FALLBACK maps to NOTPROTON_FRAMEGEN_FALLBACK" "0" "$(got NOTPROTON_FRAMEGEN_FALLBACK)"+is "FRAMEGEN_ENGINE maps to NOTPROTON_FRAMEGEN_ENGINE" "metalfx" "$(got NOTPROTON_FRAMEGEN_ENGINE)"+launch waitforexitandrun "$case_dir/game/game.exe" NOTPROTON_FRAMEGEN_QUALITY=balanced NOTPROTON_FRAMEGEN_UI=1 \+ NOTPROTON_FRAMEGEN_FALLBACK=1 NOTPROTON_FRAMEGEN_ENGINE=own+is "the quality launch option wins" "balanced" "$(got NOTPROTON_FRAMEGEN_QUALITY)"+is "the Protect UI launch option wins" "1" "$(got NOTPROTON_FRAMEGEN_UI)"+is "the fallback launch option wins" "1" "$(got NOTPROTON_FRAMEGEN_FALLBACK)"+is "the engine launch option wins" "own" "$(got NOTPROTON_FRAMEGEN_ENGINE)"+new_case+full_engine+launch waitforexitandrun "$case_dir/game/game.exe"+is "no conf leaves the quality to the shim" "<unset>" "$(got NOTPROTON_FRAMEGEN_QUALITY)"++# The stub reports NOTPROTON_OVERLAY_SHIM, set beside DYLD_INSERT_LIBRARIES, since SIP strips DYLD_* from /bin/sh.+echo "== the launcher loads the shim for frame generation unless it is off"+mkdir -p "$work/launcher/Contents/MacOS" "$work/launcher/home/Library/Application Support/notproton"+: > "$work/launcher/home/Library/Application Support/notproton/overlay-shim.dylib"+printf '#!/bin/sh\nprintf "%%s" "${NOTPROTON_OVERLAY_SHIM:-none}"\n' > "$work/launcher/wine"+chmod +x "$work/launcher/wine"+env -i PATH="$PATH" HOME="$work/launcher/home" WINELOADER="$work/launcher/wine" loader_root="$work/launcher" \+ loader_macos="$work/launcher/Contents/MacOS" body="$launcher_body" sh -ec 'eval "$body"'+chmod +x "$work/launcher/Contents/MacOS/launcher"+for spec in '-:none' '0:none' 'off:none' '1:shim' '2:shim' '3:shim' 'adaptive:shim'; do+ fg=${spec%%:*} want=${spec#*:}+ if [ "$fg" = - ]; then+ env -i PATH="$PATH" "$work/launcher/Contents/MacOS/launcher" >/dev/null 2>&1 || true+ else+ env -i PATH="$PATH" NOTPROTON_FRAMEGEN="$fg" "$work/launcher/Contents/MacOS/launcher" >/dev/null 2>&1 || true+ fi+ got_dyld=$(cat "$work/launcher/notproton-wine.log")+ case "$got_dyld" in *overlay-shim.dylib) got_dyld=shim ;; esac+ is "NOTPROTON_FRAMEGEN=${fg#-} without the Steam overlay: $want" "$want" "$got_dyld"+doneecho "== the launcher receives the allow-listed variables"set --out=$(env -i PATH="$PATH" forward="$forward" VKD3D_CONFIG=dxr MVK_CONFIG_LOG_LEVEL=1 \STAGING_SHARED_MEMORY=1 WINE_CPU_TOPOLOGY=4:0,1,2,3 WINE_LARGE_ADDRESS_AWARE=1 \- DXVK_HUD=fps NOTPROTON_FRAMEGEN=1 NOTPROTON_UNRELATED=1 sh -c 'set --; eval "$forward"; printf "%s\n" "$@"' | grep -v '^--env$' | sort | tr '\n' ' ')+ DXVK_HUD=fps NOTPROTON_FRAMEGEN=1 NOTPROTON_FRAMEGEN_QUALITY=quality NOTPROTON_FRAMEGEN_UI=0 \+ NOTPROTON_FRAMEGEN_FALLBACK=0 NOTPROTON_FRAMEGEN_ENGINE=metalfx NOTPROTON_FRAMEGENX=1 NOTPROTON_UNRELATED=1 sh -c 'set --; eval "$forward"; printf "%s\n" "$@"' | grep -v '^--env$' | sort | tr '\n' ' ')is "VKD3D_, MVK_, STAGING_ and WINE_ topology variables are forwarded" \- "DXVK_HUD=fps MVK_CONFIG_LOG_LEVEL=1 NOTPROTON_FRAMEGEN=1 STAGING_SHARED_MEMORY=1 VKD3D_CONFIG=dxr WINE_CPU_TOPOLOGY=4:0,1,2,3 WINE_LARGE_ADDRESS_AWARE=1 " "$out"+ "DXVK_HUD=fps MVK_CONFIG_LOG_LEVEL=1 NOTPROTON_FRAMEGEN=1 NOTPROTON_FRAMEGEN_ENGINE=metalfx NOTPROTON_FRAMEGEN_FALLBACK=0 NOTPROTON_FRAMEGEN_QUALITY=quality NOTPROTON_FRAMEGEN_UI=0 STAGING_SHARED_MEMORY=1 VKD3D_CONFIG=dxr WINE_CPU_TOPOLOGY=4:0,1,2,3 WINE_LARGE_ADDRESS_AWARE=1 " "$out"echo "== the wineserver directory self-heal"heal=$(sed -n '/^heal_wine_tmp() {$/,/^}$/p' "$SRC")diff --git a/dylib/tests/panel-behavior/behavior.js b/dylib/tests/panel-behavior/behavior.jsindex e6ff3f8..e54cfd8 100644--- a/dylib/tests/panel-behavior/behavior.js+++ b/dylib/tests/panel-behavior/behavior.js@@ -14,15 +14,13 @@ for (const form of Object.keys(FORMS)) {const sections = ns => ns.filter(x => x.type === 'Section').map(x => x.props.label.split(' ')[0]);const last = () => (written.length ? written[written.length - 1].opts : '');- t.ok(P({ details: details('', { vecPlatforms: ['osx'], strCompatToolName: '' }) }) === null,- 'a mac build with nothing pinned renders no panel');t.ok(P({ details: details('', { unAppID: 3420702832, vecPlatforms: ['osx'],strCompatToolName: '' }) }) !== null,'a shortcut renders the panel before a tool name reaches the page');let r = nodes('');- t.ok(toggles(r).length === 7 && sections(r).length === 4, 'automatic shows seven toggles in four sections');- t.ok(r.filter(x => x.type === 'Dropdown').length === 2, 'two dropdowns');+ t.ok(toggles(r).length === 6 && sections(r).length === 4, 'automatic shows six toggles in four sections');+ t.ok(r.filter(x => x.type === 'Dropdown').length === 3, 'three dropdowns');t.ok(!('label' in r.find(x => x.type === 'Dropdown').props), 'the backend dropdown carries no label column');r = nodes('CX_GRAPHICS_BACKEND=dxmt');@@ -79,7 +77,7 @@ for (const form of Object.keys(FORMS)) {const root = P({ details: details('') });t.ok(root.props.className === 'MSCXPanel', 'the panel root carries its own class');const classes = nodes('').filter(x => x.type === 'Toggle').map(x => x.props.className);- t.ok(classes.length === 7 && classes.every(c => c === 'MSCXRow'), 'every checkbox carries the row class');+ t.ok(classes.length === 6 && classes.every(c => c === 'MSCXRow'), 'every checkbox carries the row class');const raw = o => nodes(o).find(x => x.props.label === 'Let games read controllers directly');t.ok(sections(nodes('')).includes('Controllers') && raw('').props.checked === false,'controller hiding is on unless the game says otherwise');@@ -119,23 +117,212 @@ for (const form of Object.keys(FORMS)) {t.ok(last().trim() === 'NOTPROTON_RAW_CONTROLLERS=0 %command%', `opting out of raw controllers writes 0 (${last()})`);delete globalThis.MSCXFx;- // Frame generation: shown for every backend, one row.- const fg = (o) => nodes(o).find(x => x.props.label === 'MetalFX frame interpolation (2x)');+ // Frame generation: a mode for every backend, and the rest of its rows only once it is on.+ const FGL = 'Frame Generation (Experimental. Adds input lag)';+ const fgRows = o => {+ const sec = nodes(o).find(x => x.type === 'Section' && x.props.label === FGL);+ return sec ? walk(sec.props.children) : [];+ };+ const FGT = { ui: 'Protect UI (keeps static HUD and menus sharp)',+ fb: 'Fast-motion fallback (skips frames that would smear)' };+ const fgrow = (o, l) => fgRows(o).find(x => x.props.label === l);for (const b of ['', 'd3dmetal', 'dxmt', 'dxvk', 'wined3d']) {- t.ok(fg(b ? 'CX_GRAPHICS_BACKEND=' + b : '') !== undefined, `${b || 'automatic'} shows the frame generation row`);+ t.ok(fgrow(b ? 'CX_GRAPHICS_BACKEND=' + b : '', 'Mode') !== undefined,+ `${b || 'automatic'} shows the frame generation mode`);}- t.ok(nodes('').some(x => x.type === 'Section' && x.props.label === 'Frame Generation (Experimental. Adds input lag)'),+ t.ok(nodes('').some(x => x.type === 'Section' && x.props.label === FGL),'the frame generation section warns about latency');- t.ok(fg('').props.checked === false, 'frame generation is off by default');- written.length = 0;- fg('').props.onChange(true);- t.ok(last().trim() === 'NOTPROTON_FRAMEGEN=1 %command%', `the frame generation row writes its flag (${last()})`);- t.ok(fg('NOTPROTON_FRAMEGEN=1').props.checked === true, 'the frame generation row reads its flag');+ const mode = fgrow('', 'Mode');+ t.ok(mode.type === 'Dropdown' && mode.props.className === undefined && mode.props.strClassName === 'MSCXRow',+ 'the mode is a dropdown row');+ t.ok(mode.props.rgOptions.map(x => x.label).join(',') === 'Off,2x,3x,Adaptive (fills to display refresh)' &&+ mode.props.rgOptions.map(x => x.data).join(',') === '0,2,3,adaptive',+ `the modes name themselves (${mode.props.rgOptions.map(x => x.label).join(',')})`);+ t.ok(mode.props.selectedOption === '0', 'frame generation is off by default');+ t.ok(fgRows('').length === 1, 'off hides every other frame generation row');+ t.ok(fgrow('NOTPROTON_FRAMEGEN=0', 'Quality') === undefined, 'an explicit 0 hides them too');+ t.ok(fgrow('NOTPROTON_FRAMEGEN=off', 'Mode').props.selectedOption === '0', 'off reads as Off');+ const ordered = fgRows('NOTPROTON_FRAMEGEN=2').map(x => x.props.label);+ t.ok(ordered.join('|') === ['Mode', 'Quality', FGT.ui, FGT.fb, 'Engine'].join('|'),+ `on shows five rows in order (${ordered.join('|')})`);+ t.ok(fgRows('NOTPROTON_FRAMEGEN=2').every(x => (x.props.className || x.props.strClassName) === 'MSCXRow'),+ 'every frame generation row carries the row class');+ for (const [v, want] of [['1', '2'], ['2', '2'], ['3', '3'], ['adaptive', 'adaptive'], ['Adaptive', 'adaptive']]) {+ t.ok(fgrow('NOTPROTON_FRAMEGEN=' + v, 'Mode').props.selectedOption === want, `${v} reads as ${want}`);+ }+ for (const [v, want] of [['2', 'NOTPROTON_FRAMEGEN=2 %command%'], ['3', 'NOTPROTON_FRAMEGEN=3 %command%'],+ ['adaptive', 'NOTPROTON_FRAMEGEN=adaptive %command%']]) {+ written.length = 0;+ fgrow('', 'Mode').props.onChange({ data: v });+ t.ok(last().trim() === want, `picking ${v} writes it (${last()})`);+ }written.length = 0;- fg('NOTPROTON_FRAMEGEN=1 WINEMSYNC=1').props.onChange(false);+ fgrow('NOTPROTON_FRAMEGEN=1 WINEMSYNC=1', 'Mode').props.onChange({ data: '0' });t.ok(last().trim() === 'WINEMSYNC=1 %command%', `turning frame generation off removes its flag (${last()})`);- globalThis.MSCXFx = { g: { NOTPROTON_FRAMEGEN: '1' }, a: {}, e: {}, d: {} };- t.ok(fg('').props.checked === true, 'a global conf value reads frame generation as on');+ written.length = 0;+ fgrow('NOTPROTON_FRAMEGEN=1', 'Mode').props.onChange({ data: '3' });+ t.ok(last().trim() === 'NOTPROTON_FRAMEGEN=3 %command%', `a legacy 1 is replaced, not kept (${last()})`);+ written.length = 0;+ fgrow('NOTPROTON_FRAMEGEN=2 NOTPROTON_FRAMEGEN_QUALITY=quality', 'Mode').props.onChange({ data: '0' });+ t.ok(last().trim() === 'NOTPROTON_FRAMEGEN_QUALITY=quality %command%',+ `turning it off keeps the sub-settings for the next time (${last()})`);++ const on = 'NOTPROTON_FRAMEGEN=2';+ const quality = fgrow(on, 'Quality');+ t.ok(quality.type === 'Dropdown' && quality.props.selectedOption === 'balanced', 'quality is balanced by default');+ t.ok(quality.props.rgOptions.map(x => x.label + ':' + x.data).join(',') ===+ 'Performance:performance,Balanced:balanced,Quality:quality', 'the qualities name themselves');+ t.ok(fgrow(on + ' NOTPROTON_FRAMEGEN_QUALITY=performance', 'Quality').props.selectedOption === 'performance',+ 'quality reads its flag');+ written.length = 0;+ fgrow(on, 'Quality').props.onChange({ data: 'quality' });+ t.ok(last().trim() === 'NOTPROTON_FRAMEGEN_QUALITY=quality NOTPROTON_FRAMEGEN=2 %command%',+ `quality writes its flag (${last()})`);+ written.length = 0;+ fgrow(on + ' NOTPROTON_FRAMEGEN_QUALITY=quality', 'Quality').props.onChange({ data: 'balanced' });+ t.ok(last().trim() === on + ' %command%', `balanced drops the flag (${last()})`);++ const engine = fgrow(on, 'Engine');+ t.ok(engine.type === 'Dropdown' && engine.props.selectedOption === 'own', 'the engine is the built-in one by default');+ t.ok(engine.props.rgOptions.map(x => x.label + ':' + x.data).join(',') ===+ 'Built-in optical flow:own,MetalFX:metalfx', 'the engines name themselves');+ t.ok(fgrow(on + ' NOTPROTON_FRAMEGEN_ENGINE=metalfx', 'Engine').props.selectedOption === 'metalfx',+ 'the engine reads its flag');+ written.length = 0;+ fgrow(on, 'Engine').props.onChange({ data: 'metalfx' });+ t.ok(last().includes('NOTPROTON_FRAMEGEN_ENGINE=metalfx '), `the engine writes its flag (${last()})`);+ written.length = 0;+ fgrow(on + ' NOTPROTON_FRAMEGEN_ENGINE=metalfx', 'Engine').props.onChange({ data: 'own' });+ t.ok(last().trim() === on + ' %command%', `own drops the flag (${last()})`);++ // Both toggles are on unless told otherwise, which only the run script defaults say.+ globalThis.MSCXFx = { g: {}, a: {}, e: {},+ d: { NOTPROTON_FRAMEGEN_UI: '1', NOTPROTON_FRAMEGEN_FALLBACK: '1' } };+ for (const [k, l] of [['NOTPROTON_FRAMEGEN_UI', FGT.ui], ['NOTPROTON_FRAMEGEN_FALLBACK', FGT.fb]]) {+ t.ok(fgrow(on, l).type === 'Toggle' && fgrow(on, l).props.checked === true, `${k} is on by default`);+ t.ok(fgrow(on + ` ${k}=0`, l).props.checked === false, `${k} reads 0 as off`);+ written.length = 0;+ fgrow(on, l).props.onChange(false);+ t.ok(last().trim() === `${k}=0 ${on} %command%`, `turning ${k} off writes 0 (${last()})`);+ written.length = 0;+ fgrow(on + ` ${k}=0`, l).props.onChange(true);+ t.ok(last().trim() === `${on} %command%`, `turning ${k} back on drops it (${last()})`);+ }+ // A conf that turns frame generation on: Off has to say so, picking the conf's mode says nothing.+ globalThis.MSCXFx = { g: { NOTPROTON_FRAMEGEN: '1', NOTPROTON_FRAMEGEN_QUALITY: 'performance',+ NOTPROTON_FRAMEGEN_ENGINE: 'metalfx', NOTPROTON_FRAMEGEN_UI: '0' },+ a: {}, e: {}, d: { NOTPROTON_FRAMEGEN_UI: '1', NOTPROTON_FRAMEGEN_FALLBACK: '1' } };+ t.ok(fgrow('', 'Mode').props.selectedOption === '2', 'a global conf 1 reads frame generation as 2x');+ t.ok(fgRows('').length === 5, 'a conf that turns it on shows every row');+ t.ok(fgrow('', 'Quality').props.selectedOption === 'performance', 'quality reads the conf');+ t.ok(fgrow('', 'Engine').props.selectedOption === 'metalfx', 'the engine reads the conf');+ t.ok(fgrow('', FGT.ui).props.checked === false, 'the conf beats the run script default');+ written.length = 0;+ fgrow('', 'Mode').props.onChange({ data: '0' });+ t.ok(last().trim() === 'NOTPROTON_FRAMEGEN=0 %command%', `off over a conf default writes 0 (${last()})`);+ written.length = 0;+ fgrow('NOTPROTON_FRAMEGEN=0', 'Mode').props.onChange({ data: '2' });+ t.ok(last() === '', `the conf's own mode drops the override (${JSON.stringify(last())})`);+ written.length = 0;+ fgrow('', 'Quality').props.onChange({ data: 'balanced' });+ t.ok(last().trim() === 'NOTPROTON_FRAMEGEN_QUALITY=balanced %command%',+ `balanced over a conf default writes it (${last()})`);+ delete globalThis.MSCXFx;++ // Native macOS builds with nothing pinned run through np-native: HUD, frame generation, pads.+ const HOME = '/Users/some one';+ const NAT = "'/Users/some one/.notproton/np-native'";+ const mac = (o, over) => details(o, Object.assign({ vecPlatforms: ['osx'], strCompatToolName: '' }, over || {}));+ const nnodes = o => walk(P({ details: mac(o) }));+ const nrow = (o, l) => nnodes(o).find(x => x.props.label === l);+ globalThis.MSCXFx = { g: { MTL_HUD_ENABLED: '1', NOTPROTON_FRAMEGEN: '2' }, a: { 287700: { WINEMSYNC: '1' } },+ e: {}, d: { NOTPROTON_FRAMEGEN_UI: '1', NOTPROTON_FRAMEGEN_FALLBACK: '1' },+ ng: {}, na: {}, h: HOME };+ let n = nnodes('');+ t.ok(P({ details: mac('') }) !== null && P({ details: mac('') }).props.className === 'MSCXPanel',+ 'a mac build with nothing pinned renders the native panel');+ t.ok(toggles(n).join('|') === 'Metal HUD' && sections(n).join(',') === 'Frame,Controllers',+ `the native panel has the HUD, frame generation and controllers only (${toggles(n)} / ${sections(n)})`);+ t.ok(n.filter(x => x.type === 'Dropdown').map(x => x.props.label).join(',') === 'Mode,Controller layer',+ 'native dropdowns: the mode and the controller layer');+ t.ok(nrow('', 'Metal HUD').props.checked === false && nrow('', 'Mode').props.selectedOption === '0',+ 'the Wine confs do not reach a native game');+ t.ok(nnodes('NOTPROTON_FRAMEGEN=3 %command%').filter(x => x.props.label === 'Quality').length === 1,+ 'the native panel carries the same frame generation rows');+ const pad = nrow('', 'Controller layer');+ t.ok(pad.props.rgOptions.map(x => x.label + ':' + x.data).join(',') ===+ 'Automatic:,Raw HID (Unity, SDL, Unreal):hid,GameController:gc,Off:off', 'the controller layers name themselves');+ t.ok(pad.props.selectedOption === '', 'Automatic is selected when NP_PAD_MODE is unset everywhere');+ t.ok(nrow(NAT + ' MTL_HUD_ENABLED=1 %command%', 'Controller layer').props.selectedOption === '',+ 'Automatic stays selected when other variables are set');+ t.ok(pad.props.strClassName === 'MSCXRow', 'the controller layer is a row');+ t.ok(nnodes('').some(x => x.type === 'Section' && x.props.label === 'Controllers'), 'the native controller section');+ t.ok(P({ details: mac('', { unAppID: 3420702832 }) }).props.children.props.children.length > 4,+ 'a mac shortcut still gets the full panel');+ t.ok(P({ details: mac('', { strCompatToolName: 'notproton' }) }).props.children.props.children.length > 4,+ 'a mac build with a tool pinned still gets the full panel');++ const ARCH = '/usr/bin/arch -arm64 -x86_64 -e "DYLD_INSERT_LIBRARIES=/Users/x/Library/Application Support/a.dylib"' ++ ' -e NP_PAD_MODE=hid -e MTL_HUD_ENABLED=1 %command% -novid';+ const NEW = '/Users/someone/.notproton/np-native NP_PAD_MODE=hid MTL_HUD_ENABLED=1 %command% -novid';+ for (const [name, o] of [['arch', ARCH], ['np-native', NEW]]) {+ t.ok(nrow(o, 'Metal HUD').props.checked === true, `${name}: the HUD reads from -e/VAR pairs`);+ t.ok(nrow(o, 'Controller layer').props.selectedOption === 'hid', `${name}: the controller layer reads hid`);+ written.length = 0;+ nrow(o, 'Controller layer').props.onChange({ data: 'gc' });+ t.ok(last() === NAT + ' NP_PAD_MODE=gc MTL_HUD_ENABLED=1 %command% -novid',+ `${name}: rewritten under the launcher, -novid kept (${last()})`);+ written.length = 0;+ nrow(o, 'Mode').props.onChange({ data: 'adaptive' });+ t.ok(last() === NAT + ' NP_PAD_MODE=hid MTL_HUD_ENABLED=1 NOTPROTON_FRAMEGEN=adaptive %command% -novid',+ `${name}: a new variable goes before %command% (${last()})`);+ written.length = 0;+ nrow(o, 'Metal HUD').props.onChange(false);+ t.ok(last() === NAT + ' NP_PAD_MODE=hid %command% -novid', `${name}: turning the HUD off drops it (${last()})`);+ }+ for (const [name, o] of [['arch', ARCH], ['np-native', NEW]]) {+ written.length = 0;+ nrow(o, 'Controller layer').props.onChange({ data: '' });+ t.ok(last() === NAT + ' MTL_HUD_ENABLED=1 %command% -novid',+ `${name}: Automatic from hid drops NP_PAD_MODE, keeps np-native and -novid (${last()})`);+ }+ written.length = 0;+ nrow(NAT + ' NP_PAD_MODE=gc %command% -novid +map x', 'Controller layer').props.onChange({ data: '' });+ t.ok(last() === NAT + ' %command% -novid +map x', `Automatic as the last variable keeps the launcher (${last()})`);+ written.length = 0;+ nrow('/x/.notproton/np-native MTL_HUD_ENABLED=1 %command% -novid', 'Metal HUD').props.onChange(false);+ t.ok(last() === NAT + ' %command% -novid', `no variable left keeps the launcher and the arguments (${last()})`);+ written.length = 0;+ nrow('', 'Controller layer').props.onChange({ data: 'off' });+ t.ok(last() === NAT + ' NP_PAD_MODE=off %command%', `empty options get the launcher (${last()})`);+ written.length = 0;+ nrow('-novid', 'Mode').props.onChange({ data: '3' });+ t.ok(last() === NAT + ' NOTPROTON_FRAMEGEN=3 %command% -novid', `bare game arguments follow %command% (${last()})`);++ // Native defaults come from np-native's confs, the per-app one first.+ globalThis.MSCXFx = { g: {}, a: {}, e: {}, d: { NOTPROTON_FRAMEGEN_UI: '1', NOTPROTON_FRAMEGEN_FALLBACK: '1' },+ ng: { MTL_HUD_ENABLED: '1', NP_PAD_MODE: 'hid', NOTPROTON_FRAMEGEN: 'adaptive' },+ na: { 287700: { NP_PAD_MODE: 'gc' } }, h: '/Users/me' };+ t.ok(nrow('', 'Metal HUD').props.checked === true, 'native-default.conf reads the HUD as on');+ t.ok(nrow('', 'Mode').props.selectedOption === 'adaptive', 'native-default.conf sets the mode');+ t.ok(nrow('', 'Controller layer').props.selectedOption === 'gc', 'the per-app native conf beats the default');+ t.ok(nrow('', FGT.ui).props.checked === true, 'the shim defaults hold for native games');+ written.length = 0;+ nrow('', 'Metal HUD').props.onChange(false);+ t.ok(last() === '/Users/me/.notproton/np-native MTL_HUD_ENABLED=0 %command%',+ `turning a native default off writes 0 under the home from the page (${last()})`);+ written.length = 0;+ nrow('NP_PAD_MODE=hid %command%', 'Controller layer').props.onChange({ data: 'gc' });+ t.ok(last() === '/Users/me/.notproton/np-native %command%', `the conf's own layer drops the override (${last()})`);+ // Without a home from the page the launcher already there is reused, and nothing is guessed.+ globalThis.MSCXFx = { g: {}, a: {}, e: {}, d: {} };+ written.length = 0;+ nrow(NEW, 'Mode').props.onChange({ data: '2' });+ t.ok(last() === '/Users/someone/.notproton/np-native NP_PAD_MODE=hid MTL_HUD_ENABLED=1 NOTPROTON_FRAMEGEN=2 %command% -novid',+ `no home: the existing launcher path is kept (${last()})`);+ written.length = 0;+ nrow(ARCH, 'Mode').props.onChange({ data: '2' });+ t.ok(written.length === 0, 'no home and no launcher: nothing is written');delete globalThis.MSCXFx;const css = nodes('').filter(x => x.type === 'style');diff --git a/dylib/tests/panel-behavior/effective.js b/dylib/tests/panel-behavior/effective.jsindex 51fcc33..ea86313 100644--- a/dylib/tests/panel-behavior/effective.js+++ b/dylib/tests/panel-behavior/effective.js@@ -12,7 +12,9 @@ const { panel, walk, details, runner, FORMS } = require('./harness');const emit = process.argv[2];if (!emit) { console.error('usage: effective.js <emit>'); process.exit(2); }-const home = fs.mkdtempSync(path.join(os.tmpdir(), 'np-effective-'));+// A quote and a space in the home have to reach the page escaped and the launch options quoted.+const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'np-effective-'));+const home = path.join(tmp, 'home "q" x');const np = path.join(home, 'Library', 'Application Support', 'notproton');const put = (rel, text) => {fs.mkdirSync(path.dirname(path.join(np, rel)), { recursive: true });@@ -24,8 +26,14 @@ put('gamefixes/default.conf','# Rosetta hides AVX/AVX2 unless asked; many games quit without it.\n' +'ROSETTA_ADVERTISE_AVX=1\n' +'# Exposes DLSS through MetalFX (D3DMetal); only takes effect when DLSS is switched on in the game.\n' +- 'D3DM_ENABLE_METALFX=1\n');+ 'D3DM_ENABLE_METALFX=1\n' ++ 'FRAMEGEN=1\nFRAMEGEN_QUALITY=quality\nFRAMEGEN_UI=0\nFRAMEGEN_FALLBACK=0\nFRAMEGEN_ENGINE=metalfx\n');put('gamefixes-default/1888930.conf', 'ROSETTA_ADVERTISE_AVX=1\n');+put('gamefixes/1778821.conf', 'FRAMEGEN=0\n');+// np-native's own confs: raw variable names, export and quotes allowed.+put('gamefixes/native-default.conf', '# native\nexport MTL_HUD_ENABLED=1\nNP_PAD_MODE = "hid"\n' ++ 'NOTPROTON_FRAMEGEN=3\nFRAMEGEN=2\nNOTPROTON_RETINA=1\n');+put('gamefixes/native/1778820.conf', "NP_PAD_MODE='gc'\nNOTPROTON_FRAMEGEN_ENGINE=metalfx\n");// The first tool is the default one, and its name runs past the 16 characters a value may.put('tools','notproton-winecx-11.17\twinecx-11.17\trosetta\tWineCX 11.17 (msync, D3DMetal)\n' +@@ -50,19 +58,30 @@ try {vm.runInContext(tail, ctx);fx = ctx.MSCXFx;} finally {- fs.rmSync(home, { recursive: true, force: true });+ fs.rmSync(tmp, { recursive: true, force: true });}t0.ok(fx !== undefined, 'the defaults survive the source map comment the chunk ends in');t0.ok(!!(fx && fx.e && fx.e['notproton-winecx-11.17'] && fx.e['notproton-winecx-11.17'].WINEMSYNC === '1'),'a tool name longer than a value still reaches the engine map');t0.ok(!!(fx && fx.e && fx.e[''] && fx.e[''].WINEMSYNC === '1'), 'the default tool stands in for an unpinned game');+t0.ok(!!fx && fx.h === home, `the home reaches the page escaped (${fx && JSON.stringify(fx.h)})`);+t0.ok(!!fx && JSON.stringify(fx.g).includes('"NOTPROTON_FRAMEGEN":"1"') &&+ fx.g.NOTPROTON_FRAMEGEN_QUALITY === 'quality' && fx.g.NOTPROTON_FRAMEGEN_UI === '0' &&+ fx.g.NOTPROTON_FRAMEGEN_FALLBACK === '0' && fx.g.NOTPROTON_FRAMEGEN_ENGINE === 'metalfx',+ 'the FRAMEGEN conf keys map to their variables');+t0.ok(!!fx && fx.d.NOTPROTON_FRAMEGEN_UI === '1' && fx.d.NOTPROTON_FRAMEGEN_FALLBACK === '1',+ 'Protect UI and the fast-motion fallback default on');+t0.ok(!!fx && JSON.stringify(fx.ng) === '{"MTL_HUD_ENABLED":"1","NP_PAD_MODE":"hid","NOTPROTON_FRAMEGEN":"3"}',+ `native-default.conf is read the way np-native reads it (${fx && JSON.stringify(fx.ng)})`);+t0.ok(!!fx && JSON.stringify(fx.na) === '{"1778820":{"NP_PAD_MODE":"gc","NOTPROTON_FRAMEGEN_ENGINE":"metalfx"}}',+ `native/<appid>.conf lands per app (${fx && JSON.stringify(fx.na)})`);failed += t0.failed;const LABELS = ['Metal HUD', 'DLSS', 'Advertise AVX2 to Rosetta', 'MSync', 'High Resolution','Let games read controllers directly'];globalThis.MSCXFx = fx;for (const form of Object.keys(FORMS)) {- const { render: P } = panel(emit, form);+ const { render: P, written } = panel(emit, form);const t = runner(form);const rows = over => walk(P({ details: details('', Object.assign({ unAppID: 1778820 }, over)) })).filter(x => x.type === 'Toggle');@@ -74,6 +93,28 @@ for (const form of Object.keys(FORMS)) {'the default tool named outright reads MSync as on');t.ok(!checked({ strCompatToolName: 'notproton-winehq' }).includes('MSync'),'a tool without msync reads MSync as off');+ // Frame generation as the confs set it up.+ const fg = (id, o, os) => walk(P({ details: details(o || '', Object.assign({ unAppID: id }, os || {})) }));+ const lab = (ns, l) => ns.find(x => x.props.label === l);+ let ns = fg(1778820);+ t.ok(lab(ns, 'Mode').props.selectedOption === '2' && lab(ns, 'Quality').props.selectedOption === 'quality' &&+ lab(ns, 'Engine').props.selectedOption === 'metalfx' &&+ lab(ns, 'Protect UI (keeps static HUD and menus sharp)').props.checked === false &&+ lab(ns, 'Fast-motion fallback (skips frames that would smear)').props.checked === false,+ 'the global FRAMEGEN keys show through, 1 as 2x');+ t.ok(lab(fg(1778821), 'Mode').props.selectedOption === '0' && !lab(fg(1778821), 'Quality'),+ 'a per-app FRAMEGEN=0 turns it off and hides the rest');+ // A native build reads np-native's confs and writes under the escaped home.+ const mac = { vecPlatforms: ['osx'], strCompatToolName: '' };+ ns = fg(1778820, '', mac);+ t.ok(lab(ns, 'Metal HUD').props.checked === true && lab(ns, 'Mode').props.selectedOption === '3' &&+ lab(ns, 'Controller layer').props.selectedOption === 'gc' && lab(ns, 'Engine').props.selectedOption === 'metalfx',+ 'a native game shows the native confs, per app over default');+ t.ok(lab(fg(999, '', mac), 'Controller layer').props.selectedOption === 'hid', 'another native game gets the default');+ written.length = 0;+ lab(fg(999, '-novid', mac), 'Metal HUD').props.onChange(false);+ const want = "'" + home.replace(/'/g, "'\\''") + "/.notproton/np-native' MTL_HUD_ENABLED=0 %command% -novid";+ t.ok(written.length === 1 && written[0].opts === want, `the launcher path is the user's home (${written[0] && written[0].opts})`);failed += t.failed;}delete globalThis.MSCXFx;