w3c / touch-events

https://w3c.github.io/touch-events/
26 stars 24 forks source link

Add touchType, altitudeAngle, azimuthAngle (Safari iOS 10.3 extensions for stylus) #81

Closed RByers closed 7 years ago

RByers commented 7 years ago

Apparently Safari on iOS 10.3 now exposes the stylus properties from iOS. These seem reasonable to me (map closely to PointerEvents tiltX, tiltY and pointerType) and could help enable more complete Pointer Events polyfills. I think we should add them to the spec to document what an important implementation has shipped.

See here for the output.

@grorg does this look good and match what you've shipped in Safari?

grorg commented 7 years ago

This matches what we shipped in iOS 10.3.

RByers commented 7 years ago

Thanks. @patrickhlauke WDYT?

patrickhlauke commented 7 years ago

Fundamentally not opposed to adding these of course (modulo my grumbles around not going full pointer events, but I understand the non-tech-related blockers for this). Will just double-check that ReSpec is happy with the way these additions are formatted and then happy to merge.

patrickhlauke commented 7 years ago

Ah, I see ReSpec hasn't been happy with the WebIDL formatting in this spec for a while anyway...will fix this separately. In meantime, happy to merge. Thanks for documenting @RByers and @grog for confirming accuracy.

patrickhlauke commented 7 years ago

@grorg @rbyers related to this...i'm having a hard time actually visualising what azimuthAngle actually is/represents. i don't suppose there's any neat diagram somewhere along the lines of the tiltX/tiltY illustrations in PE https://w3c.github.io/pointerevents/#dom-pointerevent-tiltx that could provide some visual clarity?

patrickhlauke commented 7 years ago

ah, on re-reading it a few times (and referring to the language in https://developer.apple.com/reference/uikit/uitouch/1618131-azimuthangle) i think i'm getting it now. am i right in assuming that the Apple Pencil has no concept of "twist" (i.e. that both the altitudeAngle and azimuthAngle remain unchanged if i simply spin the Pencil along its lengthwise/z axis while keeping its overall position/attitude towards the digitizer surface the same)?

patrickhlauke commented 7 years ago

FWIW updated https://patrickhlauke.github.io/touch/tracker/multi-touch-tracker-pointer-hud.html to now list the new values in the tracker. hoping to also update the WebGL tracker for pointer events stylus properties to support these, but that will likely take some time... https://patrickhlauke.github.io/touch/pen-tracker/

RByers commented 7 years ago

am i right in assuming that the Apple Pencil has no concept of "twist" (i.e. that both the altitudeAngle and azimuthAngle remain unchanged if i simply spin the Pencil along its lengthwise/z axis while keeping its overall position/attitude towards the digitizer surface the same)?

Sorry for the delay. Yes, AFAIK there's no notion of twist (I think that's the same as MS Surface, right?). But Twist is entirely separate I think (unless you're thinking about the special case of the stylus pointing straight up and down).

altitudeAngle/azimuthAngle are mathematically just an alternate representation of tiltX/tiltY. Android has basically the same thing with AXIS_TILT (altitudeAngle) and AXIS_ORIENTATION (for stylus only, equivalent of azimuthAngle). In Chrome we just do some trigonometry to convert between the one representation and the other.

patrickhlauke commented 7 years ago

(I think that's the same as MS Surface, right?).

correct.

patrickhlauke commented 7 years ago

@grorg quick question: are these new properties officially documented anywhere (for JS/touch event side, rather than native) on developer.apple.com yet?