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') 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