Roku PhotoBridge Programming: Patterns and Pitfallsfrequal.com

Remote Simulator

When testing your applications, you'll find yourself using the remote control a great deal. However, there is no need to wear out your remote buttons or your thumb. The Cascade API provides a class to let us simulate remote keypresses. By reading from the console, we can create an application that simulates the remote control.

The most important class is CascadeInput. It has static methods DispatchKeyDown and DispatchKeyUp that let us simulate a remote key being pressed and released. Simply pass the methods a key code (like CK_SELECT for the select button). To simulate a realy button press on the remote control, call DispatchKeyDown followed by DispatchKeyUp.

In this application we'll read from the Linux console. Normally when getting keystrokes, input is buffered until return is pressed. We allow each key to be processed as it is entered in the disableConsoleBuffering function.

In the main function we loop getting characters entered on the console. For different keys, we simulate different remote control buttons.

When you run this application on the PhotoBridge, you can use i, j, k, and l to navigate and space to select. The is no need to wear out the batteries in your remote or your thumb any more!


Last modified on 23 Nov 2006 by AO

Copyright © 2024 Andrew Oliver