forked from Blendman974/faceclaw
Apple Watch: Sound-effects and vibrate settings, build scripts
This commit is contained in:
1 parent
2696f3b76c
commit
6df52021c8
13 files changed
+117
-29
No files matched your search
@@ -7,7 +7,7 @@ struct FaceclawWatchApp: App {
|
||||
|
||||
init() {
|
||||
link = PhoneLink()
|
||||
prefs = WatchPrefs()
|
||||
prefs = WatchPrefs(link: link)
|
||||
// Here rather than in a view: a background launch never builds one.
|
||||
link.start()
|
||||
}
|
||||
|
||||
@@ -171,8 +171,8 @@ final class PadController {
|
||||
let steps = Int(crownRemainder.rounded(.towardZero))
|
||||
guard steps != 0 else { return }
|
||||
crownRemainder -= Double(steps)
|
||||
let clockwiseNext = link.state?.crownClockwiseNext == true
|
||||
let gesture: RingGesture = (steps > 0) == clockwiseNext ? .scrollDown : .scrollUp
|
||||
// Clockwise moves to the previous item.
|
||||
let gesture: RingGesture = steps > 0 ? .scrollUp : .scrollDown
|
||||
guard gestureAllowed(gesture) else { return }
|
||||
// Capped low: a fast twirl otherwise outruns the display. The crown's
|
||||
// own detent haptics are the feedback, so there's no buzz here.
|
||||
|
||||
@@ -115,8 +115,9 @@ struct PhoneState: Equatable {
|
||||
var windows: [WindowEntry] = []
|
||||
var apps: [AppEntry] = []
|
||||
var remoteEnabled = true
|
||||
/** False by default: clockwise moves to the previous item. */
|
||||
var crownClockwiseNext = false
|
||||
/** Settings > Watch on the glasses; WatchPrefs and Haptics say what they do. */
|
||||
var vibrateOnInput = true
|
||||
var soundEffects = false
|
||||
var canUnlock = true
|
||||
var mirrorAssistant = true
|
||||
var assistantAvailable = false
|
||||
@@ -155,7 +156,8 @@ struct PhoneState: Equatable {
|
||||
}
|
||||
state.apps = (o["apps"] as? [[String: Any]] ?? []).map(appEntry)
|
||||
state.remoteEnabled = o["remoteEnabled"] as? Bool ?? true
|
||||
state.crownClockwiseNext = o["crownClockwiseNext"] as? Bool ?? false
|
||||
state.vibrateOnInput = o["vibrateOnInput"] as? Bool ?? true
|
||||
state.soundEffects = o["soundEffects"] as? Bool ?? false
|
||||
state.canUnlock = o["canUnlock"] as? Bool ?? true
|
||||
state.mirrorAssistant = o["mirrorAssistant"] as? Bool ?? true
|
||||
state.assistantAvailable = o["assistantAvailable"] as? Bool ?? false
|
||||
|
||||
@@ -340,20 +340,23 @@ struct StatusScreen: View {
|
||||
|
||||
// MARK: - Settings
|
||||
|
||||
/** Watch-local preferences: feel of the pad and crown. */
|
||||
/** Watch-local preferences: feel of the crown. */
|
||||
struct SettingsScreen: View {
|
||||
@Environment(WatchPrefs.self) private var prefs
|
||||
|
||||
var body: some View {
|
||||
@Bindable var prefs = prefs
|
||||
ScrollView {
|
||||
VStack(spacing: 4) {
|
||||
Toggle("Vibrate on input", isOn: $prefs.haptics)
|
||||
Button {
|
||||
prefs.crownSensitivity = prefs.crownSensitivity.next
|
||||
} label: {
|
||||
RowLabel(title: "Crown sensitivity", detail: prefs.crownSensitivity.rawValue)
|
||||
}
|
||||
Text("Vibration and sound effects are in Settings > Watch on the glasses.")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
.multilineTextAlignment(.center)
|
||||
.padding(.top, 6)
|
||||
Text("To keep the remote open between glances, set Settings > General > Return to Clock > Faceclaw on the watch.")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.secondary)
|
||||
|
||||
@@ -22,33 +22,44 @@ enum CrownSensitivity: String, CaseIterable {
|
||||
}
|
||||
}
|
||||
|
||||
/** Watch-local preferences (nothing here is synced to the phone). */
|
||||
/**
|
||||
Crown sensitivity is the watch's own. Vibration and sound follow Settings > Watch on
|
||||
the glasses, through the mirrored state, which the application context keeps for
|
||||
when the phone is out of reach.
|
||||
*/
|
||||
@MainActor
|
||||
@Observable
|
||||
final class WatchPrefs {
|
||||
/** Buzz on every gesture sent, and tick on crown detents. */
|
||||
var haptics: Bool {
|
||||
didSet { store.set(haptics, forKey: Keys.haptics) }
|
||||
}
|
||||
/** Confirm each gesture sent, and tick on crown detents. */
|
||||
var haptics: Bool { link.state?.vibrateOnInput ?? true }
|
||||
|
||||
/** Give each gesture its own cue, sound included; see Haptics. */
|
||||
var soundEffects: Bool { link.state?.soundEffects ?? false }
|
||||
|
||||
var crownSensitivity: CrownSensitivity {
|
||||
didSet { store.set(crownSensitivity.rawValue, forKey: Keys.crown) }
|
||||
}
|
||||
|
||||
@ObservationIgnored private let link: PhoneLink
|
||||
@ObservationIgnored private let store = UserDefaults.standard
|
||||
|
||||
private enum Keys {
|
||||
static let haptics = "haptics"
|
||||
static let crown = "crownSensitivity"
|
||||
}
|
||||
|
||||
init() {
|
||||
haptics = store.object(forKey: Keys.haptics) as? Bool ?? true
|
||||
init(link: PhoneLink) {
|
||||
self.link = link
|
||||
crownSensitivity = store.string(forKey: Keys.crown).flatMap(CrownSensitivity.init(rawValue:)) ?? .normal
|
||||
}
|
||||
}
|
||||
|
||||
/** The wrist's confirmation of what was sent. */
|
||||
/**
|
||||
The wrist's confirmation of what was sent. watchOS has no call that plays only a
|
||||
vibration or only a sound: every WKHapticType is both, and only the watch's own Silent
|
||||
Mode mutes the sound. So sound effects on means the full set of cues, which vibrate
|
||||
whatever the vibrate setting says, and off means `.click` for everything. Whether
|
||||
`.click` is truly silent is unconfirmed; see notes/apple-watch-followups.md.
|
||||
*/
|
||||
@MainActor
|
||||
struct Haptics {
|
||||
let prefs: WatchPrefs
|
||||
@@ -62,10 +73,28 @@ struct Haptics {
|
||||
/** A reply finished arriving. */
|
||||
func done() { play(.success) }
|
||||
|
||||
/** The phone refused or did not answer; always plays. */
|
||||
func error() { WKInterfaceDevice.current().play(.failure) }
|
||||
|
||||
private func play(_ type: WKHapticType) {
|
||||
if prefs.haptics { WKInterfaceDevice.current().play(type) }
|
||||
/** The phone refused or did not answer; always plays, and never feels like a sent gesture. */
|
||||
func error() {
|
||||
let device = WKInterfaceDevice.current()
|
||||
if prefs.soundEffects {
|
||||
device.play(.failure)
|
||||
return
|
||||
}
|
||||
device.play(.click)
|
||||
Task {
|
||||
try? await Task.sleep(nanoseconds: Self.errorTapGapNanos)
|
||||
device.play(.click)
|
||||
}
|
||||
}
|
||||
|
||||
private func play(_ cue: WKHapticType) {
|
||||
if prefs.soundEffects {
|
||||
WKInterfaceDevice.current().play(cue)
|
||||
} else if prefs.haptics {
|
||||
WKInterfaceDevice.current().play(.click)
|
||||
}
|
||||
}
|
||||
|
||||
/** Apple's documentation asks for at least 100 ms between haptics. */
|
||||
private static let errorTapGapNanos: UInt64 = 150_000_000
|
||||
}
|
||||
@@ -17,7 +17,7 @@ standalone app: without Faceclaw on the iPhone it only tells you to install it.
|
||||
| press and hold | the system menu: Focus app switcher, Voice input, Close window (held until you lift your finger; games that use a long press as a move get it instead) |
|
||||
| tap, then press and hold | the app's context menu |
|
||||
| swipe ↑ ↓ ← → | **spatial navigation**: the launcher moves one app by a row or a column, the settings panel moves between its columns and down its lists, the sidebar moves up and down, Music skips tracks. Right goes *into* things and left comes back *out*. Anywhere without a spatial meaning, up/down scroll, right selects and left goes back. One step per swipe. |
|
||||
| turn the crown | previous / next. Clockwise is previous by default; reverse it in the on-glasses Settings > Watch section. Sensitivity is in the watch's own settings. |
|
||||
| turn the crown | previous / next; clockwise is previous. Don't count on it: on a real watch the crown has triggered watchOS's own actions instead of reaching the app. Sensitivity is in the watch's own settings. |
|
||||
| the Double Tap hand gesture (Series 9, Ultra 2, SE 3 and later, watchOS 11) | select |
|
||||
|
||||
Swipe up from the bottom edge to reveal the buttons, and down from them to hide them:
|
||||
@@ -32,7 +32,8 @@ Swipe up from the bottom edge to reveal the buttons, and down from them to hide
|
||||
- **Status** — connection, display on/off, lock/unlock, whether Faceclaw is
|
||||
answering on the iPhone, and the watch's settings.
|
||||
|
||||
Phone-side switches live in Faceclaw's Settings > Watch. While the glasses display
|
||||
Phone-side switches live in Faceclaw's Settings > Watch, including vibration and
|
||||
sound effects. While the glasses display
|
||||
is off, a double-tap wakes it and a tap or hold shows the Glanceboard; other gestures
|
||||
do nothing. The watch buzzes differently when the phone refuses or doesn't answer a
|
||||
gesture, and the pill at the bottom says why.
|
||||
@@ -46,6 +47,10 @@ These come from what watchOS allows apps to do:
|
||||
|
||||
- **No two-finger gestures.** SwiftUI on watchOS only reports one finger.
|
||||
- **No side buttons.** The crown press and side button belong to the system.
|
||||
- **Vibration and sound come as a pair.** watchOS has no call that plays only one, and
|
||||
only the watch's own Silent Mode mutes the sound. With sound effects off, every input
|
||||
gets a light tap rather than its own cue; with them on, inputs vibrate even if
|
||||
Vibrate on input is off.
|
||||
- **The display can't be kept on.** To keep the remote open between glances, set
|
||||
Settings > General > Return to Clock > Faceclaw on the watch to a longer time.
|
||||
- **The tap that wakes the display does nothing.** The system consumes it, and an
|
||||
@@ -69,6 +74,7 @@ The watch app is its own Xcode project, so it can be opened and previewed alone:
|
||||
./build_apple_watch.sh # simulator build, no signing
|
||||
./build_apple_watch.sh --device # signed build for a real watch
|
||||
./build_apple_watch.sh --install # as --device, then installs on the paired watch
|
||||
npm run install:apple-watch # the same as --install
|
||||
```
|
||||
|
||||
**It only works with a phone app that embeds it.** The system links the two apps
|
||||
|
||||
Reference in new issue
Block a user