/*
 * Copyright 2015 Samsung Electronics Co., Ltd.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *     http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
'use strict';

module.exports = {
	getSupportedKeys: function (success, fail, args) {
		try {		
			var supportedKeys = [];
			supportedKeys = tizen.tvinputdevice.getSupportedKeys();
			setTimeout(function(){
				success(supportedKeys);
			}, 0);
		} catch (e) {
			var error = new Error(e.message);
			error.name = e.name;
			setTimeout(function(){
				fail(e);
			}, 0);			
		}
	},
	getKey: function(success, fail, args){
		try	{
			var inputDeviceKey = tizen.tvinputdevice.getKey(args[0]);
			setTimeout(function(){
				success(inputDeviceKey);	
			}, 0);
		} catch (e) {
			var error;
			if(e.name === 'InvalidValuesError') {
				error = new RangeError(e.message);
			}
			else {
				error = new Error(e.message);
			}
			error.name = e.name;
			setTimeout(function(){
				fail(error);
			}, 0);
			
		}
	},
	registerKey: function(success, fail, args){
		try {
			tizen.tvinputdevice.registerKey(args[0]);
			setTimeout(function(){
				success();
			}, 0);			
		} catch (e) {
			var error;
			if(e.name === 'InvalidValuesError') {
				error = new RangeError(e.message);
			}
			else {
				error = new Error(e.message);
			}
			error.name = e.name;
			setTimeout(function(){
				fail(error);
			}, 0);
		}
	},
	unregisterKey: function(success, fail, args){
		try	{
			tizen.tvinputdevice.unregisterKey(args[0]);
			setTimeout(function(){
				success();
			}, 0);
		} catch (e) {
			var error;
			if(e.name === 'InvalidValuesError') {
				error = new RangeError(e.message);
			}
			else {
				error = new Error(e.message);
			}
			error.name = e.name;
			setTimeout(function(){
				fail(error);
			}, 0);
		}
	}
};

require('cordova/exec/proxy').add('toast.inputdevice',module.exports);
@@ -791,16 +791,347 @@
 Keys();%0A
+%09%09%09supportedKeys.push(%7Bname : 'ArrowUp', code : 38%7D);%0A%09%09%09supportedKeys.push(%7Bname : 'ArrowDown', code : 40%7D);%0A%09%09%09supportedKeys.push(%7Bname : 'ArrowLeft', code : 37%7D);%0A%09%09%09supportedKeys.push(%7Bname : 'ArrowRight', code : 39%7D);%0A%09%09%09supportedKeys.push(%7Bname : 'Enter', code : 13%7D);%0A%09%09%09supportedKeys.push(%7Bname : 'Return', code : 10009%7D);%0A
 %09%09%09setTi

Add mandatory keys in supportedKeys