From b43165bf6cbfea74550dbb6326c546542c62d49f Mon Sep 17 00:00:00 2001 From: Gina Yeh Date: Fri, 14 Jun 2013 11:58:09 +0800 Subject: [PATCH] Bug 834554 - Support Bluetooth AVRCP 1.0, r=fabrice --- b2g/chrome/content/shell.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/b2g/chrome/content/shell.js b/b2g/chrome/content/shell.js index 3dd737539047..ccefda9d58f5 100644 --- a/b2g/chrome/content/shell.js +++ b/b2g/chrome/content/shell.js @@ -379,8 +379,27 @@ var shell = { case evt.DOM_VK_F1: // headset button type = 'headset-button'; break; - default: // Anything else is a real key - return; // Don't filter it at all; let it propagate to Gaia + } + + let mediaKeys = { + 'MediaNextTrack': 'media-next-track-button', + 'MediaPreviousTrack': 'media-previous-track-button', + 'MediaPause': 'media-pause-button', + 'MediaPlay': 'media-play-button', + 'MediaPlayPause': 'media-play-pause-button', + 'MediaStop': 'media-stop-button', + 'MediaRewind': 'media-rewind-button', + 'FastFwd': 'media-fast-forward-button' + }; + + let isMediaKey = false; + if (mediaKeys[evt.key]) { + isMediaKey = true; + type = mediaKeys[evt.key]; + } + + if (!type) { + return; } // If we didn't return, then the key event represents a hardware key @@ -408,6 +427,12 @@ var shell = { return; } + if (isMediaKey) { + this.lastHardwareButtonEventType = type; + gSystemMessenger.broadcastMessage('media-button', type); + return; + } + // On my device, the physical hardware buttons (sleep and volume) // send multiple events (press press release release), but the // soft home button just sends one. This hack is to manually