From 7904ea490cdf96797fbb1c696a9a7f12d2dab517 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20M=C3=A9nager?= Date: Sun, 6 Jan 2013 12:16:54 +0100 Subject: Handle keystrokes in the web interface remote (up, down, left, right, play/pause, ...) --- addons/webinterface.default/js/MediaLibrary.js | 30 ++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'addons/webinterface.default') diff --git a/addons/webinterface.default/js/MediaLibrary.js b/addons/webinterface.default/js/MediaLibrary.js index bbe81d6ae5..f97260ecff 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,35 @@ 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 key = keys[event.which]; + + if (key) { + event.data = { + key: key + }; + + this.pressRemoteKey(event); + return false; + } + }, pressRemoteKey: function(event) { var player = -1, keyPressed = event.data.key; -- cgit v1.2.3 From 6696b306cf85690843d4dbba1a54250e4179bfc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20M=C3=A9nager?= Date: Sun, 10 Mar 2013 19:44:02 +0100 Subject: Handle letters and digits keystrokes in the web interface remote --- addons/webinterface.default/js/MediaLibrary.js | 53 ++++++++++++++++++-------- 1 file changed, 38 insertions(+), 15 deletions(-) (limited to 'addons/webinterface.default') diff --git a/addons/webinterface.default/js/MediaLibrary.js b/addons/webinterface.default/js/MediaLibrary.js index f97260ecff..8f63620c1d 100755 --- a/addons/webinterface.default/js/MediaLibrary.js +++ b/addons/webinterface.default/js/MediaLibrary.js @@ -126,25 +126,41 @@ MediaLibrary.prototype = { } 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" // - + 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 key = keys[event.which]; + var which = event.which; + var key = keys[which]; - if (key) { - event.data = { - key: key - }; + 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; } @@ -246,6 +262,13 @@ MediaLibrary.prototype = { }); } }); + case 'text': + return xbmc.rpc.request({ + 'method': 'Input.SendText', + 'params': { + 'text': event.data.text + } + }); } // TODO: Get active player -- cgit v1.2.3