Browse Source

win32 port: use win32 API functions instead of _kbhit() from conio.h

master
goldsimon 9 years ago
parent
commit
7b0adcf4a8
  1. 2
      ports/win32/include/arch/sys_arch.h
  2. 18
      ports/win32/sys_arch.c
  3. 3
      ports/win32/test.c

2
ports/win32/include/arch/sys_arch.h

@ -74,5 +74,7 @@ void sys_arch_netconn_sem_free(void);
#define LWIP_NETCONN_THREAD_SEM_ALLOC() sys_arch_netconn_sem_alloc()
#define LWIP_NETCONN_THREAD_SEM_FREE() sys_arch_netconn_sem_free()
int lwip_win32_keypressed(void);
#endif /* LWIP_ARCH_SYS_ARCH_H */

18
ports/win32/sys_arch.c

@ -592,3 +592,21 @@ void sys_arch_netconn_sem_free(void)
#endif /* LWIP_NETCONN_SEM_PER_THREAD */
#endif /* !NO_SYS */
/* get keyboard state to terminate the debug app on any kbhit event using win32 API */
int lwip_win32_keypressed(void)
{
INPUT_RECORD rec;
DWORD num = 0;
HANDLE h = GetStdHandle(STD_INPUT_HANDLE);
BOOL ret = PeekConsoleInput(h, &rec, 1, &num);
if (ret) {
if(rec.EventType == KEY_EVENT) {
if(rec.Event.KeyEvent.bKeyDown) {
return 1;
}
}
ReadConsoleInput(h, &rec, 1, &num);
}
return 0;
}

3
ports/win32/test.c

@ -36,7 +36,6 @@
#include <stdarg.h>
#include <time.h>
#include <string.h>
#include <conio.h>
/* lwIP core includes */
#include "lwip/opt.h"
@ -676,7 +675,7 @@ main_loop(void)
#endif
/* MAIN LOOP for driver update (and timers if NO_SYS) */
while (!_kbhit()) {
while (!lwip_win32_keypressed()) {
#if NO_SYS
/* handle timers (already done in tcpip.c when NO_SYS=0) */
sys_check_timeouts();

Loading…
Cancel
Save