Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.
Swift apple-siliconcustom-formathomebrewiosipaipadipadosiphonemetalnative-portnintendo-switchnxnativeromfsswitch-games
front_mac: hide the pointer after a few idle seconds over the game
v0lumehiad679dac020c
diff --git a/dm/host/front_mac.m b/dm/host/front_mac.mindex 99c18f7d..e73472fb 100644--- a/dm/host/front_mac.m+++ b/dm/host/front_mac.m@@ -1185,6 +1185,22 @@ void front_run(void (*guest)(void)) {[NSNotificationCenter.defaultCenter addObserverForName:nm object:win queue:nil usingBlock:^(NSNotification *n) { (void)n; want = 0; }]; // the player's own toggle (ours already cleared it)dispatch_async(dispatch_get_main_queue(), enter);}+ // The pointer hides after DM_CURSOR_HIDE seconds (3 by default, 0 keeps it) without movement over the game, and comes back with the next movement, click or scroll. macOS+ // hides it only for a game that asks (a game window does not, and a pointer left over a fullscreen game stays on the picture); it is also shown whenever the window is+ // not key or the pointer is outside the game view, so the title bar and other windows keep theirs+ const char *ch = getenv("DM_CURSOR_HIDE"); double idle = ch && *ch ? atof(ch) : 3.0;+ if (idle > 0) {+ win.acceptsMouseMovedEvents = YES;+ __block double last = CACurrentMediaTime(); __block int hidden = 0;+ void (^show)(void) = ^{ if (hidden) { hidden = 0; [NSCursor unhide]; } };+ [NSEvent addLocalMonitorForEventsMatchingMask:NSEventMaskMouseMoved | NSEventMaskLeftMouseDragged | NSEventMaskRightMouseDragged | NSEventMaskOtherMouseDragged |+ NSEventMaskLeftMouseDown | NSEventMaskRightMouseDown | NSEventMaskOtherMouseDown | NSEventMaskScrollWheel handler:^NSEvent *(NSEvent *e) { last = CACurrentMediaTime(); show(); return e; }];+ [NSTimer scheduledTimerWithTimeInterval:0.25 repeats:YES block:^(NSTimer *t) {+ (void)t; NSView *cv = win.contentView;+ int over = win.isKeyWindow && NSApp.isActive && NSPointInRect([cv convertPoint:win.mouseLocationOutsideOfEventStream fromView:nil], cv.bounds);+ if (hidden && !over) show();+ else if (!hidden && over && CACurrentMediaTime() - last >= idle) { hidden = 1; [NSCursor hide]; } }];+ }for (NSNotificationName nm in @[GCControllerDidConnectNotification, GCControllerDidDisconnectNotification])[NSNotificationCenter.defaultCenter addObserverForName:nm object:nil queue:NSOperationQueue.mainQueue usingBlock:^(NSNotification *n) {GCController *c = n.object; int conn = n.name == GCControllerDidConnectNotification;diff --git a/docs/agents/symptoms.md b/docs/agents/symptoms.mdindex 25a662fe..e4523585 100644--- a/docs/agents/symptoms.md+++ b/docs/agents/symptoms.md@@ -312,6 +312,7 @@ One line per symptom in the [subsystem references](../reference/): what you see- asked for 60 Hz, the system fires the display link on every third refresh of a 165 Hz screen, 55 Hz, so games paced by it ran at 55 fps (27.5 at 30). → [Virtual 60 Hz ticks on screens that are not a multiple of 60](../reference/frame-rate.md#virtual-60-hz-ticks-on-screens-that-are-not-a-multiple-of-60)- virtual ticks keep the average, but a frame still stays up two or three refreshes in turn (13.9 / 20.8 ms at 144 Hz), and Apple's HUD showed the frame interval jumping between them. → [Fullscreen switches the screen to a rate the frame rate divides](../reference/frame-rate.md#fullscreen-switches-the-screen-to-a-rate-the-frame-rate-divides)- a Mac game started with `DM_FULLSCREEN=1` from an app that is itself in fullscreen (the launcher's console mode) came up as a window. The reporter: "using a full screen app to launch another full-screen app will fail, it will automatically switch to windowed mode". → [A game opened from a fullscreen app stays a window](../reference/frame-rate.md#a-game-opened-from-a-fullscreen-app-stays-a-window)+- the mouse pointer stayed on the picture of a Mac game, in a window and in fullscreen, until it was moved to a screen corner. → [The pointer stays on a Mac game](../reference/frame-rate.md#the-pointer-stays-on-a-mac-game)- on a ProMotion built-in screen, only in fullscreen, the frame step went 1 → 2 → 3 vsyncs on frames costing 0.1–0.6 vsyncs (`3 late frames; cost 0.32 vsyncs`) and the game presented 15 frames a second; a window, or the screen set to a fixed 60 Hz, did not do it. The `DM_NVN_TSV` rows show presents shown one 120 Hz refresh late (`@pres_at_ms` − `@link_target_ms` = 8.3 ms) with a skipped tick after each (`@link_gap_ms` 33 ms), and `@link_lead_ms` about 16 ms against about 50 ms in a window. → [Frame latency 2 for the display link in fullscreen](../reference/frame-rate.md#frame-latency-2-for-the-display-link-in-fullscreen)- autorelease work takes a measurable share of replay time, with temporary arena-buffer ownership traffic a few times per draw. → [Arena buffer ownership on allocation](../reference/frame-rate.md#arena-buffer-ownership-on-allocation)- the submit thread waits on the texture / sampler registry lock while a lower-priority registration thread is preempted holding it. → [Registry lock priority inheritance](../reference/frame-rate.md#registry-lock-priority-inheritance)diff --git a/docs/env_switches.tsv b/docs/env_switches.tsvindex 6993f8dc..c475d8ed 100644--- a/docs/env_switches.tsv+++ b/docs/env_switches.tsv@@ -20,6 +20,7 @@ DM_CHEATS_WINDOW switch `1` opens the Mac Cheats panel beside the game from theDM_COPY_GAME_RESOURCES switch `NO` skips the Xcode build phase that copies the game's resources into the app (`stage_resources.sh`, on by default); `build_ipa.sh` sets it for its unsigned build, which packs them itselfDM_COPY_ROMFS switch `NO` keeps the game files out of the app, in the Xcode build phase (`stage_resources.sh`) and in the unsigned IPA of `build_ipa.sh` (on by default): `main.m` takes the validated `Documents/romfs.img` copied by `scripts/push_romfs.sh`, then a `Documents/romfs` folder; the build writes the image's identity as `romfs.id` into the app, and `main.m` uses only a matching image (`--romfs separate` of the NSP script sets this)DM_CTL diagnostic `=<file>` (Mac): the host polls the file every 100 ms and runs each appended line: button presses, `shot`, `passdump`, `texdump`, `env KEY=VALUE`, `peek`, `memdump`, `drag` and more+DM_CURSOR_HIDE player `=<seconds>` hides the Mac pointer after that many seconds without movement over the game window (3 by default) and shows it again on the next movement, click or scroll; `0` keeps itDM_DBG diagnostic When set, prints the guest's `svcOutputDebugString` text to stderr as `[guest]` linesDM_DBG_AU_FRAMES diagnostic `=<frames>` asks the Mac's Core Audio output for that many frames per callback instead of about 5 ms (1024 reproduces the iOS default that caused crackling)DM_DETCLOCK switch `=<step ns>`: from the first present on, the guest clock advances a fixed step per present instead of following the wall clock, and the random source becomes a fixed-seed stream (replay and test runs)diff --git a/docs/reference/frame-rate.md b/docs/reference/frame-rate.mdindex 19e21153..7a181245 100644--- a/docs/reference/frame-rate.md+++ b/docs/reference/frame-rate.md@@ -210,6 +210,14 @@ Frame pacing: the host's frame step, engine frame limiters, present intervals an- **Found on:** the NX2Apple launcher's console mode (LNPANDY/NX2Apple), no game in particular.- **Not checked:** the refusal itself, and a game started through the real console mode.+### The pointer stays on a Mac game++- **Symptom:** the mouse pointer stayed on the picture of a Mac game, in a window and in fullscreen, until it was moved to a screen corner.+- **Cause:** `front_run` never hid it. macOS hides the pointer only for an app that asks, and a game window is not one.+- **Fix:** `front_mac.m` `front_run` hides it after `DM_CURSOR_HIDE` seconds (3 by default, `0` keeps it) without movement over the game view, and shows it on the next movement, click or scroll (a local event monitor and a 0.25 s timer). It is shown whenever the window is not key or the pointer is outside the game view, so the title bar and other windows keep theirs.+- **Found on:** the NX2Apple launcher's issue #272, no game in particular.+- **Not checked:** not yet run on a game here.+### Frame latency 2 for the display link in fullscreen- **Symptom:** on a ProMotion built-in screen, only in fullscreen, the frame step went 1 → 2 → 3 vsyncs on frames costing 0.1–0.6 vsyncs (`3 late frames; cost 0.32 vsyncs`) and the game presented 15 frames a second; a window, or the screen set to a fixed 60 Hz, did not do it. The `DM_NVN_TSV` rows show presents shown one 120 Hz refresh late (`@pres_at_ms` − `@link_target_ms` = 8.3 ms) with a skipped tick after each (`@link_gap_ms` 33 ms), and `@link_lead_ms` about 16 ms against about 50 ms in a window.