libaurum: Sync connect mouse device when wheel needed and code clean up 99/260699/1 submit/tizen/20210706.064323
authorWoochanlee <wc0917.lee@samsung.com>
Thu, 1 Jul 2021 07:40:30 +0000 (16:40 +0900)
committerWoochanlee <wc0917.lee@samsung.com>
Thu, 1 Jul 2021 07:40:30 +0000 (16:40 +0900)
File log update

Change-Id: I0c8bd1a9bc44e286cf5389aa5a50540bfa487e69

libaurum/src/Impl/TizenDeviceImpl.cc

index fc81f062545b68e5d0aeb036e6dbc9809f4400a6..82fc92603c9e558a8ad460dfeb79169c2f689c12 100644 (file)
@@ -1,5 +1,6 @@
+#include "Aurum.h"
+
 #include "TizenDeviceImpl.h"
-#include <loguru.hpp>
 
 #include <functional>
 #include <tuple>
 TizenDeviceImpl::TizenDeviceImpl()
 : mFakeTouchHandle{0}, mFakeKeyboardHandle{0}, mFakeWheelHandle{0}, tStart{}, isTimerStarted{false}, mTouchSeq{}
 {
-    loguru::add_file("/tmp/aurum.log", loguru::Append, loguru::Verbosity_MAX);
-    loguru::g_stderr_verbosity = loguru::Verbosity_ERROR;
-
-    LOG_SCOPE_F(INFO, "device implementation init");
+    dlog_print(DLOG_INFO, LOG_TAG, "device implementation init");
     TizenDeviceImpl *obj = static_cast<TizenDeviceImpl*>(this);
     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);
 }
 
 TizenDeviceImpl::~TizenDeviceImpl()
@@ -33,7 +30,6 @@ TizenDeviceImpl::~TizenDeviceImpl()
    TizenDeviceImpl *obj = static_cast<TizenDeviceImpl*>(this);
    efl_util_input_deinitialize_generator(obj->mFakeTouchHandle);
    efl_util_input_deinitialize_generator(obj->mFakeKeyboardHandle);
-   efl_util_input_deinitialize_generator(obj->mFakeWheelHandle);
 }
 
 bool TizenDeviceImpl::click(const int x, const int y)
