%define tizen_feature_tvchannel_support 0
%define tizen_feature_tv_display_support 0
%define tizen_feature_tvinputdevice_support 0
+%define tizen_feature_inputdevice_support 0
%define tizen_feature_tvwindow_support 0
%if 0%{?tizen_feature_telephony_support}
%define tizen_feature_tvchannel_support 0
%define tizen_feature_tv_display_support 0
%define tizen_feature_tvinputdevice_support 0
+%define tizen_feature_inputdevice_support 0
%define tizen_feature_tvwindow_support 0
#- telephony related APIs
#off for tizen 3.0 (no systeminfo definitions)
%define tizen_feature_tv_display_support 0
%define tizen_feature_tvinputdevice_support 1
-%define tizen_feature_tvwindow_support 0
+%define tizen_feature_inputdevice_support 1
+%define tizen_feature_tvwindow_support 1
%endif # tizen_profile_tv
GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_tvchannel_support=%{?tizen_feature_tvchannel_support}"
GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_tv_display_support=%{?tizen_feature_tv_display_support}"
GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_tvinputdevice_support=%{?tizen_feature_tvinputdevice_support}"
+GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_inputdevice_support=%{?tizen_feature_inputdevice_support}"
GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_tvwindow_support=%{?tizen_feature_tvwindow_support}"
GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_web_setting_support=%{?tizen_feature_web_setting_support}"
GYP_OPTIONS="$GYP_OPTIONS -Dtizen_feature_wi_fi_support=%{?tizen_feature_wi_fi_support}"
--- /dev/null
+{
+ 'includes':[
+ '../common/common.gypi',
+ ],
+ 'targets': [
+ {
+ 'target_name': 'tizen_inputdevice',
+ 'type': 'loadable_module',
+ 'dependencies': [
+ '../common/common.gyp:tizen_common',
+ ],
+ 'sources': [
+ 'inputdevice_api.js',
+ 'inputdevice_extension.cc',
+ 'inputdevice_extension.h',
+ 'inputdevice_instance.cc',
+ 'inputdevice_instance.h',
+ 'inputdevice_key.cc',
+ 'inputdevice_key.h',
+ 'inputdevice_manager.cc',
+ 'inputdevice_manager.h'
+ ],
+ 'includes': [
+ '../common/pkg-config.gypi',
+ ],
+ 'conditions': [
+ ['tizen == 1', {
+ 'variables': {
+ 'packages': [
+ ]
+ },
+ }],
+ ],
+ },
+ ],
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+var native = new xwalk.utils.NativeManager(extension);
+var validator = xwalk.utils.validator;
+var types = validator.Types;
+
+
+function InputDeviceKey(dict) {
+ for (var key in dict) {
+ if (dict.hasOwnProperty(key)) {
+ Object.defineProperty(this, key, {
+ value: dict[key],
+ enumerable: true
+ });
+ }
+ }
+ Object.freeze(this);
+}
+
+
+function dictListToInputDeviceKeyList(list) {
+ var result = [], listLength = list.length;
+ for (var i = 0; i < listLength; ++i) {
+ result.push(new InputDeviceKey(list[i]));
+ }
+ return result;
+}
+
+
+
+/**
+ * This class provides access to the API functionalities through the tizen.tvinputdevice interface.
+ * @constructor
+ */
+function InputDeviceManager() {
+ if (!(this instanceof InputDeviceManager)) {
+ throw new TypeError;
+ }
+}
+
+
+/**
+ * Retrieves the list of keys can be registered with the registerKey() method.
+ * @return {array} Array of keys
+ */
+InputDeviceManager.prototype.getSupportedKeys = function() {
+ var ret = native.callSync('InputDeviceManager_getSupportedKeys');
+ if (native.isFailure(ret)) {
+ throw native.getErrorObject(ret);
+ }
+ return dictListToInputDeviceKeyList(native.getResultObject(ret));
+};
+
+
+/**
+ * Returns information about the key which has the given name.
+ * @param {!string} keyName The key name
+ * @return {object} Key object
+ */
+InputDeviceManager.prototype.getKey = function(keyName) {
+ var args = validator.validateArgs(arguments, [
+ {name: 'keyName', type: types.STRING}
+ ]);
+
+ var ret = native.callSync('InputDeviceManager_getKey', {
+ keyName: args.keyName
+ });
+
+ if (native.isFailure(ret)) {
+ throw native.getErrorObject(ret);
+ }
+ return native.getResultObject(ret);
+};
+
+
+/**
+ * Registers an input device key to receive DOM keyboard event when it is pressed or released.
+ * @param {!string} keyName The key name
+ */
+InputDeviceManager.prototype.registerKey = function(keyName) {
+ var args = validator.validateArgs(arguments, [
+ {name: 'keyName', type: types.STRING}
+ ]);
+
+ var ret = native.callSync('InputDeviceManager_registerKey', {
+ keyName: args.keyName
+ });
+
+ if (native.isFailure(ret)) {
+ throw native.getErrorObject(ret);
+ }
+};
+
+
+/**
+ * Unregisters an input device key.
+ * @param {!string} keyName The key name
+ */
+InputDeviceManager.prototype.unregisterKey = function(keyName) {
+ var args = validator.validateArgs(arguments, [
+ {name: 'keyName', type: types.STRING}
+ ]);
+
+ var ret = native.callSync('InputDeviceManager_unregisterKey', {
+ keyName: args.keyName
+ });
+
+ if (native.isFailure(ret)) {
+ throw native.getErrorObject(ret);
+ }
+};
+
+
+// Exports
+exports = new InputDeviceManager();
--- /dev/null
+// Copyright 2014 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "../inputdevice/inputdevice_extension.h"
+
+#include "../inputdevice/inputdevice_instance.h"
+
+// This will be generated from inputdevice_api.js
+extern const char kSource_inputdevice_api[];
+
+namespace extension {
+namespace inputdevice {
+
+InputDeviceExtension::InputDeviceExtension() {
+ SetExtensionName("tizen.inputdevice");
+ SetJavaScriptAPI(kSource_inputdevice_api);
+}
+
+InputDeviceExtension::~InputDeviceExtension() {}
+
+InputDeviceManager& InputDeviceExtension::manager() {
+ // Initialize API on first request
+ return InputDeviceManager::getInstance();
+}
+
+common::Instance* InputDeviceExtension::CreateInstance() {
+ return new InputDeviceInstance;
+}
+
+} // namespace inputdevice
+} // namespace extension
+
+common::Extension* CreateExtension() {
+ return new extension::inputdevice::InputDeviceExtension;
+}
--- /dev/null
+// Copyright 2014 Samsung Electronics Co, Ltd. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SRC_INPUTDEVICE_INPUTDEVICE_EXTENSION_H_
+#define SRC_INPUTDEVICE_INPUTDEVICE_EXTENSION_H_
+
+#include "../inputdevice/inputdevice_manager.h"
+#include "common/extension.h"
+
+namespace extension {
+namespace inputdevice {
+
+class InputDeviceExtension : public common::Extension {
+ public:
+ InputDeviceExtension();
+ virtual ~InputDeviceExtension();
+
+ InputDeviceManager& manager();
+
+ private:
+ virtual common::Instance* CreateInstance();
+};
+
+} // namespace inputdevice
+} // namespace extension
+
+#endif // SRC_INPUTDEVICE_INPUTDEVICE_EXTENSION_H_
+
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#include <functional>
+#include <string>
+#include <vector>
+
+#include "../inputdevice/inputdevice_instance.h"
+#include "../inputdevice/inputdevice_manager.h"
+#include "common/logger.h"
+
+
+namespace extension {
+namespace inputdevice {
+
+InputDeviceInstance::InputDeviceInstance() {
+ LOGD("Enter");
+ using std::placeholders::_1;
+ using std::placeholders::_2;
+ #define REGISTER_SYNC(c, x) \
+ RegisterSyncHandler(c, std::bind(&InputDeviceInstance::x, this, _1, _2));
+ REGISTER_SYNC("TVInputDeviceManager_getSupportedKeys", getSupportedKeys);
+ REGISTER_SYNC("TVInputDeviceManager_getKey", getKey);
+ REGISTER_SYNC("TVInputDeviceManager_registerKey", registerKey);
+ REGISTER_SYNC("TVInputDeviceManager_unregisterKey", unregisterKey);
+ #undef REGISTER_SYNC
+}
+
+InputDeviceInstance::~InputDeviceInstance() {
+ LOGD("Enter");
+}
+
+picojson::value InputDeviceInstance::inputDeviceKeyToJson(
+ const InputDeviceKeyPtr keyPtr) {
+ LOGD("Enter");
+ picojson::value::object keyMap;
+ keyMap.insert(
+ std::make_pair("name",
+ picojson::value(keyPtr->getName())));
+ keyMap.insert(
+ std::make_pair("code",
+ picojson::value(static_cast<double>(keyPtr->getCode()))));
+ return picojson::value(keyMap);
+}
+
+void InputDeviceInstance::getSupportedKeys(const picojson::value& args,
+ picojson::object& out) {
+ LOGD("Enter");
+ std::vector<InputDeviceKeyPtr> inputDeviceKeys =
+ InputDeviceManager::getInstance().getSupportedKeys();
+ picojson::value::array picjsonValuesArray;
+ for (auto it = inputDeviceKeys.begin(); it != inputDeviceKeys.end(); ++it) {
+ picjsonValuesArray.push_back(inputDeviceKeyToJson(*it));
+ }
+ ReportSuccess(picojson::value(picjsonValuesArray), out);
+}
+
+void InputDeviceInstance::getKey(const picojson::value& args,
+ picojson::object& out) {
+ LOGD("Enter");
+ std::string keyName = args.get("keyName").get<std::string>();
+ InputDeviceKeyPtr keyPtr =
+ InputDeviceManager::getInstance().getKey(keyName);
+ ReportSuccess(inputDeviceKeyToJson(keyPtr), out);
+}
+
+void InputDeviceInstance::registerKey(const picojson::value& args,
+ picojson::object& out) {
+ LOGD("Enter");
+ std::string keyName = args.get("keyName").get<std::string>();
+ InputDeviceManager::getInstance().registerKey(keyName);
+ ReportSuccess(out);
+}
+
+void InputDeviceInstance::unregisterKey(const picojson::value& args,
+ picojson::object& out) {
+ LOGD("Enter");
+ std::string keyName = args.get("keyName").get<std::string>();
+ InputDeviceManager::getInstance().unregisterKey(keyName);
+ ReportSuccess(out);
+}
+
+} // namespace inputdevice
+} // namespace extension
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef SRC_INPUTDEVICE_INPUTDEVICE_INSTANCE_H_
+#define SRC_INPUTDEVICE_INPUTDEVICE_INSTANCE_H_
+
+#include "../inputdevice/inputdevice_manager.h"
+#include "common/picojson.h"
+#include "common/extension.h"
+
+
+namespace extension {
+namespace inputdevice {
+
+class InputDeviceInstance : public common::ParsedInstance {
+ public:
+ InputDeviceInstance();
+ virtual ~InputDeviceInstance();
+
+ private:
+ picojson::value inputDeviceKeyToJson(const InputDeviceKeyPtr keyPtr);
+ void getSupportedKeys(const picojson::value& args, picojson::object& out);
+ void getKey(const picojson::value& args, picojson::object& out);
+ void registerKey(const picojson::value& args, picojson::object& out);
+ void unregisterKey(const picojson::value& args, picojson::object& out);
+};
+
+} // namespace inputdevice
+} // namespace extension
+
+#endif // SRC_INPUTDEVICE_INPUTDEVICE_INSTANCE_H_
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+
+#include "../inputdevice/inputdevice_key.h"
+#include "common/logger.h"
+#include "common/platform_exception.h"
+
+
+namespace extension {
+namespace inputdevice {
+
+InputDeviceKey::InputDeviceKey():
+ m_code(0), m_name("") {
+ LOGD("Enter");
+}
+
+InputDeviceKey::InputDeviceKey(std::string name, int32_t code):
+ m_name(name), m_code(code) {
+ LOGD("Key Name %s", m_name.c_str() );
+}
+
+InputDeviceKey::~InputDeviceKey() {
+ LOGD("Enter");
+}
+
+std::string InputDeviceKey::getName() const {
+ LOGD("Enter");
+ LOGD("Key Name %s", m_name.c_str() );
+ return m_name;
+}
+
+void InputDeviceKey::setName(std::string name) {
+ LOGD("Key Name %s", name.c_str() );
+ m_name = name;
+}
+
+int32_t InputDeviceKey::getCode() const {
+ return m_code;
+}
+
+void InputDeviceKey::setCode(int32_t code) {
+ m_code = code;
+}
+
+
+} // namespace inputdevice
+} // namespace extension
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef SRC_INPUTDEVICE_INPUTDEVICE_KEY_H_
+#define SRC_INPUTDEVICE_INPUTDEVICE_KEY_H_
+
+#include <sys/types.h>
+#include <string>
+#include <memory>
+
+namespace extension {
+namespace inputdevice {
+
+class InputDeviceKey {
+ public:
+ InputDeviceKey();
+
+ InputDeviceKey(std::string name, int32_t code);
+
+ virtual ~InputDeviceKey();
+
+ std::string getName() const;
+ void setName(std::string name);
+
+ int32_t getCode() const;
+ void setCode(int32_t code);
+
+ private:
+ std::string m_name;
+ int32_t m_code;
+};
+
+typedef std::shared_ptr<InputDeviceKey> InputDeviceKeyPtr;
+
+} // namespace inputdevice
+} // namespace extension
+
+#endif // SRC_INPUTDEVICE_INPUTDEVICE_KEY_H_
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+
+#include "../inputdevice/inputdevice_manager.h"
+#include <sys/types.h>
+#include <algorithm>
+
+#include "common/logger.h"
+#include "common/platform_exception.h"
+
+
+namespace extension {
+namespace inputdevice {
+
+using common::UnknownException;
+using common::InvalidValuesException;
+
+InputDeviceManager::InputDeviceManager() {
+ LOGD("Enter");
+ setSupportedKeys();
+}
+
+InputDeviceManager::~InputDeviceManager() {
+ LOGD("Enter");
+ cleanSupportedKeys();
+}
+
+InputDeviceManager& InputDeviceManager::getInstance() {
+ LOGD("Enter");
+ static InputDeviceManager instance;
+ return instance;
+}
+
+void InputDeviceManager::cleanSupportedKeys() {
+ LOGD("Enter");
+ m_availableKeys.clear();
+}
+
+void InputDeviceManager::setSupportedKeys() {
+ LOGD("Entered");
+ cleanSupportedKeys();
+ InputDeviceKeyPtr key(new InputDeviceKey());
+ m_availableKeys.push_back(key);
+}
+
+InputDeviceKeyPtr InputDeviceManager::getKey(
+ std::string const& keyName) const {
+ LOGD("Enter");
+ auto it = std::find_if(m_availableKeys.begin(), m_availableKeys.end(),
+ [ keyName ](InputDeviceKeyPtr _pKey)->bool{
+ if (_pKey->getName() == keyName) {
+ return true;
+ } else {
+ return false;
+ }
+ });
+
+ if (it != m_availableKeys.end()) {
+ return *it;
+ } else {
+ return NULL;
+ }
+}
+void InputDeviceManager::registerKey(std::string const& keyName) const {
+ LOGD("Enter");
+}
+void InputDeviceManager::unregisterKey(std::string const& keyName) const {
+ LOGD("Enter");
+}
+
+std::vector<InputDeviceKeyPtr> InputDeviceManager::getSupportedKeys() const {
+ LOGD("Enter");
+ return m_availableKeys;
+}
+
+} // namespace inputdevice
+} // namespace extension
--- /dev/null
+/*
+ * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef SRC_INPUTDEVICE_INPUTDEVICE_MANAGER_H_
+#define SRC_INPUTDEVICE_INPUTDEVICE_MANAGER_H_
+
+#include <vector>
+#include <string>
+
+#include "../inputdevice/inputdevice_key.h"
+
+namespace extension {
+namespace inputdevice {
+
+class InputDeviceManager {
+ public:
+ InputDeviceKeyPtr getKey(std::string const& keyName) const;
+
+ void registerKey(std::string const& keyName) const;
+
+ void unregisterKey(std::string const& keyName) const;
+
+ std::vector<InputDeviceKeyPtr> getSupportedKeys() const;
+
+ static InputDeviceManager& getInstance();
+
+ virtual ~InputDeviceManager();
+
+ private:
+ InputDeviceManager();
+
+ void setSupportedKeys();
+ std::vector<InputDeviceKeyPtr> m_availableKeys;
+
+ void cleanSupportedKeys();
+};
+
+} // namespace inputdevice
+} // namespace extension
+
+#endif // SRC_INPUTDEVICE_INPUTDEVICE_MANAGER_H_
],
},
],
+ [
+ 'tizen_feature_inputdevice_support==1', {
+ 'dependencies': [
+ 'inputdevice/inputdevice.gyp:*'
+ ],
+ },
+ ],
[
'tizen_feature_tvchannel_support==1', {
'dependencies': [