aboutsummaryrefslogtreecommitdiff
path: root/addons
diff options
context:
space:
mode:
authorArne Morten Kvarving <spiff@xbmc.org>2013-04-06 01:56:48 -0700
committerArne Morten Kvarving <spiff@xbmc.org>2013-04-06 01:56:48 -0700
commita35f64abf2506106315dba5e6d30791e0cb9d2ab (patch)
tree1e0bef5851218e65f615a6694599b3fe9888a66c /addons
parent53a3ddbec12509d9a7cc381ba85aae1ff600ee2b (diff)
parent6696b306cf85690843d4dbba1a54250e4179bfc4 (diff)
Merge pull request #2033 from PhenX/master
Handle keystrokes in the web interface remote (up, down, left, right,…
Diffstat (limited to 'addons')
-rwxr-xr-xaddons/webinterface.default/js/MediaLibrary.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/addons/webinterface.default/js/MediaLibrary.js b/addons/webinterface.default/js/MediaLibrary.js
index 6a55b46647..27cb895794 100755
--- a/addons/webinterface.default/js/MediaLibrary.js
+++ b/addons/webinterface.default/js/MediaLibrary.js
@@ -38,6 +38,7 @@ MediaLibrary.prototype = {
$('#remoteControl').click(jQuery.proxy(this.remoteControlOpen, this));
$('#overlay').click(jQuery.proxy(this.hideOverlay, this));
$(window).resize(jQuery.proxy(this.updatePlayButtonLocation, this));
+ $(document).bind('keydown', jQuery.proxy(this.handleKeyPress, this));
},
resetPage: function() {
$('#musicLibrary').removeClass('selected');
@@ -119,6 +120,51 @@ MediaLibrary.prototype = {
$('#spinner').hide();
},
+ handleKeyPress: function(event) {
+ if (!$('#remoteControl').hasClass('selected')) {
+ return;
+ }
+
+ var keys = {
+ 8: 'back', // Back space
+ 13: 'ok', // Enter
+ 27: 'home', // Escape
+ 32: 'playpause', // Space bar
+ 37: 'left', // Left
+ 38: 'up', // Up
+ 39: 'right', // Right
+ 40: 'down', // Down
+ 107: 'volumeup', // +
+ 109: 'volumedown' // -
+ };
+
+ var which = event.which;
+ var key = keys[which];
+
+ event.data = {
+ key: key
+ };
+
+ if (!key) {
+ event.data.key = 'text';
+
+ // Letters
+ if (which >= 65 && which <= 90) {
+ var offset = event.shiftKey ? 0 : 32;
+ event.data.text = String.fromCharCode(which + offset);
+ }
+
+ // Digits
+ if (which >= 96 && which <= 105) {
+ event.data.text = (which-96)+"";
+ }
+ }
+
+ if (event.data.key) {
+ this.pressRemoteKey(event);
+ return false;
+ }
+ },
pressRemoteKey: function(event) {
var player = -1,
keyPressed = event.data.key;
@@ -216,6 +262,13 @@ MediaLibrary.prototype = {
});
}
});
+ case 'text':
+ return xbmc.rpc.request({
+ 'method': 'Input.SendText',
+ 'params': {
+ 'text': event.data.text
+ }
+ });
}
// TODO: Get active player