@@ -43,7 +39,7 @@ bool TizenDeviceImpl::click(const int x, const int y)
 
 bool TizenDeviceImpl::click(const int x, const int y, const unsigned int intv)
 {
-    LOG_SCOPE_F(INFO, "click %d %d , intv:%d", x, y, intv);
+    dlog_print(DLOG_INFO, LOG_TAG, "click %d %d , intv:%d", x, y, intv);
 
     int seq = touchDown(x, y);
     if (seq < 0) return false;
@@ -57,7 +53,7 @@ bool TizenDeviceImpl::click(const int x, const int y, const unsigned int intv)
 int TizenDeviceImpl::touchDown(const int x, const int y)
 {
     int seq = grabTouchSeqNumber();
-    LOG_SCOPE_F(INFO, "touch down %d %d , seq:%d", x, y, seq);
+    dlog_print(DLOG_INFO, LOG_TAG, "touch down %d %d , seq:%d", x, y, seq);
     if (seq >= 0) {
          TizenDeviceImpl *obj = static_cast<TizenDeviceImpl*>(this);
          long result = (long)efl_util_input_generate_touch(obj->mFakeTouchHandle, seq, EFL_UTIL_INPUT_TOUCH_BEGIN,
@@ -73,7 +69,7 @@ int TizenDeviceImpl::touchDown(const int x, const int y)
 
 bool TizenDeviceImpl::touchMove(const int x, const int y, const int seq)
 {
-    LOG_SCOPE_F(INFO, "touch move %d %d, seq:%d", x, y, seq);
+    dlog_print(DLOG_INFO, LOG_TAG, "touch move %d %d, seq:%d", x, y, seq);
     if (seq >= 0) {
          TizenDeviceImpl *obj = static_cast<TizenDeviceImpl*>(this);
          long result = (long)efl_util_input_generate_touch(obj->mFakeTouchHandle, seq, EFL_UTIL_INPUT_TOUCH_UPDATE,
@@ -85,7 +81,7 @@ bool TizenDeviceImpl::touchMove(const int x, const int y, const int seq)
 
 bool TizenDeviceImpl::touchUp(const int x, const int y, const int seq)
 {
-   LOG_SCOPE_F(INFO, "touch up %d %d, seq:%d", x, y, seq);
+   dlog_print(DLOG_INFO, LOG_TAG, "touch up %d %d, seq:%d", x, y, seq);
    if (seq >= 0) {
         TizenDeviceImpl *obj = static_cast<TizenDeviceImpl*>(this);
         long result = (long)efl_util_input_generate_touch(obj->mFakeTouchHandle, seq, EFL_UTIL_INPUT_TOUCH_END,
@@ -97,26 +93,32 @@ bool TizenDeviceImpl::touchUp(const int x, const int y, const int seq)
 
 bool TizenDeviceImpl::wheelUp(int amount, const int durationMs)
 {
-    LOG_SCOPE_F(INFO, "wheel up %d for %d", amount, durationMs);
+    dlog_print(DLOG_INFO, LOG_TAG, "wheel up %d for %d", amount, durationMs);
     long result = -1;
+    TizenDeviceImpl *obj = static_cast<TizenDeviceImpl*>(this);
+    obj->mFakeWheelHandle = efl_util_input_initialize_generator_with_sync(EFL_UTIL_INPUT_DEVTYPE_POINTER, NULL);
     for (int i = 0; i < amount; i++){
          TizenDeviceImpl *obj = static_cast<TizenDeviceImpl*>(this);
          result = (long)efl_util_input_generate_wheel(obj->mFakeWheelHandle, EFL_UTIL_INPUT_POINTER_WHEEL_HORZ, 1);
          usleep(durationMs*MSEC_PER_SEC/amount);
     }
+    efl_util_input_deinitialize_generator(obj->mFakeWheelHandle);
 
     return result == EFL_UTIL_ERROR_NONE;
 }
 
 bool TizenDeviceImpl::wheelDown(int amount, const int durationMs)
 {
-   LOG_SCOPE_F(INFO, "wheel down %d for %d", amount, durationMs);
-   long result = -1;
-   for (int i = 0; i < amount; i++){
+    dlog_print(DLOG_INFO, LOG_TAG, "wheel down %d for %d", amount, durationMs);
+    long result = -1;
+    TizenDeviceImpl *obj = static_cast<TizenDeviceImpl*>(this);
+    obj->mFakeWheelHandle = efl_util_input_initialize_generator_with_sync(EFL_UTIL_INPUT_DEVTYPE_POINTER, NULL);
+    for (int i = 0; i < amount; i++){
         TizenDeviceImpl *obj = static_cast<TizenDeviceImpl*>(this);
         result = (long)efl_util_input_generate_wheel(obj->mFakeWheelHandle, EFL_UTIL_INPUT_POINTER_WHEEL_HORZ, -1);
         usleep(durationMs*MSEC_PER_SEC/amount);
     }
+    efl_util_input_deinitialize_generator(obj->mFakeWheelHandle);
 
     return result == EFL_UTIL_ERROR_NONE;
 }
@@ -154,7 +156,7 @@ bool TizenDeviceImpl::drag(const int sx, const int sy, const int ex, const int e
         _steps = (int)(_durationUs / (INTV_MINIMUM_DRAG_MS * MSEC_PER_SEC)) - 1;
         _stepUs  = (INTV_MINIMUM_DRAG_MS * MSEC_PER_SEC);
     }
-    LOG_SCOPE_F(INFO, "flicking (%d, %d) -> (%d, %d) for (%d ms)", sx, sy, ex, ey, durationMs);
+    dlog_print(DLOG_INFO, LOG_TAG, "flicking (%d, %d) -> (%d, %d) for (%d ms)", sx, sy, ex, ey, durationMs);
     startTimer();
     int seq = touchDown(sx, sy);
     if (seq < 0) return false;