Categories
General

Calling all speakers! A hardware button to toggle display mirroring

I’ve been really frustrated that my favourite keyboard shortcut to toggle display mirroring doesn’t work on TouchBar MacBooks so I’ve made a button that can emulate it!

Of course since I’ve got this working I’ve discovered there’s a weird work-around to get it working on the TouchBar, but it’s still quite a fun device, and you could use it to emulate any key (missing that Escape key, anyone?)

What you need :

That’s it! It should be way less than $20. You’ll also need a soldering iron.

Solder the switch to the Trinket as in the pictures – you’ll need to break one of the legs off.


Then you’ll need to install the Arduino IDE, and add the Adafruit boards. Checkout Adafruit’s brilliant guide to installing the Arduino IDE for their boards.

Download the code from the Cmd-f1-emulator repository on GitHub.

In the Arduino IDE, open the preferences and change the sketchbook folder to be the ‘Arduino’ folder inside the repository that you just downloaded. Restart the IDE, and then open the file CmdF1Emulator from the sketchbook. Make sure that the correct board and programmer are selected (Adafruit Trinket 8Mhz and USBTinyISP, respectively – check the instructions on working with the Trinket on Adafruit if you’re new to this).

Press the reset button on the Trinket and upload the code to it.

It should now work! It uses the Keyboard Trinket code provided by Adafruit, although I had to adapt it – apparently the Mac doesn’t act on the keyboard shortcut unless it thinks it’s made by Apple. That was a day wasted trying to figure that out! I adapted the Keyboard Trinket library to provide an Apple USB device ID to fool your computer into thinking it’s an Apple keyboard.

Ideally you should really put it in some kind of case – maybe just wrap it in Sugru? Or else there are some Trinket cases on Thingiverse you could check out.

Let me know if you decide to make this simple project and how you get along!