-#if USE_SYSMOUSE
- if ((SP->_mouse_type == M_SYSMOUSE)
- && (SP->_sysmouse_head < SP->_sysmouse_tail)) {
- return 2;
- }
-#endif
- rc = _nc_timed_wait(TWAIT_MASK, delay, (int *) 0 EVENTLIST_2nd(evl));
-#if USE_SYSMOUSE
- if ((SP->_mouse_type == M_SYSMOUSE)
- && (SP->_sysmouse_head < SP->_sysmouse_tail)
- && (rc == 0)
- && (errno == EINTR)) {
- rc |= 2;
+#ifdef USE_TERM_DRIVER
+ TERMINAL_CONTROL_BLOCK *TCB = TCBOf(sp);
+ rc = TCBOf(sp)->drv->td_testmouse(TCBOf(sp), delay EVENTLIST_2nd(evl));
+# if defined(EXP_WIN32_DRIVER)
+ /* if we emulate terminfo on console, we have to use the console routine */
+ if (IsTermInfoOnConsole(sp)) {
+ rc = _nc_console_testmouse(sp,
+ _nc_console_handle(sp->_ifd),
+ delay EVENTLIST_2nd(evl));
+ } else
+# elif defined(_NC_WINDOWS)
+ /* if we emulate terminfo on console, we have to use the console routine */
+ if (IsTermInfoOnConsole(sp)) {
+ HANDLE fd = _nc_get_handle(sp->_ifd);
+ rc = _nc_mingw_testmouse(sp, fd, delay EVENTLIST_2nd(evl));
+ } else
+# endif
+ rc = TCB->drv->td_testmouse(TCB, delay EVENTLIST_2nd(evl));
+#else /* !USE_TERM_DRIVER */
+# if USE_SYSMOUSE
+ if ((sp->_mouse_type == M_SYSMOUSE)
+ && (sp->_sysmouse_head < sp->_sysmouse_tail)) {
+ rc = TW_MOUSE;
+ } else
+# endif
+ {
+# if defined(EXP_WIN32_DRIVER)
+ rc = _nc_console_testmouse(sp,
+ _nc_console_handle(sp->_ifd),
+ delay
+ EVENTLIST_2nd(evl));
+# else
+ rc = _nc_timed_wait(sp,
+ TWAIT_MASK,
+ delay,
+ (int *) 0
+ EVENTLIST_2nd(evl));
+# endif
+# if USE_SYSMOUSE
+ if ((sp->_mouse_type == M_SYSMOUSE)
+ && (sp->_sysmouse_head < sp->_sysmouse_tail)
+ && (rc == 0)
+ && (errno == EINTR)) {
+ rc |= TW_MOUSE;
+ }
+# endif