Skip to content

Play your own Switch games on iPhone/iPad — one-click macOS app, no terminal. | 把 Switch 游戏装进 iPhone:图形界面一键构建,不用命令行。Bring your own game.

Patch queue: drop 0036, the layout editor

v0lumehi28382a94bc58
diff --git a/patches/0036-the-layout-editor-long-press-the-layout-button-a.patch b/patches/0036-the-layout-editor-long-press-the-layout-button-a.patch
deleted file mode 100644
index 452651fd..00000000
--- a/patches/0036-the-layout-editor-long-press-the-layout-button-a.patch
+++ /dev/null
@@ -1,264 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: LNPANDY <[email protected]>
-Date: Sun, 1 Nov 2026 00:59:17 +0800
-Subject: [PATCH] The layout editor: long-press the layout button and drag
- every control where it fits
-MIME-Version: 1.0
-Content-Type: text/plain; charset=UTF-8
-Content-Transfer-Encoding: 8bit
-
-Each game is its own app, so its layout is its own: a long press on the layout button opens the editor, where every movable control (left stick, A, B, X, Y each on their own, D-pad, shoulders, L3 / R3, − / +) shows a dashed outline to drag anywhere on screen; a one-tap reset at the bottom centre or a long press on the button restores every position. Positions are kept in NSUserDefaults per game as screen fractions, and a control without one sits exactly where the built-in layout puts it. The drawn key, the touch hit-test and the editor's grab read the same place (facePos: and the group anchors), so a moved key cannot trigger at its old spot. The editor holds no game input and the choice survives updates like the layout choice does.
-
-Upstream-Status: pending
-Reason: Players ask to place the virtual controls themselves; per-key face buttons, a one-tap reset, and the touch hit-test reading the drawn position (owner-verified on a device)
-Issue: LNPANDY/NX2Apple (owner request, virtual pad customization)
----
- dm/ios/Sources/DmGamepad.m | 145 ++++++++++++++++++++++++++++++++++---
- 1 file changed, 133 insertions(+), 12 deletions(-)
-
-diff --git a/dm/ios/Sources/DmGamepad.m b/dm/ios/Sources/DmGamepad.m
-index 3747fc9..38c4ebf 100644
---- a/dm/ios/Sources/DmGamepad.m
-+++ b/dm/ios/Sources/DmGamepad.m
-@@ -10,6 +10,9 @@
- // then in 3D the right stick for a touch in the right third.
- // Everything hugs the edges and corners to leave the picture room; controls sit over the picture, one CAShapeLayer each: a press only swaps the fill, a stick only moves its knob, nothing redraws the whole screen.
- // Touches no control takes (in 3D, those outside the right third) go to the game's touch screen (pushGame; Super Mario Galaxy's pointer in handheld mode).
-+// The layout editor: long-press the layout button (half a second) and every movable control becomes a dashed outline to drag anywhere; tapping the button
-+// again saves, long-pressing it inside the editor resets every position. Positions are kept in NSUserDefaults per game as screen fractions (each game is
-+// its own app, so its own layout), and a control without one sits exactly where the built-in layout puts it. The editor holds no game input.
- // The virtual gamepad (layout button included) hides while a physical controller is connected and comes back when it is removed; meanwhile every touch goes to the game. Physical controllers keep every button (D-pad and right stick included) and map by position: bottom = B, right = A, left = Y, top = X (same positions as on a Switch controller); a Nintendo pad maps by its labels (pad_apple.h).
- // Each physical controller is a player of its own (local co-op), as on the Mac: the first one connected is player 1, together with the touch gamepad, the next player 2, and so on up to 8; see "Physical controllers" below.
- // Shaking the phone shakes the controller (DM_BTN_SHAKE: its six-axis sensor, hle_hid.c), whichever controls are in use; see "Shaking the phone" below.
-@@ -127,7 +130,18 @@ static const CGFloat
- K_CLICK_X = 102, K_CLICK_R = 17; // L3 / R3: centre from the outer edge (level with ZL / ZR), radius
- static const int k_btns[] = {B_ZL, B_L, B_ZR, B_R, B_MINUS, B_PLUS, B_LS, B_RS}; // keys locked at touch-down (L3 / R3 only in the 3D layout)
- static NSString *const k_layout_key = @"DmPadLayout"; // NSUserDefaults: 0 = 2D, 1 = 3D, 2 = Tap (DM_GAME_PAD_LAYOUT's numbers)
-+static NSString *const k_custom_key = @"DmPadCustom"; // NSUserDefaults: group → [x, y] as fractions of the screen (the layout editor's positions, per game)
- int dm_opmode(void); // hle_oe.c: 0 = handheld
-+static NSString *groupOf(int b) { // the group a key moves with in the layout editor; nil = not movable
-+ switch (b) {
-+ case B_A: return @"A"; case B_B: return @"B"; case B_X: return @"X"; case B_Y: return @"Y";
-+ case B_UP: case B_DOWN: case B_LEFT: case B_RIGHT: return @"dpad";
-+ case B_LS: return @"LS"; case B_RS: return @"RS";
-+ case B_L: return @"L"; case B_ZL: return @"ZL"; case B_R: return @"R"; case B_ZR: return @"ZR";
-+ case B_MINUS: return @"minus"; case B_PLUS: return @"plus";
-+ default: return nil;
-+ }
-+}
-
- @interface DmGamepad : UIView
- @end
-@@ -143,6 +157,11 @@ static void pads_start(void); // Physical controllers, below
- CAShapeLayer *_key[B_N]; CATextLayer *_label[B_N]; // one layer per key
- CAShapeLayer *_ring, *_knob; // the left stick (the right one is not drawn)
- CAShapeLayer *_swap; CATextLayer *_swapLabel; BOOL _swapHeld;
-+ CAShapeLayer *_rst; CATextLayer *_rstLabel; // the editor's one-tap reset (bottom centre)
-+ BOOL _edit; NSString *_editGroup; CGPoint _editGrab; UITouch *_editTouch; // the layout editor: one dragged group at a time
-+ NSDate *_swapDown; // when the layout button went down: a long press opens the editor (or resets inside it)
-+ NSMutableDictionary<NSString *, CAShapeLayer *> *_ghosts; // dashed outlines of the movable groups, visible only while editing
-+ NSMutableDictionary<NSString *, NSArray<NSNumber *> *> *_draft; // the editor's unsaved positions: group → [x, y] in screen fractions
- UIImpactFeedbackGenerator *_touchFeedback; // one short feedback per touch-control press edge
- unsigned _hapticSticks;
- BOOL _stickShown; // the left stick was held at the last refresh
-@@ -192,6 +211,13 @@ static BOOL fullOnly(int b) { return b == B_LS || b == B_RS || b >= B_LEFT; }
- if (names[b]) _label[b] = label(_key[b], names[b]); // the D-pad arms carry no label
- }
- _swap = shape(_controls); _swapLabel = label(_swap, @"");
-+ _rst = shape(_controls); _rst.fillColor = k_ringFill.CGColor; _rst.strokeColor = k_line.CGColor; _rst.lineWidth = 1.5; _rst.hidden = YES;
-+ _rstLabel = label(_rst, @"\u21ba");
-+ _ghosts = [NSMutableDictionary dictionary];
-+ for (NSString *g in @[@"stick", @"A", @"B", @"X", @"Y", @"dpad", @"L", @"ZL", @"R", @"ZR", @"LS", @"RS", @"minus", @"plus"]) {
-+ CAShapeLayer *gh = shape(_controls); gh.fillColor = nil; gh.strokeColor = k_line.CGColor; gh.lineWidth = 1.5;
-+ gh.lineDashPattern = @[@6, @5]; gh.hidden = YES; _ghosts[g] = gh; // the editor's drag handles, one per movable group
-+ }
- NSNumber *saved = [NSUserDefaults.standardUserDefaults objectForKey:k_layout_key];
- int l = saved ? (int)saved.integerValue : dm_profile()->pad_layout;
- if (l == 2 && dm_opmode() != 0) l = 0; // Tap only in handheld mode (env.txt's DM_OPMODE may have changed it)
-@@ -211,9 +237,89 @@ static BOOL fullOnly(int b) { return b == B_LS || b == B_RS || b >= B_LEFT; }
- [CATransaction begin]; [CATransaction setDisableActions:YES];
- for (int b = 0; b < B_N; b++) _key[b].hidden = _tap || (fullOnly(b) && !_full);
- _ring.hidden = _knob.hidden = _tap;
-- _swapLabel.string = _tap ? @"Tap" : _full ? @"3D" : @"2D";
-+ _controls.opacity = _edit ? 0.5 : 1; // the editor dims the controls so its dashed outlines read as handles, not keys
-+ _swapLabel.string = _edit ? @"✓" : _tap ? @"Tap" : _full ? @"3D" : @"2D";
-+ for (NSString *g in _ghosts) [_ghosts[g] setHidden:!_edit];
-+ _rst.hidden = !_edit;
- [CATransaction commit];
- }
-+
-+// ---- The layout editor (see the header) ----
-+- (CGPoint)placed:(CGPoint)fallback group:(NSString *)g { // the group's kept position, falling back to the built-in layout
-+ NSArray<NSNumber *> *p = _draft[g] ?: [NSUserDefaults.standardUserDefaults dictionaryForKey:k_custom_key][g];
-+ if (p.count == 2) return CGPointMake(p[0].doubleValue * self.bounds.size.width, p[1].doubleValue * self.bounds.size.height);
-+ return fallback;
-+}
-+- (CGPoint)groupAnchor:(NSString *)g {
-+ if ([g isEqualToString:@"stick"]) return self.stickHome;
-+ if ([g isEqualToString:@"A"]) return [self facePos:B_A];
-+ if ([g isEqualToString:@"B"]) return [self facePos:B_B];
-+ if ([g isEqualToString:@"X"]) return [self facePos:B_X];
-+ if ([g isEqualToString:@"Y"]) return [self facePos:B_Y];
-+ if ([g isEqualToString:@"face"]) return self.faceCenter;
-+ if ([g isEqualToString:@"dpad"]) return self.dpadCenter;
-+ if ([g isEqualToString:@"L"]) return [self dropCenter:B_L];
-+ if ([g isEqualToString:@"ZL"]) return [self dropCenter:B_ZL];
-+ if ([g isEqualToString:@"R"]) return [self dropCenter:B_R];
-+ if ([g isEqualToString:@"ZR"]) return [self dropCenter:B_ZR];
-+ if ([g isEqualToString:@"LS"]) return [self clickCenter:B_LS];
-+ if ([g isEqualToString:@"RS"]) return [self clickCenter:B_RS];
-+ if ([g isEqualToString:@"minus"]) { CGRect rc = [self pillRect:B_MINUS]; return CGPointMake(CGRectGetMidX(rc), CGRectGetMidY(rc)); }
-+ CGRect rc = [self pillRect:B_PLUS]; return CGPointMake(CGRectGetMidX(rc), CGRectGetMidY(rc));
-+}
-+- (CGFloat)groupR:(NSString *)g {
-+ if ([g isEqualToString:@"stick"]) return [self stickR:0];
-+ if ([g isEqualToString:@"A"] || [g isEqualToString:@"B"] || [g isEqualToString:@"X"] || [g isEqualToString:@"Y"]) return self.faceR;
-+ if ([g isEqualToString:@"face"]) return self.faceR + self.faceGap;
-+ if ([g isEqualToString:@"dpad"]) return self.dpadR + 6 * self.u;
-+ if ([g isEqualToString:@"L"] || [g isEqualToString:@"R"]) return [self dropR:B_L] + 4 * self.u;
-+ if ([g isEqualToString:@"ZL"] || [g isEqualToString:@"ZR"]) return [self dropR:B_ZL] + 4 * self.u;
-+ if ([g isEqualToString:@"LS"] || [g isEqualToString:@"RS"]) return K_CLICK_R * self.u + 4 * self.u;
-+ return K_PILL_H * self.u / 2 + 4 * self.u; // the pills
-+}
-+- (void)openEditor { // long-press on the layout button: drag the controls, tap the button to save and leave, long-press it to reset everything
-+ if (_tap || _edit) return; // the Tap layout has no controls to move
-+ _edit = YES; _draft = [NSMutableDictionary dictionary];
-+ [self reset];
-+ [self applyLayout]; [self setNeedsLayout];
-+}
-+- (void)closeEditor {
-+ _edit = NO;
-+ if (_draft.count) {
-+ NSMutableDictionary *d = [[NSUserDefaults.standardUserDefaults dictionaryForKey:k_custom_key] mutableCopy] ?: [NSMutableDictionary dictionary];
-+ [d addEntriesFromDictionary:_draft]; // a group the editor never touched keeps its saved place
-+ [NSUserDefaults.standardUserDefaults setObject:d forKey:k_custom_key];
-+ }
-+ _draft = nil;
-+ [self reset];
-+ [self applyLayout]; [self setNeedsLayout];
-+}
-+- (void)editDown:(UITouch *)t at:(CGPoint)p {
-+ if ([self inSwap:p]) { [_owner setObject:@(C_SWAP) forKey:t]; _swapDown = [NSDate date]; return; } // tap = save and leave, long press = reset
-+ if (_edit && dist(p, [self rstCentre]) <= K_SWAP_R * self.u * 1.6) { // one-tap reset: every custom position back to the built-in layout, staying in the editor
-+ [NSUserDefaults.standardUserDefaults removeObjectForKey:k_custom_key];
-+ [_draft removeAllObjects]; [self setNeedsLayout]; return;
-+ }
-+ if (_editTouch) return; // one dragged group at a time
-+ NSString *best = nil; CGFloat bd = INFINITY;
-+ for (NSString *g in _ghosts) {
-+ if (_ghosts[g].hidden) continue;
-+ CGFloat d = dist(p, [self groupAnchor:g]);
-+ if (d <= [self groupR:g] * 1.6 && d < bd) { bd = d; best = g; }
-+ }
-+ if (!best) return;
-+ _editTouch = t; _editGroup = best;
-+ CGPoint c = [self groupAnchor:best]; _editGrab = CGPointMake(c.x - p.x, c.y - p.y);
-+}
-+- (void)editMove:(CGPoint)p {
-+ if (!_editGroup) return;
-+ CGPoint c = CGPointMake(p.x + _editGrab.x, p.y + _editGrab.y);
-+ UIEdgeInsets i = self.safeAreaInsets; CGFloat m = 30 * self.u; // the group's centre stays a margin inside the safe area
-+ c.x = fminf(fmaxf(c.x, CGRectGetMinX(self.bounds) + i.left + m), CGRectGetMaxX(self.bounds) - i.right - m);
-+ c.y = fminf(fmaxf(c.y, CGRectGetMinY(self.bounds) + i.top + m), CGRectGetMaxY(self.bounds) - i.bottom - m);
-+ _draft[_editGroup] = @[@(c.x / self.bounds.size.width), @(c.y / self.bounds.size.height)];
-+ [self setNeedsLayout]; // the keys and the outlines follow live
-+}
- - (void)nextLayout { // 2D → 3D (→ Tap in handheld mode) → 2D: release every touch first (no key stays held), save, lay out again
- int l = _tap ? 0 : _full ? (dm_opmode() == 0 ? 2 : 0) : 1;
- [self reset];
-@@ -227,27 +333,29 @@ static BOOL fullOnly(int b) { return b == B_LS || b == B_RS || b >= B_LEFT; }
- - (CGRect)corner { UIEdgeInsets i = self.safeAreaInsets; i.left *= K_CORNER_IN; i.right *= K_CORNER_IN; return UIEdgeInsetsInsetRect(self.bounds, i); } // the rectangle the bottom-corner controls use
- - (CGFloat)u { return MIN(self.bounds.size.height / 430.0, 1.3); } // 1 = 430 points tall (iPhone Pro Max landscape)
- static CGPoint side(CGRect s, int right, CGFloat dx, CGFloat y) { return CGPointMake(right ? CGRectGetMaxX(s) - dx : CGRectGetMinX(s) + dx, y); }
--- (CGPoint)faceCenter { CGRect s = self.corner; CGFloat u = self.u; return side(s, 1, K_FACE_X * u, CGRectGetMaxY(s) - K_PAD_Y * u); }
-+- (CGPoint)faceCenter { CGRect s = self.corner; CGFloat u = self.u; return [self placed:side(s, 1, K_FACE_X * u, CGRectGetMaxY(s) - K_PAD_Y * u) group:@"face"]; }
- - (CGFloat)faceGap { return K_FACE_GAP * self.u; }
- - (CGFloat)faceR { return K_FACE_R * self.u; }
- - (CGPoint)facePos:(int)b { CGPoint c = self.faceCenter; CGFloat g = self.faceGap;
-- switch (b) { case B_A: return CGPointMake(c.x + g, c.y); case B_B: return CGPointMake(c.x, c.y + g); case B_X: return CGPointMake(c.x, c.y - g); default: return CGPointMake(c.x - g, c.y); } }
--- (CGPoint)stickHome { CGRect s = self.corner; return side(s, 0, K_STICK_X * self.u, CGRectGetMaxY(s) - K_PAD_Y * self.u); } // the left stick's ring centre
-+ CGPoint p; switch (b) { case B_A: p = CGPointMake(c.x + g, c.y); break; case B_B: p = CGPointMake(c.x, c.y + g); break; case B_X: p = CGPointMake(c.x, c.y - g); break; default: p = CGPointMake(c.x - g, c.y); }
-+ return [self placed:p group:groupOf(b)]; } // the key's own saved spot wins, the diamond's saved spot is the fallback
-+- (CGPoint)stickHome { CGRect s = self.corner; return [self placed:side(s, 0, K_STICK_X * self.u, CGRectGetMaxY(s) - K_PAD_Y * self.u) group:@"stick"]; } // the left stick's ring centre
- - (CGPoint)stickCentre:(int)i { return i ? _rCentre : self.stickHome; }
- - (CGFloat)stickR:(int)i { return (i ? K_RSTICK_R : K_STICK_R) * self.u; }
- - (BOOL)inRightArea:(CGPoint)p { CGRect b = self.bounds; return p.x >= CGRectGetMaxX(b) - b.size.width * K_RSWIPE; }
--- (CGPoint)dpadCenter { CGRect s = self.corner; CGFloat u = self.u; return side(s, 0, K_LOW_X * u, CGRectGetMaxY(s) - K_LOW_Y * u); }
-+- (CGPoint)dpadCenter { CGRect s = self.corner; CGFloat u = self.u; return [self placed:side(s, 0, K_LOW_X * u, CGRectGetMaxY(s) - K_LOW_Y * u) group:@"dpad"]; }
- - (CGFloat)dpadR { return K_DPAD_R * self.u; }
- static BOOL isDrop(int b) { return b == B_ZL || b == B_L || b == B_ZR || b == B_R; }
- static BOOL isClick(int b) { return b == B_LS || b == B_RS; }
- - (CGPoint)dropCenter:(int)b { CGRect s = self.safe; CGFloat u = self.u; BOOL z = b == B_ZL || b == B_ZR;
-- return side(s, b == B_ZR || b == B_R, (z ? K_ZL_X : K_L_X) * u, CGRectGetMinY(s) + (z ? K_ZL_Y : K_L_Y) * u); }
-+ return [self placed:side(s, b == B_ZR || b == B_R, (z ? K_ZL_X : K_L_X) * u, CGRectGetMinY(s) + (z ? K_ZL_Y : K_L_Y) * u) group:groupOf(b)]; }
- - (CGFloat)dropR:(int)b { return (b == B_ZL || b == B_ZR ? K_ZL_R : K_L_R) * self.u; }
--- (CGPoint)clickCenter:(int)b { CGRect s = self.safe; CGFloat u = self.u; return side(s, b == B_RS, K_CLICK_X * u, CGRectGetMinY(s) + K_ZL_Y * u); }
-+- (CGPoint)clickCenter:(int)b { CGRect s = self.safe; CGFloat u = self.u; return [self placed:side(s, b == B_RS, K_CLICK_X * u, CGRectGetMinY(s) + K_ZL_Y * u) group:groupOf(b)]; }
- - (CGRect)pillRect:(int)b { CGRect s = self.safe; CGFloat u = self.u, w = K_PILL_W * u, h = K_PILL_H * u;
-- CGPoint c = CGPointMake(CGRectGetMidX(s) + (b == B_PLUS ? K_PILL_DX : -K_PILL_DX) * u, CGRectGetMinY(s) + K_PILL_Y * u); // − on the left, + on the right
-+ CGPoint c = [self placed:CGPointMake(CGRectGetMidX(s) + (b == B_PLUS ? K_PILL_DX : -K_PILL_DX) * u, CGRectGetMinY(s) + K_PILL_Y * u) group:groupOf(b)]; // − on the left, + on the right
- return CGRectMake(c.x - w / 2, c.y - h / 2, w, h); }
- - (CGPoint)swapCenter { CGRect s = self.safe; return CGPointMake(CGRectGetMidX(s), CGRectGetMinY(s) + K_PILL_Y * self.u); }
-+- (CGPoint)rstCentre { CGRect s = self.safe; return CGPointMake(CGRectGetMidX(s), CGRectGetMaxY(s) - K_PILL_Y * self.u); } // the editor's reset button: bottom centre, opposite the layout button
-
- static CGFloat dist(CGPoint a, CGPoint b) { return hypot(a.x - b.x, a.y - b.y); }
- - (int)btnAt:(CGPoint)p { // locked keys (tested on touch-down only, then locked)
-@@ -336,13 +444,16 @@ static CGFloat dist(CGPoint a, CGPoint b) { return hypot(a.x - b.x, a.y - b.y);
- BOOL game = NO;
- for (UITouch *t in ts) {
- if (_padOff) { game |= [self gameBegin:t]; continue; }
-- CGPoint p = [t locationInView:self]; int hit = _tap ? -1 : [self btnAt:p];
-+ CGPoint p = [t locationInView:self];
-+ if (_edit) { [self editDown:t at:p]; continue; }
-+ int hit = _tap ? -1 : [self btnAt:p];
- if (hit >= 0) { [_owner setObject:@(C_BTN | (uint64_t)hit << 8) forKey:t]; continue; }
-- if ([self inSwap:p]) { [_owner setObject:@(C_SWAP) forKey:t]; continue; }
-+ if ([self inSwap:p]) { [_owner setObject:@(C_SWAP) forKey:t]; _swapDown = [NSDate date]; continue; }
- if (_tap) { game |= [self gameBegin:t]; continue; }
- // diamond, D-pad, left stick: take the one with the smallest distance / grab radius, if it is <= 1
- CGFloat best = 1; int kind = C_NONE, idx = 0;
-- CGFloat f = dist(p, self.faceCenter) / (self.faceGap + self.faceR * 1.6); if (f <= best) { best = f; kind = C_FACE; }
-+ CGFloat fb = INFINITY; for (int b = B_A; b <= B_Y; b++) fb = fminf(fb, dist(p, [self facePos:b]));
-+ CGFloat f = fb / (self.faceGap + self.faceR * 1.6); if (f <= best) { best = f; kind = C_FACE; }
- if (_full) { CGFloat d = dist(p, self.dpadCenter) / (self.dpadR * K_DPAD_GRAB); if (d < best) { best = d; kind = C_DPAD; } }
- if (!_stick[0]) { CGFloat s = dist(p, self.stickHome) / ([self stickR:0] * K_STICK_GRAB); if (s < best) { best = s; kind = C_STICK; } }
- if (kind == C_NONE && _full && !_stick[1] && [self inRightArea:p]) { kind = C_STICK; idx = 1; _rCentre = p; } // the right stick: centred where the touch lands
-@@ -358,6 +469,7 @@ static CGFloat dist(CGPoint a, CGPoint b) { return hypot(a.x - b.x, a.y - b.y);
- BOOL game = NO;
- for (UITouch *t in ts) {
- uint64_t v = [_owner objectForKey:t].unsignedLongLongValue; int c = (int)(v & 0xff); CGPoint p = [t locationInView:self];
-+ if (t == _editTouch) { [self editMove:p]; continue; }
- if (c == C_FACE) [_faceOf setObject:@([self faceAt:p]) forKey:t];
- else if (c == C_STICK) { _stickNow[v >> 8] = p;
- if ((v >> 8) == 1) { CGFloat d = dist(p, _rCentre), R = [self stickR:1]; // the right stick's centre follows a finger past its radius, so turning back responds at once
-@@ -371,13 +483,20 @@ static CGFloat dist(CGPoint a, CGPoint b) { return hypot(a.x - b.x, a.y - b.y);
- BOOL swap = NO, game = NO;
- for (UITouch *t in ts) {
- uint64_t v = [_owner objectForKey:t].unsignedLongLongValue;
-+ if (t == _editTouch) { _editTouch = nil; _editGroup = nil; continue; }
- if (ended && (v & 0xff) == C_SWAP && [self inSwap:[t locationInView:self]]) swap = YES; // layout button: counts only when released on the button
- if ((v & 0xff) == C_GAME && (v >> 8) < 16) { _game[v >> 8] = nil; game = YES; }
- [_owner removeObjectForKey:t]; [_faceOf removeObjectForKey:t]; for (int i = 0; i < 2; i++) if (t == _stick[i]) _stick[i] = nil;
- }
- if (game) [self pushGame];
- [self recompute];
-- if (swap) [self nextLayout];
-+ if (!swap) return;
-+ BOOL held = _swapDown && -[_swapDown timeIntervalSinceNow] >= 0.5; _swapDown = nil; // the layout button: tap = next layout (or save and leave), long press = the editor (or reset inside it)
-+ if (_edit) {
-+ if (held) { [NSUserDefaults.standardUserDefaults removeObjectForKey:k_custom_key]; [_draft removeAllObjects]; [self setNeedsLayout]; }
-+ else [self closeEditor];
-+ } else if (held) [self openEditor];
-+ else [self nextLayout];
- }
- - (void)touchesEnded:(NSSet<UITouch *> *)ts withEvent:(UIEvent *)e { [self endTouches:ts tapped:YES]; }
- - (void)touchesCancelled:(NSSet<UITouch *> *)ts withEvent:(UIEvent *)e { [self endTouches:ts tapped:NO]; }
-@@ -434,6 +553,8 @@ static void placeLabel(CATextLayer *t, CGPoint c, CGFloat fs) {
- static const struct { int b; CGFloat angle; } arms[] = {{B_UP, 0}, {B_RIGHT, M_PI_2}, {B_DOWN, M_PI}, {B_LEFT, -M_PI_2}}; // the same arm in 90° steps
- for (int i = 0; i < 4; i++) setPath(_key[arms[i].b], armPath(self.dpadCenter, self.dpadR, K_ARM_W * u, K_ARM_IN * u, arms[i].angle, 6 * u));
- CGPoint sc = self.swapCenter; setPath(_swap, circlePath(sc, K_SWAP_R * u)); placeLabel(_swapLabel, sc, 12 * u);
-+ CGPoint rc = [self rstCentre]; setPath(_rst, circlePath(rc, K_SWAP_R * u)); placeLabel(_rstLabel, rc, 12 * u);
-+ if (_edit) for (NSString *g in _ghosts) { CAShapeLayer *gh = _ghosts[g]; if (!gh.hidden) setPath(gh, circlePath([self groupAnchor:g], [self groupR:g])); }
- setPath(_ring, circlePath(self.stickHome, [self stickR:0]));
- CGFloat k = K_KNOB_R * u; _knob.bounds = CGRectMake(0, 0, 2 * k, 2 * k);
- setPath(_knob, circlePath(CGPointMake(k, k), k));
diff --git a/patches/series b/patches/series
index 8f7c2e61..844f985b 100644
--- a/patches/series
+++ b/patches/series
@@ -19,7 +19,6 @@
0032-front-mac-hide-the-pointer-after-a-few-idle-seco.patch
0033-lint-c-test-without-workflow.patch
0034-metal-a-newer-compiler-of-the-recorded-generatio.patch
-0036-the-layout-editor-long-press-the-layout-button-a.patch
0037-totk-1.4.2-frame-step-sites.patch
0039-patch-nso-a-zero-extending-and-of-the-index-is-a.patch
0040-nsp-derived-profile-without-frame-step.patch