mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-27 07:58:01 +01:00
* iOS keyboard: Apple's key flicks on the docked iPad, and no Number row switch there TestFlight build 147 (iPad Air 11-inch): "On ipad number row is not visible - broken, and flick for symbol is not working either." Settings › Keyboard showed Number row on an iPad, where it does nothing (the iPad keeps Apple's rows), and Hex's keys had none of Apple's key flicks. Docked iPad letter keys now carry Apple's flick characters (iPad mini, iPadOS 26.5 and 27.2, black box): 1 to 0 over row 1, @ # $ & * ( ) ' " over row 2, % - + = / ; : over row 3 in English and German, AZERTY's own in French, and the #+= page's characters over the 123 page's symbols. Pulling a key down slides its character into place as Apple's does; let go past half way (17 pt) and it goes in as a typed character, short of it or pulled back, the letter. The pull keeps its key and never starts a swipe; rollover commits it; Reduce Motion swaps without the slide. Apple's Enable Key Flicks can't be read by an extension, so Settings › Keyboard has Key flicks (on by default), shown on an iPad in place of Number row, which is hidden there. Typing logs: ui flick and insert src flick. Verified: iOS suite on the Studio, 976 tests, 0 failures, 4 skipped; code-shape.py --check passes; iPad mini (26.5, 27.2), Air 11-inch and Pro 13-inch simulators beside Apple's, a pull typing 3 and a short one E, and "Room 415" recorded with flicks. * iOS keyboard: key flicks' drawing and test sit away from the number pad's What: moves drawFlickKey below pixelAligned in KeyboardKeyPlaneView.swift, and testDockedIPadKeysCarryApplesKeyFlicks into KeyboardLayoutTests beside the accent menu tests. Pure moves, no change in code or assertions. Why: #2541 (Hex's number pad) adds its own drawing function and test at the very spots these were added, so the two pull requests conflicted whichever landed second. Apart, both merge into dev in either order. Verified: merges with origin/dev, #2541 and #2542 without conflicts. * iOS keyboard: the key flicks hint string sits beside "Key flicks" in the catalog What: moves "Pull a key down to type the character above its letter" from its alphabetical place to right after "Key flicks". Same key and translation. Why: #2542 adds "Passwords" at that exact alphabetical place, so the two conflicted. Verified: the catalog parses; merges with origin/dev, #2541 and #2542 without conflicts.
64 lines
3.2 KiB
Swift
64 lines
3.2 KiB
Swift
import QuartzCore
|
|
import UIKit
|
|
|
|
/// The full keyboard's touches, as data: one finger's key, where it started and where it is,
|
|
/// and the state that makes a press an accent picker, a slide, a trackpad or a language
|
|
/// swipe. Kept beside the engine, like `SwipedWord`, so the engine's own file stays readable.
|
|
@MainActor
|
|
extension FullKeyboardEngine {
|
|
/// One finger on the keys.
|
|
struct ActiveTouch: Equatable {
|
|
var key: KeyboardKey
|
|
var startPoint: CGPoint
|
|
var point: CGPoint
|
|
/// A character (or space) that already went in because another key went down after it.
|
|
var committed: Bool
|
|
/// The page a 123/ABC press came from; releasing over a character returns there.
|
|
var returnLayer: KeyboardLayer?
|
|
/// A 123, #+= or shift press slid onto this character key: it shows the key's pop-up,
|
|
/// and letting go types it (`slideTarget`), as on Apple's keyboard.
|
|
var slideKey: KeyboardKey?
|
|
/// True once such a press slid onto a character key, so letting go back on the page
|
|
/// key is a slide taken back rather than a tap.
|
|
var hasSlid = false
|
|
/// True once a spacebar press is held `trackpadHoldDelay` (`holdSpace`).
|
|
var isTrackpad = false
|
|
/// True once a spacebar press slides before its hold (`holdSpace`) while it switches
|
|
/// language: letting go far enough along switches instead of typing a space.
|
|
var isLanguageSwipe = false
|
|
/// The trackpad finger's last few moves, for its speed (`TrackpadCursor.speed(along:)`).
|
|
var trackpadPath: [TrackpadCursor.Sample] = []
|
|
/// The text the trackpad moves the cursor through (`TrackpadCursor.State`).
|
|
var trackpad: TrackpadCursor.State?
|
|
/// UTF-16 units the trackpad has moved the cursor, for Record typing logs.
|
|
var trackpadOffset = 0
|
|
/// True when the likelier next letter claimed this touch from the key under it; a
|
|
/// small move then keeps it rather than sliding back (`letterReach`).
|
|
var claimed = false
|
|
/// Where the finger went down, before a strip touch moved onto row 1 (Adaptive touch).
|
|
var downPoint: CGPoint = .zero
|
|
/// A docked iPad key pulled down (`KeyboardFlicks`): how far its character has come, 0 to 1;
|
|
/// nil until the finger goes down more than across.
|
|
var flick: CGFloat?
|
|
}
|
|
|
|
/// A press that types the character key it slides onto: 123, ABC and #+= (with a page to
|
|
/// go back to), and shift.
|
|
static func slidesToType(_ touch: ActiveTouch) -> Bool {
|
|
touch.returnLayer != nil || touch.key.kind == .shift
|
|
}
|
|
|
|
/// A language swipe's direction, or nil when it was too short or more up than along.
|
|
static func languageSwipeStep(from start: CGPoint, to end: CGPoint) -> Int? {
|
|
let dx = end.x - start.x
|
|
guard abs(dx) >= languageSwipeDistance, abs(dx) >= abs(end.y - start.y) else { return nil }
|
|
return dx < 0 ? 1 : -1
|
|
}
|
|
|
|
/// How far `point` is from `rect`: zero inside it.
|
|
static func distance(from point: CGPoint, to rect: CGRect) -> CGFloat {
|
|
let dx = max(rect.minX - point.x, 0, point.x - rect.maxX)
|
|
let dy = max(rect.minY - point.y, 0, point.y - rect.maxY)
|
|
return (dx * dx + dy * dy).squareRoot()
|
|
}
|
|
}
|