@@ -10,6 +10,7 @@ using namespace Send;
1010#include < future>
1111#include < queue>
1212#include < IbWinCppLib/WinCppLib.hpp>
13+ #include " Vk.hpp"
1314
1415
1516class Measure {
@@ -133,12 +134,15 @@ class KeyboardTest : public InitTest<TypeV>
133134 input_keys.pop ();
134135 }
135136
136- BOOST_TEST_MESSAGE (fmt::format (" Duration: {}ns\n " , t1));
137- // SendInput: 1~3ms
137+ BOOST_TEST_MESSAGE (" TestKeyboardLatency:" );
138+ BOOST_TEST_MESSAGE (fmt::format (" Duration: {}ns" , t1));
139+ // SendInput: 1000~3000us (1~3ms)
138140 // Logitech: 25~45us
139- BOOST_TEST_MESSAGE (fmt::format (" Latency: {}ns\n " , t2));
141+ // DD: 70~110us
142+ BOOST_TEST_MESSAGE (fmt::format (" Latency: {}ns" , t2));
140143 // SendInput: 100ns (0)
141144 // Logitech: 0.8~4ms
145+ // DD: 0.6~1ms
142146 }
143147};
144148
@@ -164,9 +168,12 @@ class MouseTest : public InitTest<TypeV> {
164168 IbAhkSendInput (1 , &input, sizeof INPUT);
165169 }
166170 uint64_t t = measure.end ();
167- BOOST_TEST_MESSAGE (fmt::format (" Duration: {}ns\n " , t / 10000 ));
171+
172+ BOOST_TEST_MESSAGE (" TestMouseMove:" );
173+ BOOST_TEST_MESSAGE (fmt::format (" Duration: {}ns" , t / 10000 ));
168174 // SendInput: 200~800us
169175 // Logitech: 3~10us
176+ // DD: 500~1000us
170177 }
171178
172179 void TestMouseMoveLatency () {
@@ -188,12 +195,37 @@ class MouseTest : public InitTest<TypeV> {
188195 d = { p2.x - p1.x , p2.y - p1.y };
189196 } while (!(d.x >= 50 && d.y >= 50 ));
190197 uint64_t latency = measure.end ();
191- BOOST_TEST_MESSAGE (fmt::format (" Latency: {}ns\n " , latency));
192- // SendInput: 3~200us
193- // Logitech: 900~4000us (0.9~4ms)
198+
199+ BOOST_TEST_MESSAGE (" TestMouseMoveLatency:" );
200+ BOOST_TEST_MESSAGE (fmt::format (" Latency: {}ns" , latency));
201+ // SendInput: 0.003~0.2ms (3~200us)
202+ // Logitech: 0.9~4ms
203+ // DD: 1.1ms~1.3ms
204+ }
205+
206+ void TestMouseAbsoluteMove () {
207+ POINT screen{ GetSystemMetrics (SM_CXSCREEN), GetSystemMetrics (SM_CYSCREEN) };
208+
209+ INPUT input;
210+ input.type = INPUT_MOUSE;
211+ input.mi = {};
212+ input.mi .dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_MOVE_NOCOALESCE | MOUSEEVENTF_ABSOLUTE;
213+ input.mi .dx = 65536 * 100 / screen.x ;
214+ input.mi .dy = 65536 * 100 / screen.y ;
215+ IbAhkSendInput (1 , &input, sizeof INPUT);
216+
217+ POINT p1, p2;
218+ GetCursorPos (&p1);
219+ Sleep (10 );
220+ GetCursorPos (&p2);
221+ BOOST_CHECK ((abs (p2.x - 100 ) <= 10 && abs (p2.y - 100 ) <= 100 ));
222+
223+ BOOST_TEST_MESSAGE (" TestMouseAbsoluteMove:" );
224+ BOOST_TEST_MESSAGE (fmt::format (" 0ms: ({}, {})" , p1.x , p1.y ));
225+ BOOST_TEST_MESSAGE (fmt::format (" 10ms: ({}, {})" , p2.x , p2.y ));
194226 }
195227
196- void TestMouseMoveDistance () {
228+ void TestMouseRelativeMove () {
197229 POINT p1, p2, d1, d2;
198230 GetCursorPos (&p1);
199231
@@ -213,35 +245,69 @@ class MouseTest : public InitTest<TypeV> {
213245 d2 = { p2.x - p1.x , p2.y - p1.y };
214246 BOOST_CHECK ((abs (d2.x - 100 ) <= 10 && abs (d2.y - 100 ) <= 100 ));
215247
216- BOOST_TEST_MESSAGE (fmt::format (" 0ms: ({}, {})\n " , d1.x , d1.y ));
217- BOOST_TEST_MESSAGE (fmt::format (" 10ms: ({}, {})\n " , d2.x , d2.y ));
248+ BOOST_TEST_MESSAGE (" TestMouseRelativeMove:" );
249+ BOOST_TEST_MESSAGE (fmt::format (" 0ms: ({}, {})" , d1.x , d1.y ));
250+ BOOST_TEST_MESSAGE (fmt::format (" 10ms: ({}, {})" , d2.x , d2.y ));
218251 }
219252};
220253
221- #define CODE_GENERATE_TEST_NAME (name, type ) \
222- BOOST_AUTO_TEST_SUITE (name) \
223- BOOST_FIXTURE_TEST_SUITE(Keyboard, KeyboardTest<SendType::type>) \
254+ #define CODE_GENERATE_KEYBOARDTEST \
224255 using base = BOOST_AUTO_TEST_CASE_FIXTURE; \
225256 BOOST_AUTO_TEST_CASE (TestKeyboardLatency) { \
226257 base::TestKeyboardLatency (); \
227- } \
228- BOOST_AUTO_TEST_SUITE_END () \
229- \
230- BOOST_FIXTURE_TEST_SUITE(Mouse, MouseTest<SendType::type>) \
231- using base = BOOST_AUTO_TEST_CASE_FIXTURE; \
258+ }
259+
260+ #define CODE_GENERATE_MOUSETEST \
261+ using base = BOOST_AUTO_TEST_CASE_FIXTURE; \
232262 BOOST_AUTO_TEST_CASE (TestMouseMove) { \
233263 base::TestMouseMove (); \
234264 } \
235265 BOOST_AUTO_TEST_CASE (TestMouseMoveLatency) { \
236266 base::TestMouseMoveLatency (); \
237267 } \
238- BOOST_AUTO_TEST_CASE (TestMouseMoveDistance ) { \
239- base::TestMouseMoveDistance (); \
268+ BOOST_AUTO_TEST_CASE (TestMouseAbsoluteMove ) { \
269+ base::TestMouseAbsoluteMove (); \
240270 } \
271+ BOOST_AUTO_TEST_CASE (TestMouseRelativeMove) { \
272+ base::TestMouseRelativeMove (); \
273+ }
274+
275+ #define CODE_GENERATE_TEST_NAME (name, type ) \
276+ BOOST_AUTO_TEST_SUITE (name) \
277+ BOOST_FIXTURE_TEST_SUITE(Keyboard, KeyboardTest<SendType::type>) \
278+ CODE_GENERATE_KEYBOARDTEST \
279+ BOOST_AUTO_TEST_SUITE_END() \
280+ \
281+ BOOST_FIXTURE_TEST_SUITE(Mouse, MouseTest<SendType::type>) \
282+ CODE_GENERATE_MOUSETEST \
241283 BOOST_AUTO_TEST_SUITE_END() \
242284BOOST_AUTO_TEST_SUITE_END()
243285#define CODE_GENERATE_TEST (type ) CODE_GENERATE_TEST_NAME(type, type)
244286
245287CODE_GENERATE_TEST_NAME (SendInput_, SendInput)
246288CODE_GENERATE_TEST(AnyDriver)
247- CODE_GENERATE_TEST(Logitech)
289+ CODE_GENERATE_TEST(Logitech)
290+
291+ BOOST_AUTO_TEST_SUITE(DD)
292+ BOOST_FIXTURE_TEST_SUITE(Keyboard, KeyboardTest<SendType::DD>)
293+ BOOST_AUTO_TEST_CASE(TestDDCode) {
294+ HMODULE dd = GetModuleHandleW (L" DD94687.64.dll" );
295+ if (!dd) dd = GetModuleHandleW (L" DD64.dll" );
296+ if (!dd) dd = GetModuleHandleW (L" DDHID64.dll" );
297+ BOOST_CHECK (dd);
298+ int (*DD_todc)(int vk) = ib::Addr (GetProcAddress (dd, " DD_todc" ));
299+ BOOST_CHECK (DD_todc);
300+
301+ std::stringstream ss;
302+ for (WORD vk = 0 ; vk < 0x100 ; vk++)
303+ ss << vk << " " << vk_to_str (vk) << " : " << DD_todc (vk) << " \n " ;
304+ BOOST_TEST_MESSAGE (ss.str ());
305+ }
306+
307+ CODE_GENERATE_KEYBOARDTEST
308+ BOOST_AUTO_TEST_SUITE_END ()
309+
310+ BOOST_FIXTURE_TEST_SUITE(Mouse, MouseTest<SendType::DD>)
311+ CODE_GENERATE_MOUSETEST
312+ BOOST_AUTO_TEST_SUITE_END()
313+ BOOST_AUTO_TEST_SUITE_END()
0 commit comments