Using Remote Control Input Outside of Windows Media Center
This topic describes the Windows commands generated by the remote control device driver and how to retrieve them so that your application can respond appropriately to input.
The following table shows the associated messages and keyboard equivalents for the compulsory and optional buttons on the remote control.
Button | Message | Command | Keyboard equivalent |
# | To be determined | — | SHIFT+3 |
* | To be determined | — | SHIFT+8 |
Back | WM_APPCOMMAND | APPCOMMAND_BROWSER_BACK | BACKSPACE |
Chan/Page Down | WM_APPCOMMAND | APPCOMMAND_MEDIA_CHANNEL_DOWN | MINUS SIGN (-)
CTRL+MINUS SIGN PAGE DOWN |
Chan/Page Up | WM_APPCOMMAND | APPCOMMAND_MEDIA_CHANNEL_UP | PLUS SIGN (+) CTRL+SHIFT+PLUS SIGN
PAGE UP |
Clear | WM_KEYDOWN | VK_ESCAPE | ESC |
Details | WM_INPUT | — | — |
Down | WM_KEYDOWN | VK_DOWN | DOWN ARROW |
DVD Angle | WM_INPUT | — | — |
DVD Audio | WM_INPUT | — | — |
DVD Menu | WM_INPUT | — | — |
DVD Subtitle | WM_INPUT | — | — |
eHome | Not for use by applications. | — | — |
Enter | VK_RETURN | — | ENTER |
Fwd | WM_APPCOMMAND | APPCOMMAND_MEDIA_FASTFORWARD | CTRL+SHIFT+F |
Guide | WM_INPUT | — | — |
Left | WM_KEYDOWN | VK_LEFT | LEFT ARROW |
Mute | WM_APPCOMMAND | APPCOMMAND_VOLUME_MUTE | F8 |
My Music | WM_INPUT | — | — |
My Pictures | WM_INPUT | — | — |
Recorded TV | WM_INPUT | — | — |
My TV | WM_INPUT | — | — |
My Videos | WM_INPUT | — | — |
Number keys | WM_KEYDOWN | VK_0 to VK_9 | 0 to 9 |
OEM1 | WM_INPUT | — | — |
OEM2 | WM_INPUT | — | — |
OK | WM_KEYDOWN | VK_RETURN | ENTER
SPACEBAR |
Pause | WM_APPCOMMAND | APPCOMMAND_MEDIA_PAUSE | CTRL+P |
Play | WM_APPCOMMAND | APPCOMMAND_MEDIA_PLAY | CTRL+SHIFT+P |
Record | WM_APPCOMMAND | APPCOMMAND_MEDIA_RECORD | CTRL+R |
Replay | WM_APPCOMMAND | APPCOMMAND_MEDIA_PREVIOUSTRACK | CTRL+B |
Rewind | WM_APPCOMMAND | APPCOMMAND_MEDIA_REWIND | — |
Right | WM_KEYDOWN | VK_RIGHT | RIGHT ARROW |
Skip | WM_APPCOMMAND | APPCOMMAND_MEDIA_NEXTTRACK | CTRL+F |
Standby | WM_INPUT | — | — |
Stop | WM_APPCOMMAND | APPCOMMAND_MEDIA_STOP | CTRL+S |
Up | WM_KEYDOWN | VK_UP | UP ARROW |
TV/Jump | WM_INPUT | — | — |
Vol Down | WM_APPCOMMAND | APPCOMMAND_VOLUME_DOWN | F9 |
Vol Up | WM_APPCOMMAND | APPCOMMAND_VOLUME_UP | F10 |
Buttons that generate WM_INPUT messages are defined according to the Human Interface Device (HID) specification. The following table shows the HID mapping of these buttons.
Button | Usage page | Page name | Collection usage ID |
Button usage ID |
Details | 0x0C | Consumer controls | 0x01 | 0x209 (AC properties) |
DVD Angle | 0xFFBC | Vendor-defined | 0x88 | 0x4B |
DVD Audio | 0xFFBC | Vendor-defined | 0x88 | 0x4C |
DVD Menu | 0xFFBC | Vendor-defined | 0x88 | 0x24 |
DVD Subtitle | 0xFFBC | Vendor-defined | 0x88 | 0x4D |
Guide | 0x0C | Consumer controls | 0x01 | 0x8D (AC Program Guide) |
My Music | 0xFFBC | Vendor-defined | 0x88 | 0x47 |
My Pictures | 0xFFBC | Vendor-defined | 0x88 | 0x49 |
My TV | 0xFFBC | Vendor-defined | 0x88 | 0x46 |
My Videos | 0xFFBC | Vendor-defined | 0x88 | 0x4A |
OEM1 | 0xFFBC | Vendor-defined | 0x88 | 0x80 |
OEM2 | 0xFFBC | Vendor-defined | 0x88 | 0x81 |
Recorded TV | 0xFFBC | Vendor-defined | 0x88 | 0x48 |
Standby | 0x01 | Generic desktop | 0x80 | 0x82 |
TV/Jump | 0xFFBC | Vendor-defined | 0x88 | 0x25 |
To process WM_INPUT messages, the application must first register the devices from which it receives data. You can do this by using the Win32® function RegisterRawInputDevices. Each RAWINPUTDEVICE structure passed to this function specifies one usage page and usage.
The following example C++ code registers the device to receive input from the controls defined on the vendor-defined usage page that have a usage of 0x88:
RAWINPUTDEVICE Rid[1];
Rid[0].usUsagePage = 0xFFBC;
Rid[0].usUsage = 0x88;
Rid[0].dwFlags = 0;
if (RegisterRawInputDevices(Rid, 1, sizeof(Rid[0])) == FALSE)
{
ErrorExit(); // Add error-handling code here.
}
To identify the event that triggered a WM_INPUT message, your application must parse the data passed to the window procedure as the lParam parameter.
If you are using the Microsoft .NET Framework, you must implement the WndProc method to retrieve messages. The WndProc method is a member of the NativeWindow class found in the System.Windows.Forms namespace. The overridden method is called each time a new message is placed in the form's message queue. Before returning, the method must call the base WndProc method to ensure that unprocessed messages are handled properly.
The following C# code shows how to use the WndProc method to retrieve WM_KEYDOWN messages:
using System.Windows.Forms;
.
.
.
class Form1Window : NativeWindow
{
private const int WM_KEYDOWN = 0x0100;
private int iChar;
public Form1 form;
protected override void WndProc(ref Message message)
{
// Handle the navigation and numeric buttons.
if (message.Msg == WM_KEYDOWN)
{
iChar = message.WParam.ToInt32();
switch(iChar)
{
case (int)Keys.D0:
// Handle 0 key here.
break;
// Insert more cases here.
.
.
.
} // End switch.
} // End key messages.
base.WndProc(ref message);
} // End WndProc
} // End class.
In the initialization code for the main form, you must create an instance of the Form1Window class and assign the main form to it, as follows:
public Form1()
{
InitializeComponent();
Form1Window win = new Form1Window();
win.form = this;
win.AssignHandle(this.Handle);
}
To learn more about Human Interface Device (HID) and the structure of HID data, see the USB home page (http://www.usb.org).
See Also