Skip to content

Commit

Permalink
Fix vpKeyboard build on UWP platorm
Browse files Browse the repository at this point in the history
  • Loading branch information
fspindle committed Jul 10, 2023
1 parent 3cf8edb commit 5c2a6fb
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions modules/io/src/tools/vpKeyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ vpKeyboard::~vpKeyboard()
{
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
end();
#endif
#endif
}

/*!
Expand All @@ -82,11 +82,10 @@ int vpKeyboard::getchar()
int c;
c = ::getchar();
return c;
#elif defined(_WIN32)
#elif defined(_WIN32) && !defined(WINRT)
return _getch();
#else
std::cout << "vpKeyboard class is not supported by your system!" << std::endl;
return 0;
#elif defined(_WIN32) && defined(WINRT)
throw(vpException(vpException::fatalError, "vpKeyboard::getchar() is not supported on UWP platform!"));
#endif
}

Expand All @@ -97,19 +96,18 @@ int vpKeyboard::getchar()
*/
int vpKeyboard::kbhit()
{
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
struct timeval tv = {0, 0};
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__)))
struct timeval tv = { 0, 0 };
fd_set readfds;

FD_ZERO(&readfds);
FD_SET(STDIN_FILENO, &readfds);

return select(STDIN_FILENO + 1, &readfds, NULL, NULL, &tv) == 1;
#elif defined(_WIN32)
#elif defined(_WIN32) && !defined(WINRT)
return _kbhit();
#else
std::cout << "vpKeyboard class is not supported by your system!" << std::endl;
return 0;
#elif defined(_WIN32) && defined(WINRT)
throw(vpException(vpException::fatalError, "vpKeyboard::kbhit() is not supported on UWP platform!"));
#endif
}

Expand All @@ -119,7 +117,7 @@ int vpKeyboard::kbhit()
Activates the raw mode to read keys in an non blocking way.
*/
void vpKeyboard::init()
{
{
setRawMode(true);
}

Expand Down Expand Up @@ -159,7 +157,8 @@ void vpKeyboard::setRawMode(bool active)
new_settings.c_cc[VTIME] = 0;
tcsetattr(STDIN_FILENO, TCSANOW, &new_settings);

} else {
}
else {
tcsetattr(STDIN_FILENO, TCSANOW, &initial_settings);
}
}
Expand Down

0 comments on commit 5c2a6fb

Please sign in to comment.