Commits

Christian Fischer committed da8c716

added touch support for DirectX

Comments (0)

Files changed (1)

src/directx11/wiesel/dx11/video/dx11_video_driver.cpp

 			break;
 		}
 
+		case WM_LBUTTONDOWN: {
+			LONG lp = GetWindowLongPtr(hWnd, GWL_USERDATA);
+			Dx11VideoDeviceDriver *driver = reinterpret_cast<Dx11VideoDeviceDriver*>(lp);
+
+			vector2d location = driver->convertScreenToWorld(vector2d(LOWORD(lParam), HIWORD(lParam)));
+			driver->getScreen()->getTouchHandler()->startTouch(0, location.x, location.y);
+
+			break;
+		}
+
+		case WM_LBUTTONUP: {
+			LONG lp = GetWindowLongPtr(hWnd, GWL_USERDATA);
+			Dx11VideoDeviceDriver *driver = reinterpret_cast<Dx11VideoDeviceDriver*>(lp);
+
+			driver->getScreen()->getTouchHandler()->releaseTouch(0);
+
+			break;
+		}
+
+		case WM_MOUSEMOVE: {
+			LONG lp = GetWindowLongPtr(hWnd, GWL_USERDATA);
+			Dx11VideoDeviceDriver *driver = reinterpret_cast<Dx11VideoDeviceDriver*>(lp);
+
+			vector2d location = driver->convertScreenToWorld(vector2d(LOWORD(lParam), HIWORD(lParam)));
+
+			for(int button=0; button<5; button++) {
+				driver->getScreen()->getTouchHandler()->updateTouchLocation(button, location.x, location.y);
+			}
+
+			break;
+		}
+
 		case WM_DESTROY: {
 			PostQuitMessage(0);
 			break;
 		return false;
 	}
 
+	// store the reference to this object into the window
+	LONG pThis = reinterpret_cast<LONG>(this);
+	SetWindowLongPtr(hWnd, GWL_USERDATA, pThis);
+
+	LONG lp = GetWindowLongPtr(hWnd, GWL_USERDATA);
+	assert(pThis == lp);
+
 	ShowWindow(hWnd, nCmdShow);
 	SetForegroundWindow(hWnd);
 	SetFocus(hWnd);