libaurum: change delay time between key down and key up
[platform/core/uifw/aurum.git] / libaurum / inc / Impl / TizenDeviceImpl.h
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *  Licensed under the Apache License, Version 2.0 (the "License");
5  *  you may not use this file except in compliance with the License.
6  *  You may obtain a copy of the License at
7  *
8  *               http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *  Unless required by applicable law or agreed to in writing, software
11  *  distributed under the License is distributed on an "AS IS" BASIS,
12  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *  See the License for the specific language governing permissions and
14  *  limitations under the License.
15  *
16  */
17
18 #ifndef _TIZEN_DEVICE_IMPL_H_
19 #define _TIZEN_DEVICE_IMPL_H_
20
21 #include "config.h"
22 #include "IDevice.h"
23
24 #include <set>
25 #include <efl_util.h>
26
27 using namespace Aurum;
28
29 namespace AurumInternal {
30
31 class TizenDeviceImpl : public IDevice {
32 public:
33     TizenDeviceImpl();
34
35     ~TizenDeviceImpl();
36
37     /**
38      * @copydoc IDevice::click()
39      */
40     bool click(const int x, const int y) override;
41
42     /**
43      * @copydoc IDevice::click()
44      */
45     bool click(const int x, const int y, const unsigned int durationMs) override;
46
47     /**
48      * @copydoc IDevice::drag()
49      */
50     bool drag(const int sx, const int sy, const int ex, const int ey,
51               const int steps, const int durationMs) override;
52
53     /**
54      * @copydoc IDevice::touchDown()
55      */
56     int touchDown(const int x, const int y) override;
57
58     /**
59      * @copydoc IDevice::touchMove()
60      */
61     bool touchMove(const int x, const int y, const int seq) override;
62
63     /**
64      * @copydoc IDevice::touchUp()
65      */
66     bool touchUp(const int x, const int y, const int seq) override;
67
68     /**
69      * @copydoc IDevice::wheelUp()
70      */
71     bool wheelUp(int amount, const int durationMs) override;
72
73     /**
74      * @copydoc IDevice::wheelDown()
75      */
76     bool wheelDown(int amount, const int durationMs) override;
77
78     /**
79      * @copydoc IDevice::pressBack()
80      */
81     bool pressBack(KeyRequestType type) override;
82
83     /**
84      * @copydoc IDevice::pressHome()
85      */
86     bool pressHome(KeyRequestType type) override;
87
88     /**
89      * @copydoc IDevice::pressMenu()
90      */
91     bool pressMenu(KeyRequestType type) override;
92
93     /**
94      * @copydoc IDevice::pressVolUp()
95      */
96     bool pressVolUp(KeyRequestType type) override;
97
98     /**
99      * @copydoc IDevice::pressVolDown()
100      */
101     bool pressVolDown(KeyRequestType type) override;
102
103     /**
104      * @copydoc IDevice::pressPower()
105      */
106     bool pressPower(KeyRequestType type) override;
107
108     /**
109      * @copydoc IDevice::pressKeyCode()
110      */
111     bool pressKeyCode(std::string keycode, KeyRequestType type) override;
112
113     /**
114      * @copydoc IDevice::takeScreenshot()
115      */
116     bool takeScreenshot(std::string path, float scale, int quality) override;
117
118     /**
119      * @copydoc IDevice::getSystemTime()
120      */
121     long long getSystemTime(TimeRequestType type) override;
122
123     /**
124      * @brief Gets device screen size.
125      *
126      * @return @Size2D
127      *
128      * @since_tizen 6.5
129      */
130     const Size2D<int> getScreenSize() override;
131
132 protected:
133     /**
134      * @brief Press and release given key during duration time.
135      *
136      * @since_tizen 6.5
137      */
138     bool strokeKeyCode(std::string keycode, unsigned int durationMs);
139
140     /**
141      * @brief Press given key.
142      *
143      * @since_tizen 6.5
144      */
145     bool pressKeyCode(std::string keycode);
146
147     /**
148      * @brief Release given key.
149      *
150      * @since_tizen 6.5
151      */
152     bool releaseKeyCode(std::string keycode);
153
154     /**
155      * @brief Increase touch count and return the number to manage touch count.
156      *
157      * @since_tizen 6.5
158      */
159     int grabTouchSeqNumber();
160
161     /**
162      * @brief Delete given touch number.
163      *
164      * @since_tizen 6.5
165      */
166     bool releaseTouchSeqNumber(int seq);
167
168 private:
169     /**
170      * @brief Timer utility.
171      *
172      * @since_tizen 6.5
173      */
174     void startTimer(void);
175
176     /**
177      * @brief Timer utility.
178      *
179      * @since_tizen 6.5
180      */
181     int stopTimer(void);
182
183 private:
184     efl_util_inputgen_h mFakeTouchHandle;
185     efl_util_inputgen_h mFakeKeyboardHandle;
186     efl_util_inputgen_h mFakeWheelHandle;
187     static const int INTV_CLICK = 5;
188     static const int INTV_SHORTSTROKE = 10;
189     static const int INTV_LONGSTROKE = 2000;
190     static const int INTV_MINIMUM_DRAG_MS = 25;
191     static const int INTV_MINIMUM_USLEEP = 1000;
192     static const int MINIMUM_DURATION_DRAG = 100;
193     static const unsigned int MSEC_PER_SEC = 1000;
194     static const unsigned int MAX_FINGER_NUMBER = 2;
195     struct timespec tStart;
196     bool isTimerStarted;
197     std::set<int> mTouchSeq;
198
199     /**
200      * @brief TBD
201      */
202     Size2D<int> mScreenSize;
203 };
204
205 }
206
207 #endif