Handling key down/up events 94/237194/3
authorhyunho <hhstark.kang@samsung.com>
Fri, 26 Jun 2020 02:01:22 +0000 (11:01 +0900)
committerhyunho <hhstark.kang@samsung.com>
Fri, 26 Jun 2020 04:28:54 +0000 (13:28 +0900)
Change-Id: I02ff28d7e4f8e261b83ef837ebe4ae99c6dbee41
Signed-off-by: hyunho <hhstark.kang@samsung.com>
screen_connector_remote_surface/ecore_event_handler_internal.h
screen_connector_remote_surface/trs_interface.h
screen_connector_remote_surface/trs_internal.h
screen_connector_remote_surface/trs_mock_internal.h
screen_connector_remote_surface_evas/image_event_listener.cc
screen_connector_remote_surface_evas/image_event_listener.h
screen_connector_remote_surface_mock/trs_interface.h

index dff7a03..2dfc715 100644 (file)
@@ -47,7 +47,7 @@ class EcoreEventHandler {
         EcoreEventCB, listener_);
     visibility_change_ = ecore_event_handler_add(
         ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE,
-       EcoreEventCB, listener_);
+        EcoreEventCB, listener_);
     pre_visibility_change_ = ecore_event_handler_add(
         ECORE_WL2_EVENT_WINDOW_PRE_VISIBILITY_CHANGE,
         EcoreEventCB, listener_);
index 9b8d250..242a3c8 100644 (file)
@@ -72,6 +72,9 @@ class EXPORT_API ITRS {
                                   wl_fixed_t pressure, wl_fixed_t angle,
                                   uint32_t clas, uint32_t subclas,
                                   const char *identifier, uint32_t time) = 0;
+  virtual void TransferKeyEvent(uint32_t event_type, int32_t keycode,
+                                  uint32_t clas, uint32_t subclas,
+                                  const char *identifier, uint32_t time) = 0;
   virtual void TransferMouseWheel(uint32_t direction, int32_t z, uint32_t clas,
                                   uint32_t subclas, const char *identifier,
                                   uint32_t time) = 0;
index ff2ad4b..c9689e5 100644 (file)
@@ -105,6 +105,13 @@ class TRS : public Handle<struct tizen_remote_surface*>, public ITRS {
         identifier, time);
   }
 
