I do a lot of presentation particularly those class projects. To make my presentation looks more professional, I decide to buy Logitech Professional Presenter R800. It is very nice. I recommend you to have one if you have to give a lot of presentation.
However, what bothers me is that not all buttons work with Apple Keynote, particularly Play button and Blank button. Well, the device is designed for Microsoft PowerPoint on Windows.
The questions are why it doesn’t work and how to make it works with Keynote?
How does the device work?
Actually, that device is merely a wireless keyboard with only 4 keys including, Page Up, Page Down, F5 and . (dot). Page Up key and Page Down key are for moving slides back and forth. F5 is for starting a presentation. Dot key is for blanking.
PowerPoint conforms to all those keys but Keynote doesn’t. Keynote uses, by default, CMD + ALT + P to start playing a slide and B for blanking the slide. Dot key for Keynote is for terminating the slideshow which may or may not what you want.
What normal people would do
The simple and sane way is to modify the shortcut key. You can go to System Preference > Keyboard > Keyboard Shortcuts > Application Shortcuts, add Keynote application and overide Play Slideshow to use F5. However, This approach doesn’t work if you want to modify the Blank key.
You can ignore Blank key actually if you want it to stop playing the slide but I want to blank the screen. To me, stop playing to the slide means the presentation is end and I will be at the computer to stop the slideshow manually.
What I actually do
To satify my geek spirit, I write my own kernel extension for the device.
The first question is where should I start? The answer is
ioreg. I know that the device is a keyboard. Keyboard is a kind of Human Interface Device (HID). Apple Keyboard is also a keyboard. Therefore, I should take a look at driver which is used with Apple Keyboard.
Before I go, I should mention a little bit about IOKit Framework first. IOKit Framework is a framework that Apple provides to developers for writing a device driver in an OOP way wtih C++.
The belowing snippet shows the partial output from
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
What does this information tell us? It shows the hierarchy of drivers which implys us the chain of command. For example, IOHIDInterface is said to be a provider of AppleEmbeddedKeyboard; you can think of it as a data provider.
The class beginning with IO belongs to the system. As you can see, there are 2 custom drivers, AppleUSBTCKeyboard and AppleEmbeddedKeyboard. I investigate further by the command
ioreg -c and find out that AppleUSBTCKeyboard is a subclass of IOUSBHIDDriver and AppleEmbeddedKeyboard is a subclass of IOHIDEventDriver.
My initial assumption about the driver is that it should do something about event dispatching. I start by looking at IOUSBHIDDriver.h and IOHIDEventDriver.h and found nothing that seems to match my assumption. Is my assumption wrong?
I google ‘AppleEmbeddedKeyboard’ and find a source code from Apple open source repository. I take a look at AppleEmbeddedKeyboard.cpp find this method overiding interesting:
1 2 3 4 5 6 7 8 9
It turns out that the method
dispatchKeyboardEvent() is declared in IOHIDEventService.h. So, I decide to write the kernel extension based on IOHIDEventDriver. With Apple documentation and suggestion from Pavel Prokofiev who writes macosx-nosleep-extension, I am able to complete it (It is not that hard but takes time to understand what things are).
What my code does is intercepting the key and replace it if necessary.
You can see my source code here https://github.com/ake-koomsin/LogitechWirelessPresenterKext.