XBox 360 & Media Center Development

by Troy Sabin 30. December 2005 13:19

I read this post on the Media Center MS newsgroup and thought I'd help spread the word.  The post was titled "XBox 360 - help to others".

From Brian Binnerup:

Hi all,

I ran into a problem with the Xbox 360 and triple tabbing that some of you
might be interested in.

When on the Xbox 360, the number keys does not fire the "onkeydown" event
that the default HTML pages in the SDK uses for the "onRemoteEvent"
function.

I looked into this a bit, and found that the Xbox 360 does fire the
"onkeypress" event for these, and also the "onkeydown" for all other keys,
but not for the number keys. I expect this to be a bug in the Xbox 360
software, or something than has been forgotten since the default Xbox 360
remote does not have these buttons.

I fixed this by catching the "onkeypress" event, and then checking if the
device is an Xbox 360, and if so, pass on the event to the onRemoteEvent
function. This works, but notice that if the bug gets fixed later on, this
might have to be expanded to ignore the "onkeydown" event on the box for the
same keys, to not have duplicate events.

Copy the "onkeydown" event attribute on the body and set it to
"onKeyPressEvent" instead of "onRemoteEvent", and put this in your
JavaScript - notice that if you use "onkeydown" for anything, you need to
expand this, as it cancels the event.
//This function is added because of an Xbox 360 bug, where numberic keys
does not sent an onkeydown event.

function onKeyPressEvent(keyChar)
{
    if (window.external.MediaCenter)
    {
        if (window.external.MediaCenter.Capabilities.IsDirectXAllowed &&
!window.external.MediaCenter.Capabilities.IsConsole)
        {
            if ((keyChar >= 48) && (keyChar <= 57))
            {
                onRemoteEvent(keyChar);
                return true;
            }
        }
    }

    event.keyCode = 0;
    event.returnValue = false;
    event.cancelBubble = true;
    return false;
}

Also, when talking about the Xbox 360, I might as well mention the remote
thing when I am at it - if you have both a Xbox 360 and a Media Center PC in
the same room, you properly found that you can set the Xbox 360 to listen to
"all channels" to be able to use it with a standard MCE remote -
unfortunately it then listens on both your PC's remote and the remote for
the Xbox 360. If you configure the Xbox to only listen to the Xbox 360
remote events, and set the MCE remote to channel 8 (or was it 9?) it runs on
the same channel as the Xbox 360 remote (set the remote channel by pressing
and holding the DVD menu key, and then the number key for the channel, and
wait for the remote to flash it's lights).

Regards,

Brian

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Design / Technique

Comments are closed

About Me

I'm an Internet technology business strategist, software architect, and development leader specializing in interactive marketing and social media.  read more...