+  void TransferKeyEvent(uint32_t event_type, int32_t keycode,
+                          uint32_t clas, uint32_t subclas,
+                          const char *identifier, uint32_t time) override {
+    tizen_remote_surface_transfer_key_event(GetRaw(), event_type, keycode, clas,
+        subclas, identifier, time);
+  }
+
   void TransferMouseEvent(uint32_t event_type, int32_t device,
                           int32_t button, int32_t x, int32_t y,
                           wl_fixed_t radius_x, wl_fixed_t radius_y,
index e08d765..000afb5 100644 (file)
@@ -87,6 +87,11 @@ class TRSMock : public TRS {
                           const char *identifier, uint32_t time) override {
   }
 
+  void TransferKeyEvent(uint32_t event_type, int32_t keycode,
+                          uint32_t clas, uint32_t subclas,
+                          const char *identifier, uint32_t time) override {
+  }
+
   void TransferMouseWheel(uint32_t direction, int32_t z, uint32_t clas,
                           uint32_t subclas, const char *identifier,
                           uint32_t time) override {
index 9f66c67..ee10c22 100644 (file)
 namespace screen_connector {
 
 ImageEventListener::ImageEventListener(RemoteSurface* parent)
-  : parent_(parent), is_flick_enabled_(parent->GetType() == RemoteSurface::Type::WATCH) {
+  : parent_(parent),
+    is_flick_enabled_(parent->GetType() == RemoteSurface::Type::WATCH) {
+  if (is_flick_enabled_) {
+    key_down_ = ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
+        KeyDownCb, this);
+    key_up_ = ecore_event_handler_add(ECORE_EVENT_KEY_UP,
+        KeyUpCb, this);
+  }
+}
+
+ImageEventListener::~ImageEventListener() {
+  if (key_down_)
+    ecore_event_handler_del(key_down_);
+  if (key_up_)
+    ecore_event_handler_del(key_up_);
+}
+
+Eina_Bool ImageEventListener::KeyUpCb(void* data, int type, void* event) {
+  ImageEventListener* listener = static_cast<ImageEventListener*>(data);
+  Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
+  listener->OnUpKey(keyEvent);
+  return ECORE_CALLBACK_RENEW;
+}
+
+Eina_Bool ImageEventListener::KeyDownCb(void* data, int type, void* event) {
+  ImageEventListener* listener = static_cast<ImageEventListener*>(data);
+  Ecore_Event_Key* keyEvent = static_cast<Ecore_Event_Key*>(event);
+  listener->OnDownKey(keyEvent);
+  return ECORE_CALLBACK_RENEW;
+}
+
+void ImageEventListener::OnDownKey(void* eventInfo) {
+  if (eventInfo == nullptr) {
+    LOGE("Null eventinfo");
+    return;
+  }
+
+  Ecore_Event_Key* info = static_cast<Ecore_Event_Key*>(eventInfo);
+  LOGI("Down key (%d)", info->keycode);
+
+  const char* desc = ecore_device_description_get(info->dev);
+  if (desc == nullptr)
+    desc = "";
+  parent_->GetRaw()->TransferKeyEvent(TIZEN_REMOTE_SURFACE_EVENT_TYPE_KEY_DOWN,
+      info->keycode,
+      ecore_device_class_get(info->dev),
+      ecore_device_subclass_get(info->dev),
+      desc,
+      info->timestamp);
+}
+
+void ImageEventListener::OnUpKey(void* eventInfo) {
+  if (eventInfo == nullptr) {
+    LOGE("Null eventinfo");
+    return;
+  }
+  Ecore_Event_Key* info = static_cast<Ecore_Event_Key*>(eventInfo);
+  LOGI("Up key (%d)", info->keycode);
+
+  const char* desc = ecore_device_description_get(info->dev);
+  if (desc == nullptr)
+    desc = "";
+  parent_->GetRaw()->TransferKeyEvent(TIZEN_REMOTE_SURFACE_EVENT_TYPE_KEY_UP,
+      info->keycode,
+      ecore_device_class_get(info->dev),
+      ecore_device_subclass_get(info->dev),
+      desc,
+      info->timestamp);
 }
 
 void ImageEventListener::OnMouseIn(const EvasObject& obj,
index e394513..9840bc4 100644 (file)
@@ -20,6 +20,8 @@
 #include <memory>
 #include <string>
 
+#include <Ecore_Wl2.h>
+
 #include "screen_connector_remote_surface_evas/evas_object.h"
 #include "screen_connector_remote_surface/remote_surface.h"
 #include "screen_connector_remote_surface/trs_interface.h"
@@ -29,6 +31,7 @@ namespace screen_connector {
 class EXPORT_API ImageEventListener {
  public:
   ImageEventListener(RemoteSurface* parent);
+  virtual ~ImageEventListener();
   virtual void OnMouseIn(const EvasObject& obj, void* eventInfo);
   virtual void OnMouseOut(const EvasObject& obj, void* eventInfo);
   virtual void OnMouseDown(const EvasObject& obj, void* eventInfo);
@@ -41,16 +44,24 @@ class EXPORT_API ImageEventListener {
   virtual void OnShow(const EvasObject& obj, void* eventInfo);
   virtual void OnHide(const EvasObject& obj, void* eventInfo);
   virtual void OnResize(const EvasObject& obj, void* eventInfo);
+  virtual void OnDownKey(void* eventInfo);
+  virtual void OnUpKey(void* eventInfo);
   void SetInputEventFilter(uint32_t filter);
   bool IsDisabledInput(ITRS::InputType type);
   bool IsFlickEnabled(bool enable);
 
  private:
+  static Eina_Bool KeyUpCb(void* data, int type, void* event);
+  static Eina_Bool KeyDownCb(void* data, int type, void* event);
+
+ private:
   RemoteSurface* parent_ = nullptr;
   bool is_flick_enabled_ = false;
   uint32_t input_event_filter_ = 0;
   bool flick_ = false;
   int prev_y_ = 0;
+  Ecore_Event_Handler* key_down_ = nullptr;
+  Ecore_Event_Handler* key_up_ = nullptr;
 };
 }
 
index 3a3a9c9..ba9218f 100644 (file)
@@ -57,6 +57,9 @@ class ITRS {
                                   wl_fixed_t pressure, wl_fixed_t angle,
                                   uint32_t clas, uint32_t subclas,
                                   const char *identifier, uint32_t time) = 0;
+  virtual void TransferKeyEvent(uint32_t event_type, int32_t keycode,
+                                  uint32_t clas, uint32_t subclas,
+                                  const char *identifier, uint32_t time) = 0;
   virtual void TransferMouseWheel(uint32_t direction, int32_t z, uint32_t clas,
                                   uint32_t subclas, const char *identifier,
                                   uint32_t time) = 0;