]> git.tdb.fi Git - libs/gui.git/blobdiff - source/input/windows/touchscreen.cpp
Add an availability check to Touchscreen
[libs/gui.git] / source / input / windows / touchscreen.cpp
index 180f1c04f568816bb9fc8de1ce7ed383c156173e..7e314ca98d39f99ab4eb2cdbc5d1942292ae7d08 100644 (file)
@@ -8,6 +8,28 @@ using namespace std;
 namespace Msp {
 namespace Input {
 
+bool Touchscreen::is_available()
+{
+       // Must have at least Windows 7 (WinNT 6.1) for WM_TOUCHMOVE
+       OSVERSIONINFOEX version;
+       version.dwOSVersionInfoSize = sizeof(version);
+       version.dwMajorVersion = 6;
+       version.dwMinorVersion = 1;
+       version.dwServicePackMajor = 0;
+       version.dwServicePackMinor = 0;
+       DWORD mask = VER_MAJORVERSION|VER_MINORVERSION|VER_SERVICEPACKMAJOR|VER_SERVICEPACKMINOR;
+       DWORDLONG cond = VerSetConditionMask(0, mask, VER_GREATER_EQUAL);
+       if(!VerifyVersionInfo(&version, type, cond))
+               return false;
+
+       if(!GetSystemMetrics(SM_TABLETPC))
+               return false;
+       if(!(GetSystemMetrics(SM_DIGITIZER)&NID_READY))
+               return false;
+
+       return true;
+}
+
 void Touchscreen::input_event(const Graphics::Window::Event &event)
 {
        if(event.msg==WM_TOUCHMOVE)