Support screen connector input 89/269589/14
authorHwankyu Jhun <h.jhun@samsung.com>
Thu, 27 Jan 2022 02:32:55 +0000 (11:32 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Tue, 22 Feb 2022 06:11:22 +0000 (15:11 +0900)
The libscreen_connector_input is supported to transfer key events using IPC.
The feature is implemented using TIDL. The consumer can send the key event
to the provider.

Requires:
 - https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/269604/

Change-Id: I69ce3504c674003328462476b2883bbfcfd1f46a
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
30 files changed:
CMakeLists.txt
packaging/libscreen_connector.spec
packaging/libscreen_connector_input.manifest [new file with mode: 0644]
screen_connector_input/CMakeLists.txt [new file with mode: 0644]
screen_connector_input/LICENSE [new file with mode: 0644]
screen_connector_input/export.hh [new file with mode: 0644]
screen_connector_input/key_event_args.cc [new file with mode: 0644]
screen_connector_input/key_event_args.hh [new file with mode: 0644]
screen_connector_input/key_event_args_implementation.hh [new file with mode: 0644]
screen_connector_input/log_private.hh [new file with mode: 0644]
screen_connector_input/proxy.cc [new file with mode: 0644]
screen_connector_input/proxy.hh [new file with mode: 0644]
screen_connector_input/proxy_implementation.hh [new file with mode: 0644]
screen_connector_input/screen_connector_input.pc.in [new file with mode: 0644]
screen_connector_input/stub.cc [new file with mode: 0644]
screen_connector_input/stub.hh [new file with mode: 0644]
screen_connector_input/stub_implementation.hh [new file with mode: 0644]
screen_connector_provider/CMakeLists.txt
screen_connector_provider/include/screen_connector_provider.h
screen_connector_provider/remote_surface_manager.cc
screen_connector_provider/remote_surface_manager.hh
screen_connector_provider/screen_connector_provider.cc
screen_connector_remote_surface/CMakeLists.txt
screen_connector_remote_surface/remote_surface.cc
screen_connector_remote_surface/remote_surface.h
screen_connector_remote_surface/remote_surface_implementation.h
screen_connector_remote_surface/screen_connector_remote_surface.pc.in
screen_connector_watcher/include/screen_connector_toolkit.h
screen_connector_watcher/src/screen_connector_toolkit.cc
tidl/screen_connector_input.tidl [new file with mode: 0644]

index ffcf2c8..1534d40 100644 (file)
@@ -21,6 +21,8 @@ SET(CMAKE_CXX_FLAGS_RELEASE "-O2")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
 
 ## TARGET
+SET(TARGET_SCREEN_CONNECTOR_INPUT
+  "screen_connector_input")
 SET(TARGET_SCREEN_CONNECTOR_LAUNCHER_SERVICE
   "screen_connector_launcher_service")
 SET(TARGET_SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS
@@ -52,19 +54,21 @@ SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
 INCLUDE(FindPkgConfig)
 INCLUDE(ApplyPkgConfig)
 
-PKG_CHECK_MODULES(GLIB_DEPS REQUIRED glib-2.0)
-PKG_CHECK_MODULES(GMOCK_DEPS REQUIRED gmock)
-PKG_CHECK_MODULES(LIBTBM_DEPS REQUIRED libtbm)
 PKG_CHECK_MODULES(AUL_DEPS REQUIRED aul)
 PKG_CHECK_MODULES(DLOG_DEPS REQUIRED dlog)
 PKG_CHECK_MODULES(ECORE_WL2_DEPS REQUIRED ecore-wl2)
 PKG_CHECK_MODULES(ELEMENTARY_DEPS REQUIRED elementary)
+PKG_CHECK_MODULES(GLIB_DEPS REQUIRED glib-2.0)
+PKG_CHECK_MODULES(GMOCK_DEPS REQUIRED gmock)
+PKG_CHECK_MODULES(LIBTBM_DEPS REQUIRED libtbm)
+PKG_CHECK_MODULES(RPC_PORT_DEPS REQUIRED rpc-port)
 PKG_CHECK_MODULES(TIZEN_REMOTE_SURFACE_CLIENT_DEPS REQUIRED tizen-remote-surface-client)
 PKG_CHECK_MODULES(TZSH_LAUNCHER_SERVICE_DEPS REQUIRED tzsh-launcher-service)
 PKG_CHECK_MODULES(TZSH_SHARED_WIDGET_LAUNCH_DEPS REQUIRED tzsh-shared-widget-launch)
 PKG_CHECK_MODULES(WAYLAND_CLIENT_DEPS REQUIRED wayland-client)
 PKG_CHECK_MODULES(WAYLAND_TBM_CLIENT_DEPS REQUIRED wayland-tbm-client)
 
+ADD_SUBDIRECTORY(screen_connector_input)
 ADD_SUBDIRECTORY(screen_connector_launcher_service)
 ADD_SUBDIRECTORY(screen_connector_launcher_service_evas)
 ADD_SUBDIRECTORY(screen_connector_provider)
index c0dbda3..d8ccc35 100644 (file)
@@ -13,6 +13,7 @@ Source1005: %{name}_remote_surface_evas.manifest
 Source1006: %{name}_launcher_service.manifest
 Source1007: %{name}_launcher_service_evas.manifest
 Source1008: %{name}_shared_widget_launch.manifest
+Source1009: %{name}_input.manifest
 BuildRequires: cmake
 BuildRequires: pkgconfig(dlog)
 BuildRequires: pkgconfig(aul)
@@ -25,6 +26,8 @@ BuildRequires: pkgconfig(ecore-wl2)
 BuildRequires: pkgconfig(gmock)
 BuildRequires: pkgconfig(tzsh-launcher-service)
 BuildRequires: pkgconfig(libtbm)
+BuildRequires: pkgconfig(rpc-port)
+BuildRequires: tidl
 
 %if 0%{?gcov:1}
 BuildRequires:  lcov
@@ -61,6 +64,11 @@ cp %{SOURCE1005} .
 cp %{SOURCE1006} .
 cp %{SOURCE1007} .
 cp %{SOURCE1008} .
+cp %{SOURCE1009} .
+
+tidlc -p -l C++ -i tidl/screen_connector_input.tidl -o screen_connector_input_proxy
+tidlc -s -l C++ -i tidl/screen_connector_input.tidl -o screen_connector_input_stub
+mv screen_connector_input_* screen_connector_input/
 
 %build
 %if 0%{?gcov:1}
@@ -91,7 +99,7 @@ install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj/%{name}
 %endif
 
 %check
-export LD_LIBRARY_PATH=../../screen_connector_remote_surface
+export LD_LIBRARY_PATH=../../screen_connector_remote_surface:../../screen_connector_input
 ctest -V
 
 %if 0%{?gcov:1}
@@ -417,4 +425,37 @@ Header & package files to support development of the shared widget launch applic
 %{_libdir}/pkgconfig/screen_connector_shared_widget_launch.pc
 %{_libdir}/%{name}_shared_widget_launch.so
 
+#################################################
+# libscreen_connector_input
+#################################################
+%package -n %{name}_input
+Summary: Library for developing the screen connector input
+Group: Applications/Core Applications
+License: Apache-2.0
+
+%description -n %{name}_input
+Input APIs to develop the screen connector provider and watcher applications.
+
+%package -n %{name}_input-devel
+Summary: Screen connector input application development library (dev)
+Group: Development/Libraries
+
+%description -n %{name}_input-devel
+Header & package files to support development of the screen connector applications.
+
+%post -n %{name}_input -p /sbin/ldconfig
+
+%postun -n %{name}_input -p /sbin/ldconfig
+
+%files -n %{name}_input
+%manifest %{name}_input.manifest
+%attr(0644,root,root) %{_libdir}/%{name}_input.so.*
+%license LICENSE
+
+%files -n %{name}_input-devel
+%{_includedir}/screen_connector_input/*
+%{_libdir}/pkgconfig/screen_connector_input.pc
+%{_libdir}/%{name}_input.so
+
+
 # End of a file
diff --git a/packaging/libscreen_connector_input.manifest b/packaging/libscreen_connector_input.manifest
new file mode 100644 (file)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/screen_connector_input/CMakeLists.txt b/screen_connector_input/CMakeLists.txt
new file mode 100644 (file)
index 0000000..ff65313
--- /dev/null
@@ -0,0 +1,39 @@
+AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}
+  SCREEN_CONNECTOR_INPUT_SRCS)
+
+ADD_LIBRARY(${TARGET_SCREEN_CONNECTOR_INPUT} SHARED
+  ${SCREEN_CONNECTOR_INPUT_SRCS})
+
+SET_TARGET_PROPERTIES(${TARGET_SCREEN_CONNECTOR_INPUT}
+  PROPERTIES SOVERSION ${MAJORVER})
+SET_TARGET_PROPERTIES(${TARGET_SCREEN_CONNECTOR_INPUT}
+  PROPERTIES VERSION ${FULLVER})
+SET_TARGET_PROPERTIES(${TARGET_SCREEN_CONNECTOR_INPUT}
+  PROPERTIES COMPILE_FLAGS ${CLFAGS} "-fpic")
+SET_TARGET_PROPERTIES(${TARGET_SCREEN_CONNECTOR_INPUT}
+  PROPERTIES LINK_FLAGS "-lpthread")
+
+TARGET_INCLUDE_DIRECTORIES(${TARGET_SCREEN_CONNECTOR_INPUT} PUBLIC
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${CMAKE_CURRENT_SOURCE_DIR}/../
+  ${CMAKE_CURRENT_SOURCE_DIR}/include)
+
+APPLY_PKG_CONFIG(${TARGET_SCREEN_CONNECTOR_INPUT} PUBLIC
+  DLOG_DEPS
+  GLIB_DEPS
+  RPC_PORT_DEPS
+)
+
+CONFIGURE_FILE(${TARGET_SCREEN_CONNECTOR_INPUT}.pc.in
+  ${TARGET_SCREEN_CONNECTOR_INPUT}.pc @ONLY)
+
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_SCREEN_CONNECTOR_INPUT}.pc
+  DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+INSTALL(TARGETS ${TARGET_SCREEN_CONNECTOR_INPUT}
+  DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries)
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+  DESTINATION include/${TARGET_SCREEN_CONNECTOR_INPUT}
+  FILES_MATCHING
+  PATTERN "*.hh"
+  PATTERN "*_private.hh" EXCLUDE
+  PATTERN "*_implemenation.hh" EXCLUDE)
diff --git a/screen_connector_input/LICENSE b/screen_connector_input/LICENSE
new file mode 100644 (file)
index 0000000..9c13a9b
--- /dev/null
@@ -0,0 +1,204 @@
+Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.\r
+\r
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
diff --git a/screen_connector_input/export.hh b/screen_connector_input/export.hh
new file mode 100644 (file)
index 0000000..b30a55c
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_INPUT_EXPORT_HH_
+#define SCREEN_CONNECTOR_INPUT_EXPORT_HH_
+
+#undef EXPORT
+#define EXPORT __attribute__((visibility("default")))
+
+#endif  // SCREEN_CONNECTOR_INPUT_EXPORT_HH_
diff --git a/screen_connector_input/key_event_args.cc b/screen_connector_input/key_event_args.cc
new file mode 100644 (file)
index 0000000..5856f21
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#include "screen_connector_input/key_event_args.hh"
+#include "screen_connector_input/key_event_args_implementation.hh"
+
+#include "screen_connector_input/log_private.hh"
+
+namespace screen_connector {
+namespace input {
+
+KeyEventArgs::Impl::Impl(KeyEventArgs* parent, int event_type, int key_code,
+    std::string key_name, long long cls, long long subcls,
+    std::string identifier, long long timestamp)
+    : parent_(parent), event_type_(event_type), key_code_(key_code),
+      key_name_(std::move(key_name)), cls_(cls), subcls_(subcls),
+      identifier_(std::move(identifier)), timestamp_(timestamp) {
+}
+
+KeyEventArgs::Impl::~Impl() = default;
+
+int KeyEventArgs::Impl::GetEventType() const {
+  return event_type_;
+}
+
+int KeyEventArgs::Impl::GetKeyCode() const {
+  return key_code_;
+}
+
+const std::string& KeyEventArgs::Impl::GetKeyName() const {
+  return key_name_;
+}
+
+long long KeyEventArgs::Impl::GetClass() const {
+  return cls_;
+}
+
+long long KeyEventArgs::Impl::GetSubClass() const {
+  return subcls_;
+}
+
+const std::string& KeyEventArgs::Impl::GetIdentifier() const {
+  return identifier_;
+}
+
+long long KeyEventArgs::Impl::GetTimestamp() const {
+  return timestamp_;
+}
+
+KeyEventArgs::KeyEventArgs(int event_type, int key_code, std::string key_name,
+    long long cls, long long subcls, std::string identifier,
+    long long timestamp)
+    : impl_(new Impl(this, event_type, key_code, std::move(key_name), cls,
+          subcls, std::move(identifier), timestamp)) {
+}
+
+KeyEventArgs::~KeyEventArgs() = default;
+
+int KeyEventArgs::GetEventType() const {
+  return impl_->GetEventType();
+}
+
+int KeyEventArgs::GetKeyCode() const {
+  return impl_->GetKeyCode();
+}
+
+const std::string& KeyEventArgs::GetKeyName() const {
+  return impl_->GetKeyName();
+}
+
+long long KeyEventArgs::GetClass() const {
+  return impl_->GetClass();
+}
+
+long long KeyEventArgs::GetSubClass() const {
+  return impl_->GetSubClass();
+}
+
+const std::string& KeyEventArgs::GetIdentifier() const {
+  return impl_->GetIdentifier();
+}
+
+long long KeyEventArgs::GetTimestamp() const {
+  return impl_->GetTimestamp();
+}
+
+}  // namespace input
+}  // namespace screen_connector
diff --git a/screen_connector_input/key_event_args.hh b/screen_connector_input/key_event_args.hh
new file mode 100644 (file)
index 0000000..9cdc9cb
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_INPUT_KEY_EVENT_ARGS_HH_
+#define SCREEN_CONNECTOR_INPUT_KEY_EVENT_ARGS_HH_
+
+#include <memory>
+#include <string>
+
+#include <screen_connector_input/export.hh>
+
+namespace screen_connector {
+namespace input {
+
+class EXPORT KeyEventArgs {
+ public:
+  KeyEventArgs(int event_type, int key_code, std::string key_name,
+      long long cls, long long subcls, std::string identifer,
+      long long timestamp);
+  virtual ~KeyEventArgs();
+
+  int GetEventType() const;
+  int GetKeyCode() const;
+  const std::string& GetKeyName() const;
+  long long GetClass() const;
+  long long GetSubClass() const;
+  const std::string& GetIdentifier() const;
+  long long GetTimestamp() const;
+
+ private:
+  class Impl;
+  std::unique_ptr<Impl> impl_;
+};
+
+}  // namespace input
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_INPUT_KEY_EVENT_ARGS_HH_
diff --git a/screen_connector_input/key_event_args_implementation.hh b/screen_connector_input/key_event_args_implementation.hh
new file mode 100644 (file)
index 0000000..35bbe40
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_INPUT_KEY_EVENT_ARGS_IMPLEMENTATION_HH_
+#define SCREEN_CONNECTOR_INPUT_KEY_EVENT_ARGS_IMPLEMENTATION_HH_
+
+#include <string>
+
+#include "screen_connector_input/key_event_args.hh"
+
+namespace screen_connector {
+namespace input {
+
+class KeyEventArgs::Impl {
+ public:
+  virtual ~Impl();
+
+  int GetEventType() const;
+  int GetKeyCode() const;
+  const std::string& GetKeyName() const;
+  long long GetClass() const;
+  long long GetSubClass() const;
+  const std::string& GetIdentifier() const;
+  long long GetTimestamp() const;
+
+ private:
+  friend class KeyEventArgs;
+
+  Impl(KeyEventArgs* parent, int event_type, int key_code, std::string key_name,
+      long long cls, long long subcls, std::string identifier,
+      long long timestamp);
+
+ private:
+  KeyEventArgs* parent_;
+  int event_type_;
+  int key_code_;
+  std::string key_name_;
+  long long cls_;
+  long long subcls_;
+  std::string identifier_;
+  long long timestamp_;
+};
+
+}  // namespace input
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_INPUT_KEY_EVENT_ARGS_IMPLEMENTATION_HH_
diff --git a/screen_connector_input/log_private.hh b/screen_connector_input/log_private.hh
new file mode 100644 (file)
index 0000000..892b166
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef LOG_PRIVATE_HH_
+#define LOG_PRIVATE_HH_
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "SC_INPUT"
+
+#undef _E
+#define _E LOGE
+
+#undef _W
+#define _W LOGW
+
+#undef _I
+#define _I LOGI
+
+#undef _D
+#define _D LOGD
+
+#endif  // LOG_PRIVATE_HH_
diff --git a/screen_connector_input/proxy.cc b/screen_connector_input/proxy.cc
new file mode 100644 (file)
index 0000000..5a1bde9
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#include "screen_connector_input/proxy.hh"
+#include "screen_connector_input/proxy_implementation.hh"
+
+#include "screen_connector_input/log_private.hh"
+
+namespace screen_connector {
+namespace input {
+
+Proxy::Impl::Impl(Proxy* parent, std::string stub)
+    : parent_(parent),
+      stub_(std::move(stub)),
+      proxy_(new ScreenConnectorInput(this, stub_)) {
+}
+
+Proxy::Impl::~Impl() {}
+
+int Proxy::Impl::Connect() {
+  try {
+    proxy_->Connect();
+  } catch (const InvalidIDException&) {
+    _E("InvalidIDException occurs");
+    return -1;
+  } catch (const InvalidIOException&) {
+    _E("InvalidIOException occurs");
+    return -1;
+  } catch (const PermissionDeniedException&) {
+    _E("PermissionDeniedException occurs");
+    return -1;
+  }
+
+  return 0;
+}
+
+bool Proxy::Impl::IsConnected() const {
+  return connected_;
+}
+
+int Proxy::Impl::SendKeyEvent(std::string instance,
+    const KeyEventArgs& args, bool& skip) {
+  return proxy_->SendKeyEvent(std::move(instance), args.GetEventType(),
+      args.GetKeyCode(), args.GetKeyName(), args.GetClass(), args.GetSubClass(),
+      args.GetIdentifier(), args.GetTimestamp(), skip);
+}
+
+void Proxy::Impl::OnConnected() {
+  connected_ = true;
+}
+
+void Proxy::Impl::OnDisconnected() {
+  connected_ = false;
+}
+
+void Proxy::Impl::OnRejected() {
+  connected_ = false;
+}
+
+Proxy::Proxy(std::string stub) : impl_(new Impl(this, std::move(stub))) {}
+
+Proxy::~Proxy() {}
+
+int Proxy::Connect() {
+  return impl_->Connect();
+}
+
+bool Proxy::IsConnected() const {
+  return impl_->IsConnected();
+}
+
+int Proxy::SendKeyEvent(std::string instance, const KeyEventArgs& args,
+    bool& skip) {
+  return impl_->SendKeyEvent(std::move(instance), args, skip);
+}
+
+}  // namespace input
+}  // namespace screen_connector
diff --git a/screen_connector_input/proxy.hh b/screen_connector_input/proxy.hh
new file mode 100644 (file)
index 0000000..b25f6d4
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_INPUT_PROXY_HH_
+#define SCREEN_CONNECTOR_INPUT_PROXY_HH_
+
+#include <memory>
+#include <string>
+
+#include <screen_connector_input/export.hh>
+#include <screen_connector_input/key_event_args.hh>
+
+namespace screen_connector {
+namespace input {
+
+class EXPORT Proxy {
+ public:
+  Proxy(std::string stub);
+  virtual ~Proxy();
+
+  int Connect();
+  bool IsConnected() const;
+  int SendKeyEvent(std::string instance, const KeyEventArgs& args, bool& skip);
+
+ private:
+  class Impl;
+  std::unique_ptr<Impl> impl_;
+};
+
+}  // namespace input
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_INPUT_PROXY_HH_
diff --git a/screen_connector_input/proxy_implementation.hh b/screen_connector_input/proxy_implementation.hh
new file mode 100644 (file)
index 0000000..648c8c0
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_INPUT_PROXY_IMPLEMENTATION_HH_
+#define SCREEN_CONNECTOR_INPUT_PROXY_IMPLEMENTATION_HH_
+
+#include <memory>
+#include <string>
+
+#include "screen_connector_input/proxy.hh"
+#include "screen_connector_input/screen_connector_input_proxy.h"
+
+namespace screen_connector {
+namespace input {
+
+using namespace rpc_port::screen_connector_input_proxy::proxy;
+
+class Proxy::Impl : public ScreenConnectorInput::IEventListener {
+ public:
+  virtual ~Impl();
+
+  int Connect();
+  bool IsConnected() const;
+  int SendKeyEvent(std::string instance, const KeyEventArgs& args, bool& skip);
+
+  void OnConnected() override;
+  void OnDisconnected() override;
+  void OnRejected() override;
+
+ private:
+  friend class Proxy;
+
+  Impl(Proxy* parent, std::string stub);
+
+ private:
+  Proxy* parent_;
+  std::string stub_;
+  std::unique_ptr<ScreenConnectorInput> proxy_;
+  bool connected_ = false;
+};
+
+}  // namespace input
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_INPUT_PROXY_IMPLEMENTATION_HH_
diff --git a/screen_connector_input/screen_connector_input.pc.in b/screen_connector_input/screen_connector_input.pc.in
new file mode 100644 (file)
index 0000000..1f3ada3
--- /dev/null
@@ -0,0 +1,11 @@
+prefix=@PREFIX@
+exec_prefix=@EXEC_PREFIX@
+libdir=@LIBDIR@
+includedir=@INCLUDEDIR@/@TARGET_SCREEN_CONNECTOR_INPUT@
+
+Name: @TARGET_SCREEN_CONNECTOR_INPUT@
+Description: Support development of the Screen Connector Input library
+Version: @VERSION@
+Libs: -L${libdir} -l@TARGET_SCREEN_CONNECTOR_INPUT@
+Cflags: -I${includedir}
+cppflags: -I${includedir}
diff --git a/screen_connector_input/stub.cc b/screen_connector_input/stub.cc
new file mode 100644 (file)
index 0000000..f3985fd
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#include "screen_connector_input/stub.hh"
+#include "screen_connector_input/stub_implementation.hh"
+
+#include "screen_connector_input/log_private.hh"
+
+namespace screen_connector {
+namespace input {
+
+Stub::Impl::Service::Service(std::string sender, std::string instance,
+    Stub::IEvent* listener)
+    : ScreenConnectorInput::ServiceBase(std::move(sender), std::move(instance)),
+      listener_(listener) {
+}
+
+void Stub::Impl::Service::OnCreate() {
+  _W("%s : %s", GetSender().c_str(), GetInstance().c_str());
+}
+
+void Stub::Impl::Service::OnTerminate() {
+  _W("%s : %s", GetSender().c_str(), GetInstance().c_str());
+}
+
+int Stub::Impl::Service::SendKeyEvent(std::string instance, int event_type,
+    int key_code, std::string key_name, long long cls, long long subcls,
+    std::string identifier, long long timestamp, bool& skip) {
+  if (listener_) {
+    KeyEventArgs args(event_type, key_code, std::move(key_name), cls, subcls,
+        std::move(identifier), timestamp);
+    skip = listener_->OnKeyEventReceived(instance, args);
+  }
+
+  return 0;
+}
+
+Stub::Impl::Factory::Factory(Stub::IEvent* listener)
+    : listener_(listener) {
+}
+
+std::unique_ptr<ScreenConnectorInput::ServiceBase>
+Stub::Impl::Factory::CreateService(std::string sender,
+    std::string instance) {
+  return std::make_unique<Stub::Impl::Service>(
+      std::move(sender), std::move(instance), listener_);
+}
+
+Stub::Impl::Impl(Stub* parent)
+    : parent_(parent), stub_(new ScreenConnectorInput()) {
+}
+
+Stub::Impl::~Impl() = default;
+
+void Stub::Impl::Listen(Stub::IEvent* listener) {
+  try {
+    stub_->Listen(std::make_shared<Stub::Impl::Factory>(listener));
+  } catch (const InvalidIOException& e) {
+    _E("InvalidIOException occurs");
+  }
+}
+
+Stub::Stub() : impl_(new Impl(this)) {}
+
+Stub::~Stub() {}
+
+void Stub::Listen(IEvent* listener) {
+  impl_->Listen(listener);
+}
+
+}  // namespace input
+}  // namespace screen_connector
diff --git a/screen_connector_input/stub.hh b/screen_connector_input/stub.hh
new file mode 100644 (file)
index 0000000..7785bf5
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_INPUT_STUB_HH_
+#define SCREEN_CONNECTOR_INPUT_STUB_HH_
+
+#include <memory>
+#include <string>
+
+#include <screen_connector_input/export.hh>
+#include <screen_connector_input/key_event_args.hh>
+
+namespace screen_connector {
+namespace input {
+
+class EXPORT Stub {
+ public:
+  class IEvent {
+   public:
+    virtual bool OnKeyEventReceived(const std::string& instance,
+        const KeyEventArgs& args) = 0;
+  };
+
+  Stub();
+  virtual ~Stub();
+
+  void Listen(IEvent* listener);
+
+ private:
+  class Impl;
+  std::unique_ptr<Impl> impl_;
+};
+
+}  // namespace input
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_INPUT_STUB_HH_
diff --git a/screen_connector_input/stub_implementation.hh b/screen_connector_input/stub_implementation.hh
new file mode 100644 (file)
index 0000000..b52ff98
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2022 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.
+ */
+
+#ifndef SCREEN_CONNECTOR_INPUT_STUB_IMPLEMENTATION_HH_
+#define SCREEN_CONNECTOR_INPUT_STUB_IMPLEMENTATION_HH_
+
+#include <memory>
+#include <string>
+
+#include "screen_connector_input/stub.hh"
+#include "screen_connector_input/screen_connector_input_stub.h"
+
+namespace screen_connector {
+namespace input {
+
+using namespace rpc_port::screen_connector_input_stub::stub;
+
+class Stub::Impl {
+ public:
+  class Service : public ScreenConnectorInput::ServiceBase {
+   public:
+    Service(std::string sender, std::string instance,
+        Stub::IEvent* listener);
+
+    void OnCreate() override;
+    void OnTerminate() override;
+    int SendKeyEvent(std::string instance, int input_type, int key_code,
+        std::string key_name, long long cls, long long subcls,
+        std::string identifier, long long timestamp, bool& skip) override;
+
+   private:
+    Stub::IEvent* listener_;
+  };
+
+  class Factory : public ScreenConnectorInput::ServiceBase::Factory {
+   public:
+    Factory(Stub::IEvent* listener);
+
+    std::unique_ptr<ScreenConnectorInput::ServiceBase>
+        CreateService(std::string sender, std::string instance) override;
+
+   private:
+    Stub::IEvent* listener_;
+  };
+
+  virtual ~Impl();
+
+  void Listen(Stub::IEvent* listener);
+
+ private:
+  friend class Stub;
+
+  Impl(Stub* parent);
+
+ private:
+  Stub* parent_;
+  std::unique_ptr<ScreenConnectorInput> stub_;
+};
+
+}  // namespace input
+}  // namespace screen_connector
+
+#endif  // SCREEN_CONNECTOR_INPUT_STUB_IMPLEMENTATION_HH_
index 2638e8d..ae9dde9 100644 (file)
@@ -13,6 +13,9 @@ SET_TARGET_PROPERTIES(${TARGET_SCREEN_CONNECTOR_PROVIDER}
 SET_TARGET_PROPERTIES(${TARGET_SCREEN_CONNECTOR_PROVIDER}
   PROPERTIES LINK_FLAGS "-lpthread")
 
+TARGET_LINK_LIBRARIES(${TARGET_SCREEN_CONNECTOR_PROVIDER} PRIVATE
+  ${TARGET_SCREEN_CONNECTOR_INPUT})
+
 TARGET_INCLUDE_DIRECTORIES(${TARGET_SCREEN_CONNECTOR_PROVIDER} PUBLIC
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/../
index a0e9710..51c8de2 100644 (file)
@@ -25,32 +25,50 @@ extern "C" {
 #endif
 
 typedef enum {
-       SCREEN_CONNECTOR_INPUT_TYPE_MOUSE_UP_DOWN =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_UP_DOWN,
-       SCREEN_CONNECTOR_INPUT_TYPE_MOUSE_MOVE_X =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_MOVE_X,
-       SCREEN_CONNECTOR_INPUT_TYPE_MOUSE_MOVE_Y =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_MOVE_Y,
-       SCREEN_CONNECTOR_INPUT_TYPE_MOUSE_MOVE_X_Y =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_MOVE_X_Y,
-       SCREEN_CONNECTOR_INPUT_TYPE_MOUSE_WHEEL =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_WHEEL_ALL,
-       SCREEN_CONNECTOR_INPUT_TYPE_TOUCH_UP_DOWN =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_UP_DOWN,
-       SCREEN_CONNECTOR_INPUT_TYPE_TOUCH_MOVE_X =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_MOVE_X,
-       SCREEN_CONNECTOR_INPUT_TYPE_TOUCH_MOVE_Y =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_MOVE_Y,
-       SCREEN_CONNECTOR_INPUT_TYPE_TOUCH_MOVE_X_Y =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_MOVE_X_Y,
-       SCREEN_CONNECTOR_INPUT_TYPE_TOUCH_CANCEL =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_CANCEL_ALL,
-       SCREEN_CONNECTOR_INPUT_TYPE_KEY =
-               TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_KEY_ALL,
+  SCREEN_CONNECTOR_INPUT_TYPE_MOUSE_UP_DOWN = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_UP_DOWN,
+  SCREEN_CONNECTOR_INPUT_TYPE_MOUSE_MOVE_X = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_MOVE_X,
+  SCREEN_CONNECTOR_INPUT_TYPE_MOUSE_MOVE_Y = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_MOVE_Y,
+  SCREEN_CONNECTOR_INPUT_TYPE_MOUSE_MOVE_X_Y = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_MOVE_X_Y,
+  SCREEN_CONNECTOR_INPUT_TYPE_MOUSE_WHEEL = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_MOUSE_WHEEL_ALL,
+  SCREEN_CONNECTOR_INPUT_TYPE_TOUCH_UP_DOWN = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_UP_DOWN,
+  SCREEN_CONNECTOR_INPUT_TYPE_TOUCH_MOVE_X = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_MOVE_X,
+  SCREEN_CONNECTOR_INPUT_TYPE_TOUCH_MOVE_Y = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_MOVE_Y,
+  SCREEN_CONNECTOR_INPUT_TYPE_TOUCH_MOVE_X_Y = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_MOVE_X_Y,
+  SCREEN_CONNECTOR_INPUT_TYPE_TOUCH_CANCEL = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_TOUCH_CANCEL_ALL,
+  SCREEN_CONNECTOR_INPUT_TYPE_KEY = TIZEN_REMOTE_SURFACE_INPUT_EVENT_FILTER_KEY_ALL,
 } screen_connector_input_type_e;
 
+typedef enum {
+  SCREEN_CONNECTOR_EVENT_TYPE_NONE,
+  SCREEN_CONNECTOR_EVENT_TYPE_MOUSE_DOWN,
+  SCREEN_CONNECTOR_EVENT_TYPE_MOUSE_UP,
+  SCREEN_CONNECTOR_EVENT_TYPE_MOUSE_MOVE,
+  SCREEN_CONNECTOR_EVENT_TYPE_TOUCH_DOWN,
+  SCREEN_CONNECTOR_EVENT_TYPE_TOUCH_UP,
+  SCREEN_CONNECTOR_EVENT_TYPE_TOUCH_MOVE,
+  SCREEN_CONNECTOR_EVENT_TYPE_KEY_DOWN,
+  SCREEN_CONNECTOR_EVENT_TYPE_KEY_UP,
+  SCREEN_CONNECTOR_EVENT_TYPE_MOUSE_IN,
+  SCREEN_CONNECTOR_EVENT_TYPE_MOUSE_OUT,
+  SCREEN_CONNECTOR_EVENT_TYPE_KEY_CANCEL,
+} screen_connector_event_type_e;
+
 typedef void *screen_connector_provider_h;
 
+/**
+ * The @id is the instance ID.
+ * The @identifier is the key ID.
+ */
+typedef bool (*screen_connector_provider_key_event_cb)(const char *id,
+               screen_connector_event_type_e event_type,
+               int key_code, const char *key_name, long long cls,
+               long long subcls, const char* identifier, long long timestamp,
+               void *user_data);
+
+void screen_connector_provider_set_key_event_cb(
+               screen_connector_provider_key_event_cb callback,
+               void *user_data);
+
 int screen_connector_provider_remote_enable(const char *id,
                struct wl_surface *surface);
 
index 4880285..9d28355 100644 (file)
@@ -32,6 +32,9 @@ bool RemoteSurfaceManager::Init() {
     return true;
   }
 
+  input_stub_.reset(new input::Stub());
+  input_stub_->Listen(this);
+
   if (!ecore_wl2_init()) {
     _E("ecore_wl2_init() is failed");
     return false;
@@ -195,12 +198,28 @@ bool RemoteSurfaceManager::Remove(const std::string& id) {
   return true;
 }
 
+void RemoteSurfaceManager::SetEventListener(
+    RemoteSurfaceManager::IEvent* listener) {
+  listener_ = listener;
+}
+
 RemoteSurfaceManager::RemoteSurfaceManager() = default;
 
 RemoteSurfaceManager::~RemoteSurfaceManager() {
   Dispose();
 }
 
+bool RemoteSurfaceManager::OnKeyEventReceived(const std::string& instance,
+    const input::KeyEventArgs& args) {
+  if (listener_) {
+    return listener_->OnKeyEventReceived(instance, args.GetEventType(),
+        args.GetKeyCode(), args.GetKeyName(), args.GetClass(),
+        args.GetSubClass(), args.GetIdentifier(), args.GetTimestamp());
+  }
+
+  return false;
+}
+
 void RemoteSurfaceManager::ResourceIdCb(void* user_data,
     struct tizen_remote_surface_provider* provider, uint32_t res_id) {
   auto* rsp = static_cast<RemoteSurfaceProvider*>(user_data);
index ca48a77..bb0b471 100644 (file)
 #include <memory>
 #include <string>
 
+#include <screen_connector_input/stub.hh>
+
 #include "remote_surface_provider.hh"
 
 namespace screen_connector {
 namespace provider {
 
-class RemoteSurfaceManager {
+class RemoteSurfaceManager : public input::Stub::IEvent {
  public:
+  class IEvent {
+   public:
+    virtual ~IEvent() = default;
+    virtual bool OnKeyEventReceived(const std::string& id, int event_type,
+        int key_code, const std::string& key_name, long long cls,
+        long long subcls, const std::string& identifier,
+        long long timestamp) = 0;
+  };
+
   RemoteSurfaceManager(const RemoteSurfaceManager&) = delete;
   RemoteSurfaceManager& operator = (const RemoteSurfaceManager&) = delete;
 
@@ -44,11 +55,14 @@ class RemoteSurfaceManager {
       struct wl_surface* surface);
   void Insert(std::string id, std::unique_ptr<RemoteSurfaceProvider> provider);
   bool Remove(const std::string& id);
+  void SetEventListener(IEvent* listener);
 
  private:
   RemoteSurfaceManager();
   ~RemoteSurfaceManager();
   void Dispose();
+  bool OnKeyEventReceived(const std::string& instance,
+      const input::KeyEventArgs& args) override;
 
   static void ResourceIdCb(void* user_data,
       struct tizen_remote_surface_provider* provider, uint32_t res_id);
@@ -57,7 +71,9 @@ class RemoteSurfaceManager {
 
  private:
   std::atomic<int> ref_ { 0 };
+  IEvent* listener_ = nullptr;
   struct tizen_remote_surface_manager* rsm_ = nullptr;
+  std::unique_ptr<input::Stub> input_stub_;
   std::map<std::string, std::unique_ptr<RemoteSurfaceProvider>> providers_;
 };
 
index 16207d6..219b61c 100644 (file)
 
 using namespace screen_connector::provider;
 
+namespace {
+
+class KeyEventCb : public RemoteSurfaceManager::IEvent {
+ public:
+  KeyEventCb() {
+    RemoteSurfaceManager::GetInst().SetEventListener(this);
+  }
+
+  void SetCallback(screen_connector_provider_key_event_cb cb, void* user_data) {
+    cb_ = cb;
+    user_data_ = user_data;
+  }
+
+ private:
+  bool OnKeyEventReceived(const std::string& instance, int event_type,
+      int key_code, const std::string& key_name, long long cls,
+      long long subcls, const std::string& identifier, long long time) {
+    if (cb_) {
+      return cb_(instance.c_str(),
+          static_cast<screen_connector_event_type_e>(event_type), key_code,
+          key_name.c_str(), cls, subcls, identifier.c_str(), time, user_data_);
+    }
+
+    return false;
+  }
+
+ private:
+  screen_connector_provider_key_event_cb cb_ = nullptr;
+  void* user_data_ = nullptr;
+};
+
+KeyEventCb key_event_cb;
+
+}  // namespace
+
+EXPORT void screen_connector_provider_set_key_event_cb(
+    screen_connector_provider_key_event_cb callback, void* user_data) {
+  key_event_cb.SetCallback(callback, user_data);
+}
+
 EXPORT screen_connector_provider_h screen_connector_provider_create(
     const char* id, struct wl_surface* surface) {
   if (id == nullptr || surface == nullptr) {
index 332ec72..84bbb00 100644 (file)
@@ -11,6 +11,9 @@ SET_TARGET_PROPERTIES(${TARGET_SCREEN_CONNECTOR_REMOTE_SURFACE}
 SET_TARGET_PROPERTIES(${TARGET_SCREEN_CONNECTOR_REMOTE_SURFACE}
   PROPERTIES COMPILE_FLAGS ${CLFAGS} "-fpic")
 
+TARGET_LINK_LIBRARIES(${TARGET_SCREEN_CONNECTOR_REMOTE_SURFACE} PRIVATE
+  ${TARGET_SCREEN_CONNECTOR_INPUT})
+
 TARGET_INCLUDE_DIRECTORIES(${TARGET_SCREEN_CONNECTOR_REMOTE_SURFACE} PUBLIC
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/../
index 7b166a1..9f87d48 100644 (file)
@@ -60,7 +60,8 @@ RemoteSurface::Impl::Impl(RemoteSurface* parent,
       aul_handle_(mock ?
           new test::AulHandleMock(this, (aul_screen_type_e)type) :
           new AulHandle(this, (aul_screen_type_e)type)),
-      type_(type), parent_(parent), mock_(mock) {
+      type_(type), parent_(parent), mock_(mock),
+      input_proxy_(nullptr) {
 }
 
 RemoteSurface::Impl::Impl(RemoteSurface* parent, int rid,
@@ -90,6 +91,11 @@ void RemoteSurface::Impl::OnAppAdded(const std::string &appId,
   pid_ = pid;
   parent_->OnBufferAdded(appId, instId, pid);
   Redirect();
+
+  if (input_proxy_.get() == nullptr) {
+    input_proxy_.reset(new input::Proxy(appId));
+    input_proxy_->Connect();
+  }
 }
 
 void RemoteSurface::Impl::OnAppRemoved(const std::string& appId,
@@ -133,6 +139,18 @@ void RemoteSurface::Impl::OnAppFocused(const std::string& appId,
                                        const unsigned int surfaceId) {
 }
 
+bool RemoteSurface::Impl::SendKeyEvent(const input::KeyEventArgs& args) {
+  if (!input_proxy_->IsConnected())
+    return false;
+
+  bool skip = false;
+  int ret = input_proxy_->SendKeyEvent(inst_id_, args, skip);
+  if (ret != 0)
+    LOGE("SendKeyEvent() is failed. error(%d)", ret);
+
+  return skip;
+}
+
 RemoteSurface::RemoteSurface(const std::string& id, Type type,
       std::shared_ptr<WlSurface> wl_surface, bool mock)
     : impl_(new Impl(this, id, type, std::move(wl_surface), mock)) {
@@ -337,6 +355,10 @@ void RemoteSurface::Thaw() {
   impl_->freeze_ = false;
 }
 
+bool RemoteSurface::SendKeyEvent(const input::KeyEventArgs& args) {
+  return impl_->SendKeyEvent(args);
+}
+
 RemoteSurface::ChangedEventFilter RemoteSurface::GetChangedEventFilter() const {
   return impl_->changed_event_filter_;
 }
index edf6da3..afb013c 100644 (file)
@@ -20,6 +20,8 @@
 #include <string>
 #include <memory>
 
+#include <screen_connector_input/key_event_args.hh>
+
 #include "screen_connector_remote_surface/buffer_event_interface.h"
 #include "screen_connector_remote_surface/trs_interface.h"
 #include "screen_connector_remote_surface/common.h"
@@ -72,6 +74,8 @@ class EXPORT_API RemoteSurface : public IBufferEvent {
   void SetBlock(bool is_block);
   virtual void Unbind();
   bool IsBound() const;
+  bool SendKeyEvent(const input::KeyEventArgs& args);
+
   void OnBufferAdded(const std::string& appId,
                      const std::string& instId, int pid) override;
   void OnBufferRemoved(const std::string& appId,
index dcc870f..53ccf18 100644 (file)
@@ -23,6 +23,8 @@
 #include <memory>
 #include <map>
 
+#include <screen_connector_input/proxy.hh>
+
 #include "screen_connector_remote_surface/buffer_event_interface.h"
 #include "screen_connector_remote_surface/common.h"
 #include "screen_connector_remote_surface/remote_surface.h"
@@ -45,6 +47,7 @@ class RemoteSurface::Impl : AulHandle::IEventListener, ITRS::IEventListener {
   void OnRawBufferChanged(int type, std::shared_ptr<WlBuffer> tbm, int fd,
                           uint32_t size, uint32_t time) override;
   void OnInputFilterChanged(uint32_t event_filter) override;
+  bool SendKeyEvent(const input::KeyEventArgs& args);
 
   virtual ~Impl();
 
@@ -84,6 +87,7 @@ class RemoteSurface::Impl : AulHandle::IEventListener, ITRS::IEventListener {
   RemoteSurface* parent_;
   bool mock_;
   std::unique_ptr<bool> queuing_visibility_;
+  std::unique_ptr<input::Proxy> input_proxy_;
   bool disposed_ = false;
 };
 
index 9fa39c2..5325ea6 100644 (file)
@@ -6,7 +6,7 @@ includedir=@INCLUDEDIR@/@TARGET_SCREEN_CONNECTOR_REMOTE_SURFACE@
 Name: @TARGET_SCREEN_CONNECTOR_REMOTE_SURFACE@
 Description: Support development of the screen connector remote surface library
 Version: @VERSION@
-Requires: ecore-wl2
+Requires: ecore-wl2 @TARGET_SCREEN_CONNECTOR_INPUT@
 Libs: -L${libdir} -l@TARGET_SCREEN_CONNECTOR_REMOTE_SURFACE@
 Cflags: -I${includedir}
 cppflags: -I${includedir}
index fd4e4c3..484f7ae 100644 (file)
@@ -38,13 +38,28 @@ typedef enum {
 } screen_connector_input_type_e;
 
 typedef enum {
-       SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET = AUL_SCREEN_TYPE_WIDGET,
-       SCREEN_CONNECTOR_SCREEN_TYPE_WATCH = AUL_SCREEN_TYPE_WATCH,
-       SCREEN_CONNECTOR_SCREEN_TYPE_UI = AUL_SCREEN_TYPE_UI,
-       SCREEN_CONNECTOR_SCREEN_TYPE_COMPONENT_BASED = AUL_SCREEN_TYPE_COMPONENT_BASED,
-       SCREEN_CONNECTOR_SCREEN_TYPE_ALL = AUL_SCREEN_TYPE_ALL,
+  SCREEN_CONNECTOR_SCREEN_TYPE_WIDGET = AUL_SCREEN_TYPE_WIDGET,
+  SCREEN_CONNECTOR_SCREEN_TYPE_WATCH = AUL_SCREEN_TYPE_WATCH,
+  SCREEN_CONNECTOR_SCREEN_TYPE_UI = AUL_SCREEN_TYPE_UI,
+  SCREEN_CONNECTOR_SCREEN_TYPE_COMPONENT_BASED = AUL_SCREEN_TYPE_COMPONENT_BASED,
+  SCREEN_CONNECTOR_SCREEN_TYPE_ALL = AUL_SCREEN_TYPE_ALL,
 } screen_connector_screen_type_e;
 
+typedef enum {
+  SCREEN_CONNECTOR_EVENT_TYPE_NONE,
+  SCREEN_CONNECTOR_EVENT_TYPE_MOUSE_DOWN,
+  SCREEN_CONNECTOR_EVENT_TYPE_MOUSE_UP,
+  SCREEN_CONNECTOR_EVENT_TYPE_MOUSE_MOVE,
+  SCREEN_CONNECTOR_EVENT_TYPE_TOUCH_DOWN,
+  SCREEN_CONNECTOR_EVENT_TYPE_TOUCH_UP,
+  SCREEN_CONNECTOR_EVENT_TYPE_TOUCH_MOVE,
+  SCREEN_CONNECTOR_EVENT_TYPE_KEY_DOWN,
+  SCREEN_CONNECTOR_EVENT_TYPE_KEY_UP,
+  SCREEN_CONNECTOR_EVENT_TYPE_MOUSE_IN,
+  SCREEN_CONNECTOR_EVENT_TYPE_MOUSE_OUT,
+  SCREEN_CONNECTOR_EVENT_TYPE_KEY_CANCEL,
+} screen_connector_event_type_e;
+
 typedef void (*screen_connector_toolkit_added_cb)(const char* appid,
     const char* instance_id, const int pid, void* data);
 typedef void (*screen_connector_toolkit_removed_cb)(const char* appid,
@@ -103,6 +118,10 @@ int screen_connector_toolkit_set_changed_event_filter(
     screen_connector_changed_event_filter_type type);
 int screen_connector_toolkit_dispose_buffer(screen_connector_toolkit_h handle,
     const struct wl_buffer* tbm);
+int screen_connector_toolkit_send_key_event(screen_connector_toolkit_h h,
+    screen_connector_event_type_e event_type, int key_code,
+    const char* key_name, long long cls, long long subcls,
+    const char* identifier, long long timestamp, bool* skip);
 
 #ifdef __cplusplus
 }
index 7f43929..d078327 100644 (file)
@@ -340,3 +340,18 @@ screen_connector_toolkit_dispose_buffer(screen_connector_toolkit_h handle,
   rs->DisposeBuffer(tbm);
   return 0;
 }
+
+extern "C" EXPORT_API int
+screen_connector_toolkit_send_key_event(screen_connector_toolkit_h handle,
+    screen_connector_event_type_e event_type, int key_code,
+    const char* key_name, long long cls, long long subcls,
+    const char* identifier, long long timestamp, bool* skip) {
+  if (handle == nullptr || key_name == nullptr)
+    return -1;
+
+  screen_connector::input::KeyEventArgs args(static_cast<int>(event_type),
+      key_code, key_name, cls, subcls, identifier, timestamp);
+  auto* rs = static_cast<RemoteSurfaceToolkit*>(handle);
+  *skip = rs->SendKeyEvent(args);
+  return 0;
+}
diff --git a/tidl/screen_connector_input.tidl b/tidl/screen_connector_input.tidl
new file mode 100644 (file)
index 0000000..3e38592
--- /dev/null
@@ -0,0 +1,3 @@
+interface ScreenConnectorInput {
+  int SendKeyEvent(string instance, int event_type, int key_code, string key_name, long cls, long subcls, string id, long time, out bool skip);
+}