Adding Apple Remote Support to your Cocoa App

6,483 views
6,340 views

Published on

In the April CocoaHeads Sydney I gave a semi-lightning talk showing how to add Apple IR support to your Cocoa app.

In the presentation I also show how I used the LaTeX beamer class to make pdf slides, and I used the open source SplitShow application to give the presentation (using my Apple IR support of course!)

Published in: Technology, Business
1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
6,483
On SlideShare
0
From Embeds
0
Number of Embeds
1,001
Actions
Shares
0
Downloads
19
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Adding Apple Remote Support to your Cocoa App

  1. 1. Adding Apple IR Remote Support to Your App Mark Aufflick February 1, 2009 + Mark Aufflick February 1, 2009 Slide 1/9
  2. 2. Rule #1 of Programming Everything should be code. Perhaps that’s why I like LTEX so much. A (Or perhaps it’s because MS Word and Endnote bite.) Ergo. . . Mark Aufflick February 1, 2009 Slide 2/9
  3. 3. LTEX slides–beamer A The LTEX beamer “document class” allows you A to easily create slides with notes: begin { frame }{ LaTeX slides - - beamer } begin { itemize } item The LaTeX beamer ‘‘ document class ’ ’ allows you to easily create slides with notes : end { itemize } end { frame } note [ itemize ]{ item Here are some notes . } Mark Aufflick February 1, 2009 Slide 3/9
  4. 4. SplitShow PDF Presentation pdflatex + beamer → PDF files So we need a way to present PDF files Preferably with notes on our second screen so I can sound like I know what I’m talking about Splitshow.app allows two screen presentations from PDF http://code.google.com/p/splitshow Mark Aufflick February 1, 2009 Slide 4/9
  5. 5. Adding Apple IR Remote Support to Your SplitShow PDF Presentation 2009-02-01 App SplitShow PDF Presentation pdflatex + beamer → PDF files So we need a way to present PDF files Preferably with notes on our second screen so I can sound like I know what I’m talking about Splitshow.app allows two screen presentations from PDF http://code.google.com/p/splitshow • Toggle to notes screen by holding Play/Pause button on remote.
  6. 6. Apple IR Remote Support Splitshow didn’t have Apple IR Remote Support I added it using classes by Martin Kahr: http://www.martinkahr.com/source-code Mark Aufflick February 1, 2009 Slide 5/9
  7. 7. Implementing Apple IR Remote Support Add the class files to your project Add the Carbon Framework (the IR classes dig into IOKit and Carbon) Create a class to be a delegate to both NSApplication and RemoteControl Or you can use RemoteControlContainer instead of RemoteControl and get Keyspan support for free Mark Aufflick February 1, 2009 Slide 6/9
  8. 8. NSApplication Delegate Methods Create RemoteControl instance, and set self as delegate via: - ( void ) a p p l i c a t i o n D i d F i n i s h L a u n c h i n g :( NSNo tificati on *) n { remoteControl = [[ RemoteControl alloc ] i n i t W i t h D e l e ga t e : self ]; [ remoteControl startLi stening : self ]; } Monopolise/release the remote control via: - ( void ) a p p l i c a t i o n W i l l B e c o m e A c t i v e :( NSNotif ication *) n { [ remoteControl startLi stening : self ]; } - ( void ) a p p l i c a t i o n W i l l R e s i g n A c t i v e :( NSNotif ication *) n { [ remoteControl stopListening : self ]; } Remember to instantiate and connect your NSApplication delegate in MainMenu.xib Mark Aufflick February 1, 2009 Slide 7/9
  9. 9. NSApplication Delegate Methods Create RemoteControl instance, and set self as delegate via: - ( void ) a p p l i c a t i o n D i d F i n i s h L a u n c h i n g :( NSNo tificati on *) n { remoteControl = [[ RemoteControl alloc ] i n i t W i t h D e l e ga t e : self ]; [ remoteControl startLi stening : self ]; } Monopolise/release the remote control via: - ( void ) a p p l i c a t i o n W i l l B e c o m e A c t i v e :( NSNotif ication *) n { [ remoteControl startLi stening : self ]; } - ( void ) a p p l i c a t i o n W i l l R e s i g n A c t i v e :( NSNotif ication *) n { [ remoteControl stopListening : self ]; } Remember to instantiate and connect your NSApplication delegate in MainMenu.xib Mark Aufflick February 1, 2009 Slide 7/9
  10. 10. Adding Apple IR Remote Support to Your NSApplication Delegate Methods 2009-02-01 App NSApplication Delegate Methods Create RemoteControl instance, and set self as delegate via: - ( void ) a p p l i c a t i o n D i d F i n i s h L a u n c h i n g :( NSNot ificati on *) n { remoteControl = [[ RemoteControl alloc ] i n i t W i t h D e le g a t e : self ]; [ remoteControl startLis tening : self ]; } Monopolise/release the remote control via: - ( void ) a p p l i c a t i o n W i l l B e c o m e A c t i v e :( NSNotifi cation *) n { [ remoteControl startLis tening : self ]; } - ( void ) a p p l i c a t i o n W i l l R e s i g n A c t i v e :( NSNotifi cation *) n { [ remoteControl stopListening : self ]; } Remember to instantiate and connect your NSApplication delegate in MainMenu.xib • http://code.google.com/p/splitshow/source/ browse/trunk/src/SSAppDelegate.m • Switch to Xcode to show code (after revealing second method).
  11. 11. RemoteControl Delegate Method - ( void ) s e n d R e m o t e B u t t o n E v e n t :( R e m o t e C o n t r o l E v e n t I d e n t i f i e r ) event pressedDown :( BOOL ) pressedDown remoteControl :( RemoteControl *) remoteControl event is an integer, matching one of a number of constants, eg: kRemoteButtonLeft kRemoteButtonRight kRemoteButtonRight Hold kRemoteButtonPlay Simply perform the appropriate method call by matching event in a case statement. Often you want to discard button up events. Mark Aufflick February 1, 2009 Slide 8/9
  12. 12. Adding Apple IR Remote Support to Your RemoteControl Delegate Method 2009-02-01 App RemoteControl Delegate Method - ( void ) s e n d R e m o t e B u t t o n E v e n t :( R e m o t e C o n t r o l E v e n t I d e n t i f i e r ) event pressedDown :( BOOL ) pressedDown remoteControl :( RemoteControl *) remoteControl event is an integer, matching one of a number of constants, eg: kRemoteButtonLeft kRemoteButtonRight kRemoteButtonRight Hold kRemoteButtonPlay Simply perform the appropriate method call by matching event in a case statement. Often you want to discard button up events. • http://code.google.com/p/splitshow/source/ browse/trunk/src/SSAppDelegate.m • Switch to Xcode to show code.
  13. 13. Fin Now your Cocoa Application has Apple Remote support :) Mark Aufflick February 1, 2009 Slide 9/9

×