Просмотр исходного кода

Fixed Windows native multitouch support

Ivan Safrin 13 лет назад
Родитель
Сommit
ffc983a341

+ 2 - 0
Core/Contents/Include/PolyWinCore.h

@@ -188,6 +188,8 @@ public:
 		void handleMouseUp(int mouseCode,LPARAM lParam, WPARAM wParam);
 		void handleTouchEvent(LPARAM lParam, WPARAM wParam);
 
+		bool isMultiTouchEnabled() { return hasMultiTouch; }
+
 		void setVideoMode(int xRes, int yRes, bool fullScreen, bool vSync, int aaLevel, int anisotropyLevel);
 		
 		void initContext(bool usePixelFormat, unsigned int pixelFormat);

+ 6 - 10
Core/Contents/PolycodeView/MSVC/PolycodeView.cpp

@@ -57,12 +57,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 			core->handleMouseUp(CoreInput::MOUSE_BUTTON2, lParam,wParam);
 	break;
 
-	#ifdef WINDOWS_TOUCH_SUPPORT
-		case WM_TOUCH:
-			if(core)
+	case WM_TOUCH:
+		if(core) {
+			if(core->isMultiTouchEnabled()) {
 				core->handleTouchEvent(lParam, wParam);
-		break;
-	#endif
+			}
+		}
+	break;
 
 	case WM_MBUTTONDOWN:
 		if(core)
@@ -135,11 +136,6 @@ WNDCLASSEX wcex;
   hwnd = CreateWindowEx(WS_EX_APPWINDOW, L"POLYCODEAPPLICATION", windowTitle, WS_OVERLAPPED|WS_SYSMENU,
       0, 0, 640, 480, NULL, NULL, hInstance, NULL);
 
-#ifdef WINDOWS_TOUCH_SUPPORT
-	RegisterTouchWindow(hwnd, 0);
-#endif
-	
-
   windowData = (void*)&hwnd;
 
    ShowWindow(hwnd, nCmdShow);

+ 5 - 1
Core/Contents/Source/PolyWinCore.cpp

@@ -842,11 +842,15 @@ void Win32Core::initTouch() {
 	// Check for windows multitouch support at runtime
 	// This could be done easily during preprocessing but would require building
 	// multiple releases of polycode for both winxp/vista and win7
-	GetTouchInputInfoFunc = (GetTouchInputInfoType) GetProcAddress(GetModuleHandle(TEXT("user32.lib")), "GetTouchInputInfo");
+	GetTouchInputInfoFunc = (GetTouchInputInfoType) GetProcAddress(GetModuleHandle(TEXT("user32")), "GetTouchInputInfo");
 	
 	// If the above multitouch functions were found, then set a flag so we don't
 	// have to check again later
 	hasMultiTouch = ( GetTouchInputInfoFunc == NULL ) ? false : true;
+
+	if(hasMultiTouch) {
+			RegisterTouchWindow(hWnd, 0);
+	}
 #endif
 }