Opinion: Why the iPhone SE Should Have 3D Touch

iPhone SE, by Apple, Inc.

Before I tell you why I won’t be buying one, let me say this: I love the iPhone SE. I love its form factor, I love its power.
As a matter of fact, I’m still using – and loving – my iPhone 5s and I think, for me, the 4’’ screen is just perfect.

Why I Won’t Buy the iPhone SE

Personally, I want to keep to the 4’’ form factor, but I can’t. As a user, I probably could do without 3D Touch, but since I want to develop for it, I need some way to test it. While the simulator with Magic Trackpad (Force Touch) support is nice for initial development, I’ll have to test on a real device sooner or later (and better sooner rather than later).

So as a user, I’d probably purchase the iPhone SE, but as a developer, I can’t do it, so I’ll have to wait for the iPhone 7.

But let’s get on to the actual point of this post.

IPhone 6s Taptic Engine 3D Touch

Why The iPhone SE Should Have 3D Touch

It’s clear to me why Apple isn’t including it – it gives the iPhone 6s and Plus (and future “mainstream” iPhones) a USP and makes it more attractive for surely lots of users, while allowing to offer a slightly cheaper iPhone for those that don’t have as deep a pocket.
Still, I think it’s a mistake not including 3D Touch in the recently announced iPhone SE. Here’s why.

It “Cheapens” the Technology

To play a Live Photo, normally you’d Force Press. On the iPhone SE, you long-press to play Live Photos. The question then becomes, what do I really need 3D Touch for?
Live Photos kind of were presented together with 3D Touch (Live Photos on the Lock Screen), but a long press does this just as well, so, yeah, whatever.

IPhone 6s 3D Touch Quick Action

It remains useful for Peek & Pop and Quick Actions, of course. So not having that on the iPhone SE is bad for all involved:
– The User, because they can not use these functions on an iPhone SE
– The developer, because their apps could be perceived as less functional because of it
– Apple, because of those two reasons

It May Stifle Adoption and Innovation by Developers

Quick Actions as well as Peek and Pop are pretty easy to implement with the APIs Apple provides for it, but anything that goes beyond it does take a certain amount of work and effort.
With only the “premium” iPhones having 3D Touch, developers (especially indies, who have less resources) will think twice before taking what might turn out to be a couple of weeks to implement a unique or innovative use of 3D Touch, seeing as they might not reach the entire market with it and having to develop and maintain different code-paths for different devices.

TL;DR

The iPhone SE will probably be sold for years to come and seeing as it’s a lower-priced phone, its customers are (in my way of thinking) less likely to upgrade, say, every year, which means 3D Touch will not be available “everywhere”™ for too long a time to come for the technology to go “mainstream” among developers to do something beyond Peek & Pop or Quick Actions.

How To: Detect Force Touch-Capable Devices on the Mac

In an effort to show preferences for configuring Force Touch in my apps (in particular, Yoink) only when a Force Touch device is actually available, I had to find a way to figure out how to detect Force Touch devices.

If this was iOS, I’d be done by now

On iOS, Apple provides a simple API for this:

UIForceTouchCapabilityUnavailable and UIForceTouchCapabilityAvailable

which you can check by calling UIView’s – (UIForceTouchCapability)traitCollection;. Lo and behold, a simple API like this is sadly not available on OS X. On the Mac, you have to do it yourself.

IOKit is where it’s at

Using IOKit, you can sort of set up a set of properties you’re looking for in a device and see if it returns anything. This does not only include an external or internal keyboard, mouse or trackpad, but also graphic cards, for example. To find out what the right properties are, I downloaded Apple’s Hardware IO Tools for Xcode 7.1 from their developer downloads site (Apple Developer account required) and launched the app IORegistryExplorer.

Digging down the IO Registry

I do have a Magic Trackpad 2 “attached” to my Mac via Bluetooth, so I tried searching for the term “Trackpad”, and sure enough, I saw my internal and external ones:

IORegistry TrackpadsThe Trackpads attached to my Mac, either via Bluetooth or internally.

Having found the Magic Trackpad 2, the next step is to see what properties it offers and if they are unique to the class of the device:

Trackpad PropertiesJackpot!

Sure enough, there it is – ForceSupported: True. I could not find such a key in the internal trackpad’s properties, hinting that it might be exclusive to devices that do support Force Touch. There’s also an entry for “Manufacturer”, which is “Apple Inc.”. Perfect.

Looking for Devices with IOKit

Now all I have to do is filtering devices by the Manufacturer – “Apple Inc.” -, iterate over the resulting devices, and filter out devices that have a DefaultMultitouchProperties key, containing a ForceSupported key with a value of true. If such a device is found, it means a device with Force Touch capabilities is available.

Code Listing #1

In this method, I create a dictionary mDict that is used to find matching devices. In this case, I’m looking for devices with the Manufacturer set to “Apple Inc.”. I query for possible devices using IOServiceGetMatchingServices. I can then iterate over the returned io_iterator_t iterator and recursively over the children in the core of all of this: – (BOOL)_containsForceTouchDevice:io_iterator_t)iterator;.

Code Listing #2

Here, we iterate recursively over iterator’s objects, checking for the DefaultMultitouchProperties key and, subsequently the ForceSupported key (and value).

Testing it with other Trackpads

The code you see above is final. However, in a previous version, all I could use to test it with was my Magic Trackpad 2 – an internal Force Touch Trackpad (the likes of which the new MacBooks and MacBook Pros feature) was not available to me directly. So I sent the first draft of the code to my friend (and fellow developer) Maurice Kelly (@mauricerkelly on twitter) who was kind enough to volunteer as my “test subject”; and – of course – it didn’t work. Turns out I shouldn’t assume the vendorID to be the same (which I used in the first draft just like the Manufacturer to filter the possible results). After leaving it out, it worked fine over all currently available Force Touch Trackpads.

Hot (Un-)Plugging

Sometimes you might want to get notified when devices are plugged in to or unplugged from the Mac. In Yoink, I’d like to display preferences specific to Force Touch if according hardware is available, but not show them if there isn’t any hardware connected that supports it. Also, as a nice touch, I’d like to hide the preferences if according hardware is disconnected and show it again when it is connected. We can accomplish this like that:

Code Listing #3

Sandbox

The code works just as well in the Sandbox environment, these entitlements have to be set, though, for the notifications to work:

Sandbox Entitlements

com.apple.security.device.usb and com.apple.security.device.bluetooth

Future Proof?

I’m not sure this code is future proof. The basic APIs will stay around, sure, but it all depends on the keys DefaultMultitouchProperties, ForceSupported and their according values which are not defined in the IOKit header files, which I unsuccessfully searched for constants pertaining to force/pressure. So, depending on this, the code might break with future versions of the Force Touch Trackpad and I’ll have to keep testing it as Apple releases new hardware. Nevertheless, I’m quite happy with the code and it works very well.

Getting the Source Code

I’ve uploaded a sample project to my server, you can download it here. The category on NSApplication in which this is available can be downloaded from Github. The example app is pretty simple:

Force Touch Device Detection Example App Screenshot

At launch, it asks if a Force Touch capable device is available and displays an according message. If subsequently the availability status changes, the message will be updated accordingly.

If you’d like to get in touch, you can mail me or write me on twitter. I’m looking forward to hearing from you :)