Skip to content

Commit 1608a25

Browse files
authored
Merge pull request #552 from insertfloppy/upstream/iphone-mouse
2 parents fc5e7cb + 1668bfa commit 1608a25

4 files changed

Lines changed: 53 additions & 40 deletions

File tree

‎app/Madeira/HardwareInput.swift‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,9 @@ final class HardwareInput: ObservableObject {
707707
/// and ignores it. No API reports this, so the idiom is the detection.
708708
static var pointerLockAvailable: Bool { lockEnabled && UIDevice.current.userInterfaceIdiom != .phone }
709709

710+
/// iPhone: the mouse arrives only through AssistiveTouch.
711+
static var isPhone: Bool { UIDevice.current.userInterfaceIdiom == .phone }
712+
710713
/// The desktop session (explorer on a virtual desktop). Read per use: the
711714
/// app sets MADEIRA_DESKTOP for each launch.
712715
static var desktopMode: Bool {
@@ -1031,7 +1034,10 @@ final class HardwareInput: ObservableObject {
10311034
installTouchObserver()
10321035
let base = computeBaseFocus()
10331036
let keyboard = base && !typingElsewhere() && !libraryTypingOwnsKeys
1034-
let over = hoverSeen ? pointerOver : clickFocus.onGame
1037+
// iPhone: the AssistiveTouch pointer's hover ends whenever it stops
1038+
// against a screen edge, while GCMouse deltas keep coming; following
1039+
// hover there dropped mouse-look at every edge. Clicks decide instead.
1040+
let over = hoverSeen && !Self.isPhone ? pointerOver : clickFocus.onGame
10351041
let mouse = base && (!Self.focusEnabled || pointerLocked || over || !gameButtons.isEmpty)
10361042
baseFocused = base
10371043
updateButtonPolling(active: Self.mouseRoutingEnabled && appActive && mouseConnected)
@@ -1113,7 +1119,7 @@ final class HardwareInput: ObservableObject {
11131119
guard Self.enabled, let game = MetalBackedView.keyboardTarget else { return }
11141120
let onGame = t.view.map { $0.isDescendant(of: game) } ?? false
11151121
clickFocus.touchBegan(onGame: onGame, at: CACurrentMediaTime())
1116-
if !hoverSeen { refreshFocus(onGame ? "tap on the game view" : "tap elsewhere") }
1122+
if !hoverSeen || Self.isPhone { refreshFocus(onGame ? "tap on the game view" : "tap elsewhere") }
11171123
}
11181124

11191125
// MARK: - keyboard
@@ -2659,8 +2665,7 @@ struct HardwareInputSettings: View {
26592665
/// device is routed through AssistiveTouch.
26602666
private var hint: some View {
26612667
HStack(alignment: .top, spacing: 8) {
2662-
Text("Mouse detected. iPhone needs AssistiveTouch: "
2663-
+ "Settings > Accessibility > Touch > AssistiveTouch > On, then Devices")
2668+
Text("Using a mouse? Turn on AssistiveTouch (Settings > Accessibility > Touch), then reopen Madeira.")
26642669
.font(.system(size: 12))
26652670
.foregroundColor(.secondary)
26662671
.fixedSize(horizontal: false, vertical: true)

‎app/Madeira/Library.swift‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5154,6 +5154,12 @@ struct LibraryPointerSettings: View {
51545154
Text(input.touchMode ? L("Tap the screen to position and click. Hold and move to drag. Two fingers: right click or scroll.")
51555155
: (input.relative ? L("Drag to send relative mouse movement for mouse-look. Tap to click.") : L("Drag the pointer like a trackpad. Tap to click.")))
51565156
.font(.caption).foregroundStyle(.secondary)
5157+
// A Bluetooth or USB mouse does nothing on iPhone until AssistiveTouch
5158+
// is on (iOS routes pointer devices only through it); nothing says so.
5159+
if UIDevice.current.userInterfaceIdiom == .phone {
5160+
Text("Using a mouse? Turn on AssistiveTouch (Settings > Accessibility > Touch), then reopen Madeira.")
5161+
.font(.caption).foregroundStyle(.secondary)
5162+
}
51575163
LabeledContent("Touch sensitivity") {
51585164
Slider(value: input.relative ? $input.sensRel : $input.sensAbs, in: 0.1...8)
51595165
}

‎app/Madeira/Localizable.xcstrings‎

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -12037,40 +12037,6 @@
1203712037
}
1203812038
}
1203912039
},
12040-
"Mouse detected. iPhone needs AssistiveTouch: ": {
12041-
"localizations": {
12042-
"de": {
12043-
"stringUnit": {
12044-
"state": "translated",
12045-
"value": "Maus erkannt. Das iPhone braucht AssistiveTouch: "
12046-
}
12047-
},
12048-
"es": {
12049-
"stringUnit": {
12050-
"state": "translated",
12051-
"value": "Ratón detectado. El iPhone necesita AssistiveTouch: "
12052-
}
12053-
},
12054-
"ko": {
12055-
"stringUnit": {
12056-
"state": "translated",
12057-
"value": "마우스가 감지되었습니다. iPhone에서는 AssistiveTouch가 필요합니다: "
12058-
}
12059-
},
12060-
"pt-BR": {
12061-
"stringUnit": {
12062-
"state": "translated",
12063-
"value": "Mouse detectado. O iPhone precisa do AssistiveTouch: "
12064-
}
12065-
},
12066-
"ru": {
12067-
"stringUnit": {
12068-
"state": "translated",
12069-
"value": "Обнаружена мышь. На iPhone нужен AssistiveTouch: "
12070-
}
12071-
}
12072-
}
12073-
},
1207412040
"Move to": {
1207512041
"localizations": {
1207612042
"de": {
@@ -23631,6 +23597,40 @@
2363123597
}
2363223598
}
2363323599
},
23600+
"Using a mouse? Turn on AssistiveTouch (Settings > Accessibility > Touch), then reopen Madeira.": {
23601+
"localizations": {
23602+
"de": {
23603+
"stringUnit": {
23604+
"state": "translated",
23605+
"value": "Maus? AssistiveTouch einschalten (Einstellungen > Bedienungshilfen > Tippen), dann Madeira neu öffnen."
23606+
}
23607+
},
23608+
"es": {
23609+
"stringUnit": {
23610+
"state": "translated",
23611+
"value": "¿Usas un ratón? Activa AssistiveTouch (Ajustes > Accesibilidad > Tocar) y vuelve a abrir Madeira."
23612+
}
23613+
},
23614+
"ko": {
23615+
"stringUnit": {
23616+
"state": "translated",
23617+
"value": "마우스를 쓰나요? AssistiveTouch를 켠 뒤(설정 > 손쉬운 사용 > 터치) Madeira를 다시 여세요."
23618+
}
23619+
},
23620+
"pt-BR": {
23621+
"stringUnit": {
23622+
"state": "translated",
23623+
"value": "Usando um mouse? Ative o AssistiveTouch (Ajustes > Acessibilidade > Toque) e abra o Madeira de novo."
23624+
}
23625+
},
23626+
"ru": {
23627+
"stringUnit": {
23628+
"state": "translated",
23629+
"value": "Мышь? Включите AssistiveTouch (Настройки > Универсальный доступ > Касание) и снова откройте Madeira."
23630+
}
23631+
}
23632+
}
23633+
},
2363423634
"Valley of the Ancient (UE5)": {
2363523635
"localizations": {
2363623636
"de": {

‎docs/KEYBOARD_MOUSE.md‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ doing in it. Input reaches the program only while it has focus:
4545
- **Keyboard:** no other text input is first responder, for example a text
4646
field in the app. The game view's own text bridge counts as the program's.
4747
- **Mouse:** the pointer is over the game view (iPad, where UIKit reports the
48-
pointer's position); or, where it does not (iPhone AssistiveTouch), the last
49-
click or tap in the app's window landed on the game view; or pointer lock is
48+
pointer's position); or, on iPhone (AssistiveTouch), the last click or tap in
49+
the app's window landed on the game view. iPhone ignores hover for focus even
50+
when AssistiveTouch reports it: its hover ends whenever the pointer stops at a
51+
screen edge while GCMouse deltas keep coming, which dropped mouse-look there; or pointer lock is
5052
on; or a button that went down on the game view is still held (a drag that
5153
leaves the view keeps the mouse until the button is released).
5254
- **Right stick controls mouse:** the "always required" part.

0 commit comments

Comments
 (0)