Developing for Microsoft Surface Duo accessories
Hello Surface Duo developers,
Microsoft recently announced new Surface devices and accessories, so this week we’re looking at some of the accessories that work with Surface Duo and how you can accommodate them in your apps.
Microsoft Surface Pens
The Surface Slim Pen and Surface Pen both work great with the Surface Duo, whether you’re drawing, note-taking, or just prefer to navigate with a pen. Microsoft OneNote provides a great experience for writing on the Surface Duo.
Figure 1: Surface Slim Pen and Surface Pen
To build inking support in your own apps, check out the TwoNote sample app for example code to create a pressure-sensitive drawing experience, and the hinge-angle sample for a fun take on drawing.
Figure 2: TwoNote drawing demo
Xamarin developers should check out the Xamarin TV sample, which includes a note-taking feature as part of the code.
Bluetooth keyboards such as the Microsoft Designer Compact Keyboard can be paired with the Surface Duo for a desktop-like data-entry experience, and the added bonus of both screens being entirely devoted to your apps and data.
Figure 3: Microsoft Designer Compact Keyboard
There’s nothing you need to do in your apps to facilitate a paired keyboard, but check out the Orientation and Spanning sample to learn how the keyboard insets can be used to check whether an on-screen keyboard is visible and adjust your views appropriately. You can enhance your app’s keyboard navigation by using the nextFocusForward attribute for handling tab order, or nextFocus* attributes for arrow-key navigation. You can also handle key presses with onKeyDown and onKeyUp, including modifier keys by checking isShiftPressed or isCtrlPressed.
Surface Duo owners are already taking advantage of paired keyboards in a number of ways, from writing code on the go with GitHub Codespaces in Microsoft Edge, to remotely accessing desktop and server computers.
For a complete desktop productivity experience, you can also pair a Surface Mobile Mouse or Surface Arc Mouse. When a mouse is paired, a pointer will appear on the screen to allow you to easily navigate and select items on the Surface Duo. The scroll-wheel will also work where supported – you can handle scroll events in your code via the ACTION_SCROLL MotionEvent.
Figure 4: Surface Mobile Mouse and Surface Arc Mouse
Audio accessories like the Surface Earbuds pair easily with the Surface Duo. Apps don’t need to do anything different to access these accessories – Android takes care of routing the audio input and output between your app and paired devices. Whether your app is a simple productivity tool or a 3D game, take advantage of the audio capabilities of the Surface Duo to provide feedback and provide an immersive user experience.
We’d love to hear how you’re adapting your apps for the dual-screen Surface Duo, including inking support and adapting to other accessories.
Please reach out to our team using the feedback forum or Twitter. You can also reach me on Twitter or GitHub.