#include "config.h"
#include "IDevice.h"
+#include <set>
#ifdef GBS_BUILD
#include <efl_util.h>
bool drag(const int sx, const int sy, const int ex, const int ey,
const int steps, const int durationMs) override;
- bool touchDown(const int x, const int y) override;
- bool touchMove(const int x, const int y) override;
- bool touchUp(const int x, const int y) override;
+ int touchDown(const int x, const int y) override;
+ bool touchMove(const int x, const int y, const int seq) override;
+ bool touchUp(const int x, const int y, const int seq) override;
bool wheelUp(int amount, const int durationMs) override;
bool wheelDown(int amount, const int durationMs) override;
bool pressKeyCode(std::string keycode);
bool releaseKeyCode(std::string keycode);
+ int grabTouchSeqNumber();
+ bool releaseTouchSeqNumber(int seq);
+
private:
void startTimer(void);
int stopTimer(void);
static const unsigned int INTV_MINIMUM_USLEEP = 1000;
static const unsigned int MINIMUM_DURATION_DRAG = 100;
static const unsigned int MSEC_PER_SEC = 1000;
+ static const unsigned int MAX_FINGER_NUMBER = 2;
struct timespec tStart;
bool isTimerStarted;
+
+ std::set<int> mTouchSeq;
};
#endif
\ No newline at end of file
#include <Ecore.h>
TizenImpl::TizenImpl()
-: mFakeTouchHandle{0}, mFakeKeyboardHandle{0}, mFakeWheelHandle{0}, isTimerStarted{false}
+: mFakeTouchHandle{0}, mFakeKeyboardHandle{0}, mFakeWheelHandle{0}, isTimerStarted{false}, mTouchSeq{}
{
LOG_SCOPE_F(INFO, "device implementation init");
ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
bool TizenImpl::click(const int x, const int y, const unsigned int intv)
{
- touchDown(x, y);
+ int seq = touchDown(x, y);
+ if (seq < 0) return false;
usleep(intv * MSEC_PER_SEC);
- touchUp(x, y);
+ touchUp(x, y, seq);
return true;
}
-bool TizenImpl::touchDown(const int x, const int y)
+int TizenImpl::touchDown(const int x, const int y)
{
- LOG_F(INFO, "touch down %d %d", x, y);
- auto args = std::make_tuple(this, x, y);
- ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
- TizenImpl *obj;
- int x, y;
- std::tie(obj, x, y) = *static_cast<std::tuple<TizenImpl*, int, int>*>(data);
- efl_util_input_generate_touch(obj->mFakeTouchHandle, 0, EFL_UTIL_INPUT_TOUCH_BEGIN,
- x, y);
+ int seq = grabTouchSeqNumber();
+ LOG_F(INFO, "touch down %d %d , seq:%d", x, y, seq);
+ if (seq >= 0) {
+ auto args = std::make_tuple(this, x, y, seq);
+ ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
+ TizenImpl *obj;
+ int x, y, seq;
+ std::tie(obj, x, y, seq) = *static_cast<std::tuple<TizenImpl*, int, int, int>*>(data);
+ efl_util_input_generate_touch(obj->mFakeTouchHandle, seq, EFL_UTIL_INPUT_TOUCH_BEGIN,
+ x, y);
- return NULL;
- }, (void*)(&args));
- return true;
+ return NULL;
+ }, (void*)(&args));
+ }
+ return seq;
}
-bool TizenImpl::touchMove(const int x, const int y)
+bool TizenImpl::touchMove(const int x, const int y, const int seq)
{
- LOG_F(INFO, "touch move %d %d", x, y);
- auto args = std::make_tuple(this, x, y);
- ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
- TizenImpl *obj;
- int x, y;
- std::tie(obj, x, y) = *static_cast<std::tuple<TizenImpl*, int, int>*>(data);
+ LOG_F(INFO, "touch move %d %d, seq:%d", x, y, seq);
+ if (seq >= 0) {
+ auto args = std::make_tuple(this, x, y, seq);
+ ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
+ TizenImpl *obj;
+ int x, y, seq;
+ std::tie(obj, x, y, seq) = *static_cast<std::tuple<TizenImpl*, int, int, int>*>(data);
- efl_util_input_generate_touch(obj->mFakeTouchHandle, 0, EFL_UTIL_INPUT_TOUCH_UPDATE,
- x, y);
+ efl_util_input_generate_touch(obj->mFakeTouchHandle, seq, EFL_UTIL_INPUT_TOUCH_UPDATE,
+ x, y);
- return NULL;
- }, (void*)(&args));
- return true;
+ return NULL;
+ }, (void*)(&args));
+ return true;
+ }
+ return false;
}
-bool TizenImpl::touchUp(const int x, const int y)
+bool TizenImpl::touchUp(const int x, const int y, const int seq)
{
- LOG_F(INFO, "touch up %d %d", x, y);
- auto args = std::make_tuple(this, x, y);
- ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
- TizenImpl *obj;
- int x, y;
- std::tie(obj, x, y) = *static_cast<std::tuple<TizenImpl*, int, int>*>(data);
- efl_util_input_generate_touch(obj->mFakeTouchHandle, 0, EFL_UTIL_INPUT_TOUCH_END,
- x, y);
- return NULL;
- }, (void*)(&args));
- return true;
+ LOG_F(INFO, "touch up %d %d, seq:%d", x, y, seq);
+ if (seq >= 0) {
+ auto args = std::make_tuple(this, x, y, seq);
+ ecore_main_loop_thread_safe_call_sync([](void *data)->void*{
+ TizenImpl *obj;
+ int x, y, seq;
+ std::tie(obj, x, y, seq) = *static_cast<std::tuple<TizenImpl*, int, int, int>*>(data);
+ efl_util_input_generate_touch(obj->mFakeTouchHandle, seq, EFL_UTIL_INPUT_TOUCH_END,
+ x, y);
+ return NULL;
+ }, (void*)(&args));
+ return releaseTouchSeqNumber(seq);;
+ }
+ return false;
}
bool TizenImpl::wheelUp(int amount, const int durationMs)
}
LOG_SCOPE_F(INFO, "flicking (%d, %d) -> (%d, %d) for (%d ms)", sx, sy, ex, ey, durationMs);
startTimer();
- touchDown(sx, sy);
+ int seq = touchDown(sx, sy);
+ if (seq < 0) return false;
consumptionUs = stopTimer();
for ( int s = 1; s <= _steps + 1; s++) {
usleep((_stepUs - consumptionUs)>INTV_MINIMUM_USLEEP?(_stepUs - consumptionUs):INTV_MINIMUM_USLEEP);
startTimer();
- touchMove(sx + (ex - sx) * s / (steps + 1), sy + (ey - sy) * s / (steps + 1));
+ touchMove(sx + (ex - sx) * s / (steps + 1), sy + (ey - sy) * s / (steps + 1), seq);
consumptionUs = stopTimer();
}
usleep((_stepUs - consumptionUs)>INTV_MINIMUM_USLEEP?(_stepUs - consumptionUs):INTV_MINIMUM_USLEEP);
- touchMove(ex, ey);
- touchUp(ex, ey);
+ touchMove(ex, ey, seq);
+ touchUp(ex, ey, seq);
return true;
}
return clock->getTime();
}
+
+int TizenImpl::grabTouchSeqNumber()
+{
+ for (int i = 0 ; i < MAX_FINGER_NUMBER; i++) {
+ if (mTouchSeq.count(i) == 0) {
+ mTouchSeq.insert(i);
+ return i;
+ }
+ }
+ return -1;
+}
+
+bool TizenImpl::releaseTouchSeqNumber(int seq)
+{
+ auto k = mTouchSeq.find(seq);
+ if (k != mTouchSeq.end()) {
+ mTouchSeq.erase(k);
+ return true;
+ }
+ return false;
+}
\ No newline at end of file