feature: Add a protocol/logic to generate a wheel event
authorWonki Kim <wonki_.kim@samsung.com>
Wed, 3 Jun 2020 10:31:06 +0000 (19:31 +0900)
committerJongmin Lee <jm105.lee@samsung.com>
Sun, 7 Jun 2020 22:41:45 +0000 (07:41 +0900)
wheel event is originally from pointer input device such as mouse.
however this feature provides wheel up/down functionalities
by handling them as hardware key input.

Change-Id: Ic3a7618efc6bb759b7a4f4bd4ae3559b5e4f6d1f

libaurum/inc/DeviceImpl/TizenImpl.h
libaurum/inc/IDevice.h
libaurum/inc/UiDevice.h
libaurum/src/DeviceImpl/TizenImpl.cc
libaurum/src/UiDevice.cc
org.tizen.aurum-bootstrap/src/Commands/SendKeyCommand.cc
protocol/aurum.proto

index 1335356..136c669 100644 (file)
@@ -23,6 +23,9 @@ public:
     bool touchMove(const int x, const int y) override;
     bool touchUp(const int x, const int y) override;
 
+    bool wheelUp(int amount, const int durationMs) override;
+    bool wheelDown(int amount, const int durationMs) override;
+
     bool pressBack() override;
     bool pressHome() override;
     bool pressMenu() override;
@@ -39,6 +42,7 @@ protected:
 private:
     efl_util_inputgen_h mFakeTouchHandle;
     efl_util_inputgen_h mFakeKeyboardHandle;
+    efl_util_inputgen_h mFakeWheelHandle;
     static const unsigned int INTV_CLICK = 5;
     static const unsigned int INTV_KEYPRESS = 10;
 };
index 5be9580..27c1ae5 100644 (file)
@@ -22,6 +22,9 @@ public:
     virtual bool touchMove(const int x, const int y) = 0;
     virtual bool touchUp(const int x, const int y) = 0;
 
+    virtual bool wheelUp(int amount, const int durationMs) = 0;
+    virtual bool wheelDown(int amount, const int durationMs) = 0;
+
     virtual bool pressBack() = 0;
     virtual bool pressHome() = 0;
     virtual bool pressMenu() = 0;
index 46634a3..3ac4658 100644 (file)
@@ -31,6 +31,9 @@ public:
     bool touchMove(const int x, const int y) override;
     bool touchUp(const int x, const int y) override;
 
+    bool wheelUp(int amount, const int durationMs) override;
+    bool wheelDown(int amount, const int durationMs) override;
+
     bool pressBack() override;
     bool pressHome() override;
     bool pressMenu() override;
index d20f069..747baaf 100644 (file)
@@ -18,6 +18,7 @@ TizenImpl::TizenImpl()
         obj->mFakeTouchHandle = efl_util_input_initialize_generator(EFL_UTIL_INPUT_DEVTYPE_TOUCHSCREEN);
         obj->mFakeKeyboardHandle =
             efl_util_input_initialize_generator(EFL_UTIL_INPUT_DEVTYPE_KEYBOARD);
+        obj->mFakeWheelHandle = efl_util_input_initialize_generator(EFL_UTIL_INPUT_DEVTYPE_POINTER);
         return NULL;
     }, this);
 }
@@ -28,6 +29,7 @@ TizenImpl::~TizenImpl()
         TizenImpl *obj = static_cast<TizenImpl*>(data);
         efl_util_input_deinitialize_generator(obj->mFakeTouchHandle);
         efl_util_input_deinitialize_generator(obj->mFakeKeyboardHandle);
+        efl_util_input_deinitialize_generator(obj->mFakeWheelHandle);
         return NULL;
     }, this);
 }
@@ -108,6 +110,40 @@ bool TizenImpl::touchUp(const int x, const int y)
     return true;
 }
 
+bool TizenImpl::wheelUp(int amount, const int durationMs)
+{
+    LOG_F(INFO, "wheel up %d for %d", amount, durationMs);
+    auto args = std::make_tuple(this);
+    for (int i = 0; i < amount; i++){
+        ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
+                TizenImpl *obj;
+                std::tie(obj) = *static_cast<std::tuple<TizenImpl*>*>(data);
+                efl_util_input_generate_wheel(obj->mFakeWheelHandle, EFL_UTIL_INPUT_POINTER_WHEEL_HORZ, 1);
+            return NULL;
+        }, (void*)(&args));
+        usleep(durationMs*1000/amount);
+    }
+
+    return true;
+}
+
+bool TizenImpl::wheelDown(int amount, const int durationMs)
+{
+    LOG_F(INFO, "wheel down %d for %d", amount, durationMs);
+    auto args = std::make_tuple(this);
+    for (int i = 0; i < amount; i++){
+        ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
+                TizenImpl *obj;
+                std::tie(obj) = *static_cast<std::tuple<TizenImpl*>*>(data);
+                efl_util_input_generate_wheel(obj->mFakeWheelHandle, EFL_UTIL_INPUT_POINTER_WHEEL_HORZ, -1);
+            return NULL;
+        }, (void*)(&args));
+        usleep(durationMs*1000/amount);
+    }
+
+    return true;
+}
+
 bool TizenImpl::drag(const int sx, const int sy, const int ex, const int ey,
                          const int steps, const int durationMs)
 {
index bdb0cbd..1db82d0 100644 (file)
@@ -134,6 +134,20 @@ bool UiDevice::touchUp(const int x, const int y)
     return result;
 }
 
+bool UiDevice::wheelUp(int amount, const int durationMs)
+{
+    bool result =  mDeviceImpl->wheelUp(amount, durationMs);
+    waitForIdle();
+    return result;
+}
+
+bool UiDevice::wheelDown(int amount, const int durationMs)
+{
+    bool result =  mDeviceImpl->wheelDown(amount, durationMs);
+    waitForIdle();
+    return result;
+}
+
 bool UiDevice::pressBack()
 {
     bool result =  mDeviceImpl->pressBack();
index 7897a7f..c8c941a 100644 (file)
@@ -27,6 +27,10 @@ SendKeyCommand::SendKeyCommand(const ::aurum::ReqKey* request,
         mDevice->pressVolDown();
     else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_POWER)
         mDevice->pressPower();
+    else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_WHEELUP)
+        mDevice->wheelUp(1,167);
+    else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_WHEELDOWN)
+        mDevice->wheelDown(1,167);
     else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_KEY) {
         ; // TODO
     }
index e678b38..3d7cda6 100644 (file)
@@ -339,6 +339,8 @@ message ReqKey{
       POWER = 5;
       KEY = 6;
       XF86 = 7;
+      WHEELUP = 8;
+      WHEELDOWN = 9;
    }
    enum KeyActionType{
       PRESS = 0;