This command simulates repeat press of the given key.
How to use
Sends Right key every 100ms for a total of 2000ms:
stub.sendKey(ReqKey(type='XF86', actionType='REPEAT', XF86keyCode='Right', durationMs=2000, intervalMs=100))
Change-Id: I03ec7a8b79a28d6802fac5318a333e7ff5cbda59
*/
bool pressKeyCode(std::string keycode, KeyRequestType type) override;
+ /**
+ * @brief TBD
+ * @since_tizen 7.0
+ */
+ bool repeatKeyCode(std::string keycode, int intervalMs, int durationMs) override;
+
/**
* @brief TBD
* @since_tizen 6.5
*/
bool pressKeyCode(std::string keycode, KeyRequestType type) override;
+ /**
+ * @copydoc IDevice::repeatKeyCode()
+ */
+ bool repeatKeyCode(std::string keycode, int intervalMs, int durationMs) override;
+
/**
* @copydoc IDevice::takeScreenshot()
*/
static const int INTV_MINIMUM_DRAG_MS = 25;
static const int INTV_MINIMUM_USLEEP = 1000;
static const int MINIMUM_DURATION_DRAG = 100;
+ static const int MINIMUM_REPEAT_INTERVAL = 20;
static const unsigned int MSEC_PER_SEC = 1000;
+ static const unsigned int USEC_PER_MSEC = 1000;
static const unsigned int MAX_FINGER_NUMBER = 2;
struct timespec tStart;
bool isTimerStarted;
LONG_STROKE, //Key long press(2000ms) and release
PRESS, //Key press
RELEASE, //Key release
+ REPEAT, //Repeat key press(100ms) and release
};
/**
*/
virtual bool pressKeyCode(std::string keycode, KeyRequestType type) = 0;
+ /**
+ * @brief Simulates repeat press of the given keycode key.
+ *
+ * @param[in] keycode keycode
+ * @param[in] intervalMs time interval for pressing given keycode key
+ * @param[in] durationMs total time to press given keycode key
+ *
+ * @return true if the scroll keycode succeeded else false
+ *
+ * @since_tizen 7.0
+ */
+ virtual bool repeatKeyCode(std::string keycode, int intervalMs, int durationMs) = 0;
+
/**
* @brief Take a screenshot of current window and store it as image file.
*
*/
bool pressKeyCode(std::string keycode, KeyRequestType type) override;
+ /**
+ * @brief Simulates repeat press of the given keycode key.
+ *
+ * @param[in] keycode keycode
+ * @param[in] intervalMs time interval for pressing given keycode key
+ * @param[in] durationMs total time to press given keycode key
+ *
+ * @return true if the scroll keycode succeeded else false
+ *
+ * @since_tizen 7.0
+ */
+ bool repeatKeyCode(std::string keycode, int intervalMs, int durationMs) override;
+
/**
* @brief Take a screenshot of current window and store it as image file.
*
return true;
}
+bool MockDeviceImpl::repeatKeyCode(std::string keycode, int intervalMs, int durationMs)
+{
+ return false;
+}
+
bool MockDeviceImpl::takeScreenshot(std::string path, float scale, int quality)
{
return true;
return pressKeyCode(keycode);
else if (type == KeyRequestType::RELEASE)
return releaseKeyCode(keycode);
+ else if (type == KeyRequestType::REPEAT)
+ {
+ LOGI("You can't repeat non-XF86 keys");
+ return false;
+ }
+
return false;
}
+bool TizenDeviceImpl::repeatKeyCode(std::string keycode, int intervalMs, int durationMs)
+{
+ if (intervalMs < MINIMUM_REPEAT_INTERVAL)
+ {
+ LOGI("Minimum intervalMs is %d, but user has set it to %d, so changed it to %d", MINIMUM_REPEAT_INTERVAL, intervalMs, MINIMUM_REPEAT_INTERVAL);
+ intervalMs = MINIMUM_REPEAT_INTERVAL;
+ }
+
+ int press_count = durationMs / intervalMs;
+
+ for (int i = 0; i < press_count; i++)
+ {
+ strokeKeyCode(keycode, INTV_SHORTSTROKE);
+ usleep((intervalMs - INTV_SHORTSTROKE) * USEC_PER_MSEC);
+ }
+ strokeKeyCode(keycode, INTV_SHORTSTROKE);
+
+ return true;
+}
+
bool TizenDeviceImpl::strokeKeyCode(std::string keycode, unsigned int durationMs)
{
pressKeyCode(keycode);
- usleep(durationMs * 1000);
+ usleep(durationMs * USEC_PER_MSEC);
releaseKeyCode(keycode);
return true;
}
return result;
}
+bool UiDevice::repeatKeyCode(std::string keycode, int intervalMs, int durationMs)
+{
+ bool result = mDeviceImpl->repeatKeyCode(keycode, intervalMs, durationMs);
+ return result;
+}
+
bool UiDevice::takeScreenshot(std::string path, float scale, int quality)
{
return mDeviceImpl->takeScreenshot(path, scale, quality);
std::unique_ptr<GetTextMinBoundingRectCommand> cmd = std::make_unique<GetTextMinBoundingRectCommand>(request, response);
return execute(cmd.get(), true);
}
-
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_XF86) {
- mDevice->pressKeyCode(mRequest->xf86keycode(), actionType);
+ else if (type == ::aurum::ReqKey_KeyType::ReqKey_KeyType_XF86)
+ {
+ if (actionType == KeyRequestType::REPEAT)
+ {
+ int durationMs = mRequest->durationms();
+ int intervalMs = mRequest->intervalms();
+ mDevice->repeatKeyCode(mRequest->xf86keycode(), intervalMs, durationMs);
+ }
+ else
+ {
+ mDevice->pressKeyCode(mRequest->xf86keycode(), actionType);
+ }
}
return grpc::Status::OK;
}
\ No newline at end of file
VOLUP = 3;
VOLDOWN = 4;
POWER = 5;
- //KEY = 6;
XF86 = 7;
WHEELUP = 8;
WHEELDOWN = 9;
LONG_STROKE = 1;
PRESS = 2;
RELEASE = 3;
+ REPEAT = 4;
}
KeyType type = 1;
KeyActionType actionType = 2;
- //oneof keys {
- //uint32 keyCode = 3;
- string XF86keyCode = 4;
- //}
+ string XF86keyCode = 3;
+ int32 durationMs = 4;
+ int32 intervalMs = 5;
}
message RspKey{
RspStatus status = 1;
RspStatus status = 1;
Rect size = 2;
}
-