The Media Center Sandbox

Resources and discussion for developing experiences in the Windows Media Center platform.
Welcome to The Media Center Sandbox Sign in | Join | Help
in Search

Capturing '#' and '*' from remote control input

Last post 03-03-2010, 4:19 PM by eddyc. 6 replies.
Sort Posts: Previous Next
  •  03-02-2010, 2:08 AM 9580

    Capturing '#' and '*' from remote control input

    I've installed a keyboard handler using WH_KEYBOARD_LL with SetWindowsHookEx(). This lets me monitor all keyboard input for shortcuts.

    I can also see the numbers coming from the remote control, but the '*' and '#' remote buttons are treated strangely -- they arrive in as digit '8' and '3' respectively, with no shift modifier set. This makes it impossible to distinguish them from the normal 8' and '3' keys on the remote.

    Typing the same characters on the keyboard works fine, and they have the Shift modifier flag set.

    Am I missing something obvious here? Do I need to switch to a different sort of keyboard capture to detect the punctuation keys?

    (This is a for a background plug-in, so normal MCML key capturing isn't an option.)
  •  03-02-2010, 12:14 PM 9582 in reply to 9580

    Re: Capturing '#' and '*' from remote control input

    Might want to check the modifier keys
  •  03-02-2010, 1:13 PM 9584 in reply to 9582

    Re: Capturing '#' and '*' from remote control input

    If the modifiers aren't coming through for the remote in the global hook, you may have to capture them in MCML instead and create an event specifically for them to pass to your input handling routine.

    Cheers,
    Andrew
  •  03-02-2010, 2:52 PM 9585 in reply to 9584

    Re: Capturing '#' and '*' from remote control input

    Thanks for the comments, guys. As I mentioned, though, the modifier flags are not being set for the remote keypresses (even though you would expect them to be) -- pressing the same keys on the keyboard produces events with the Shift bit correctly set in the modifiers.

    (I checked all the fields in the event I receive, just in case there's some other way of identifying them, but no.) It's as if whatever low-level input handler accepts the remote keystrokes and maps them to keyboard equivalents is just forgetting to set the shift flag for those two keys.

    Unfortunately, going the MCML route is not an option since this is for a background plug-in.

    I guess I'll have to switch to GetRawInputData, as described in http://discuss.mediacentersandbox.com/forums/thread/8732.aspx.
  •  03-02-2010, 3:37 PM 9586 in reply to 9585

    Re: Capturing '#' and '*' from remote control input

    My bad, I didn't pay attention to your whole post. Ya, you wil need to handle it as raw. Here is an implementation that will hook HID remote, keyboard and mouse events. http://code.google.com/p/open-media-library/source/browse/trunk/Library/Code/V3/Controls/MoreInfoHooker.cs
  •  03-02-2010, 4:21 PM 9587 in reply to 9586

    Re: Capturing '#' and '*' from remote control input

    davidtjudd:
    Here is an implementation that will hook HID remote, keyboard and mouse events. http://code.google.com/p/open-media-library/source/browse/trunk/Library/Code/V3/Controls/MoreInfoHooker.cs
    Very useful example - exactly what I need!

    Much obliged,

    Eddy
  •  03-03-2010, 4:19 PM 9591 in reply to 9587

    Re: Capturing '#' and '*' from remote control input

    Okay, got to the bottom of why my original hook wasn't working.

    For reasons not relevant here, I was relying on WM_KEYUP rather than WM_KEYDOWN events to detect when a key had been pressed. Also, my actual keyboard hook was in a lower level library I wrote ages ago and had more or less forgotten about.

    That library takes in the discrete keypresses like SHIFT, 3, etc. and uses the modifier keys (Shift, Ctrl, Alt, Win) to set modifier flags for any subsequent normal keystrokes that arrive. It then passes composite key-down/key-up events to my application code which doesn't have to worry about SHIFT being handled as a separate key.

    So, # gets treated as a [SHIFT-Down] [3-Down] [3-Up] [SHIFT-UP] sequence which turns into a KeyDown(3+Shift) / KeyUp (3+Shift) event.

    That's what happens for keyboard input anyway. Remote button input is slightly different: the raw sequence is [SHIFT-Down] [3-Down] [SHIFT-Up] [3-Up], which turns into KeyDown(3+Shift) / KeyUp (3). This is why my #'s were coming out as 3's.

    Now fixed by making my low-level library a little smarter about how it deals with modifiers for key-up events.
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems