os/boardsupport/emulator/emulatorbsp/specific/multitouch.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/boardsupport/emulator/emulatorbsp/specific/multitouch.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,522 @@
     1.4 +// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// wins\specific\multitouch.cpp
    1.18 +// 
    1.19 +//
    1.20 +#include "multitouch.h"
    1.21 +#include "resource.h"
    1.22 +
    1.23 +#define KDefaultMaxProximity -100
    1.24 +#define KDefaultMaxPressure 5000
    1.25 +#define KDefaultPressureStep 500
    1.26 +#define KDefaultProximityStep 5
    1.27 +
    1.28 +// Static members
    1.29 +DMultiMouse DMultiMouse::iMice[KMaxMice];
    1.30 +int DMultiMouse::iNumMice = 0;
    1.31 +DMultiMouse* DMultiMouse::iPrimary = 0;
    1.32 +int DMultiMouse::iMouseId = 0;
    1.33 +int DMultiTouch::iNumberOfMice = 0;
    1.34 +bool DMultiTouch::iMultiTouchSupported= FALSE;
    1.35 +bool DMultiTouch::iMultiTouchCreated= FALSE;
    1.36 +bool DMultiTouch::iMultiTouchTempEnabled= FALSE;
    1.37 +
    1.38 +// Function pointers for raw input APIs
    1.39 +TYPEOF_RegisterRawInputDevices pfnRegisterRawInputDevices= NULL;
    1.40 +TYPEOF_GetRawInputData pfnGetRawInputData= NULL;
    1.41 +TYPEOF_GetRawInputDeviceList pfnGetRawInputDeviceList=NULL;
    1.42 +
    1.43 +/**
    1.44 + *  Initialise the proximity and pressure information if undefined by the user
    1.45 + */
    1.46 +DMultiTouch::DMultiTouch(TInt aProximityStep, TInt aPressureStep)
    1.47 +	{
    1.48 +	iZMaxRange = KDefaultMaxProximity;
    1.49 +	iMaxPressure = KDefaultMaxPressure;
    1.50 +	iProximityStep = (aProximityStep == -1) ? KDefaultProximityStep : aProximityStep;
    1.51 +	iPressureStep = (aPressureStep == -1) ? KDefaultPressureStep : aPressureStep;
    1.52 +	}
    1.53 +
    1.54 +/** 
    1.55 + * Register all the mice 
    1.56 +*/
    1.57 +BOOL DMultiTouch::Register()
    1.58 +	{
    1.59 +	RAWINPUTDEVICE device;
    1.60 +	device.usUsagePage = 0x01;
    1.61 +	device.usUsage = 0x02;
    1.62 +	device.dwFlags = RIDEV_NOLEGACY; // adds HID mouse and also ignores legacy mouse messages
    1.63 +	device.hwndTarget = 0;
    1.64 +	ShowCursors();
    1.65 +	return pfnRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE));
    1.66 +	}
    1.67 +
    1.68 +/**
    1.69 + * Unregister mice devices
    1.70 + */
    1.71 +BOOL DMultiTouch::UnRegister()
    1.72 +	{
    1.73 +	RAWINPUTDEVICE device;
    1.74 +	device.usUsagePage = 0x01;
    1.75 +	device.usUsage = 0x02;
    1.76 +	device.dwFlags = RIDEV_REMOVE;
    1.77 +	device.hwndTarget = NULL;
    1.78 +	HideCursors();
    1.79 +	return pfnRegisterRawInputDevices(&device, 1, sizeof(RAWINPUTDEVICE));
    1.80 +	}
    1.81 +
    1.82 +
    1.83 +/* * Handle multi-input Window messages
    1.84 + */
    1.85 +void DMultiTouch::OnWmInput(HWND aHWnd,TUint aMessage,TUint aWParam,TUint aLParam,HWND aParentHwnd)
    1.86 +	{
    1.87 +	RAWINPUT ri;
    1.88 +	UINT dwSize = sizeof(ri);
    1.89 +	if (pfnGetRawInputData((HRAWINPUT)aLParam, RID_INPUT, &ri, &dwSize, sizeof(RAWINPUTHEADER))==(UINT)-1)
    1.90 +		{
    1.91 +		OutputDebugString(TEXT("GetRawInputData has an error !\n"));
    1.92 +		}
    1.93 +	else if (ri.header.dwType == RIM_TYPEMOUSE) 
    1.94 +		{
    1.95 +		DMultiMouse* mouse = DMultiMouse::Find(ri.header.hDevice);
    1.96 +		if (mouse)
    1.97 +			{
    1.98 +			if (!DMultiMouse::iPrimary)
    1.99 +				{
   1.100 +				DMultiMouse::iPrimary = mouse;
   1.101 +				DMultiMouse::iPrimary->iIsPrimary = TRUE;
   1.102 +				}
   1.103 +			mouse->HandleRawMouseEvent(ri.data.mouse, aParentHwnd);
   1.104 +			}
   1.105 +		}
   1.106 +	DefWindowProcA(aHWnd, aMessage, aWParam, aLParam);
   1.107 +	}
   1.108 +
   1.109 +void DMultiTouch::HideCursors()
   1.110 +	{
   1.111 +	for (int ii=0; ii<DMultiMouse::iNumMice; ii++)
   1.112 +		{
   1.113 +		DMultiMouse::iMice[ii].iCursorWnd.Hide();
   1.114 +		}
   1.115 +	}
   1.116 +
   1.117 +void DMultiTouch::ShowCursors()
   1.118 +	{
   1.119 +	for (int ii=0; ii<DMultiMouse::iNumMice; ii++)
   1.120 +		{
   1.121 +		DMultiMouse::iMice[ii].iCursorWnd.Show();
   1.122 +		}
   1.123 +	}
   1.124 +
   1.125 +/**
   1.126 + * The cursor window procedure
   1.127 + */
   1.128 +static LRESULT CALLBACK CursorWndProc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
   1.129 +	{
   1.130 +	if (msg==WM_PAINT)
   1.131 +		{
   1.132 +		PAINTSTRUCT ps;
   1.133 +		HDC hdc = BeginPaint(hwnd, &ps);
   1.134 +		CursorWindow* wnd = (CursorWindow*)GetWindowLong(hwnd, GWL_USERDATA);
   1.135 +		DrawIconEx(hdc,0,0, wnd->iCursor,0,0,0,NULL, DI_NORMAL | DI_DEFAULTSIZE);
   1.136 +		EndPaint(hwnd, &ps);
   1.137 +		return 0;
   1.138 +		}
   1.139 +	return DefWindowProc(hwnd, msg, wp, lp);
   1.140 +	}
   1.141 +
   1.142 +CursorWindow::CursorWindow(): iHwnd(NULL),iCursor(NULL),iNumber(0)
   1.143 +	{
   1.144 +	}
   1.145 +
   1.146 +HWND CursorWindow::Create(HMODULE hm, HWND hwndParent, int number)
   1.147 +	{
   1.148 +	// Create the window
   1.149 +	static ATOM atom = NULL;
   1.150 +	if (!atom) 
   1.151 +		{
   1.152 +		WNDCLASSEX wcex;
   1.153 +		ZeroMemory(&wcex, sizeof(wcex));
   1.154 +		wcex.cbSize = sizeof(WNDCLASSEX); 
   1.155 +		wcex.style			= CS_OWNDC;
   1.156 +		wcex.lpfnWndProc	= (WNDPROC)CursorWndProc;
   1.157 +		wcex.hInstance		= (HINSTANCE)hm;
   1.158 +		wcex.lpszClassName	= TEXT("CursorWndClass");
   1.159 +		wcex.hbrBackground = CreateSolidBrush(RGB(255,0,0));//Background color is also for the number
   1.160 +		atom = RegisterClassEx(&wcex);
   1.161 +		}
   1.162 +	iHwnd = CreateWindowA((LPCSTR)atom, NULL, WS_CHILD|WS_CLIPSIBLINGS, 0,0,64,64, hwndParent, NULL, hm, NULL);
   1.163 +	SetWindowLong(iHwnd, GWL_USERDATA, (LONG)this);
   1.164 +	iNumber = number;
   1.165 +	return iHwnd;
   1.166 +	}
   1.167 +
   1.168 +void CursorWindow::Show()
   1.169 +	{
   1.170 +	ShowWindow(iHwnd, SW_NORMAL);
   1.171 +	}
   1.172 +
   1.173 +void CursorWindow::Hide()
   1.174 +	{
   1.175 +	ShowWindow(iHwnd, SW_HIDE);
   1.176 +	}
   1.177 +
   1.178 +BOOL CursorWindow::SetCursor(HCURSOR hc)
   1.179 +	{
   1.180 +	// Duplicate the cursor (because we're going to draw a number on the mask)
   1.181 +	if (iCursor) 
   1.182 +		{
   1.183 +		DestroyCursor(iCursor);
   1.184 +		iCursor = NULL;
   1.185 +		}
   1.186 +	iCursor = CopyCursor(hc);
   1.187 +
   1.188 +	// Get information about the cursor, and select its mask bitmap into a temporary DC.
   1.189 +	ICONINFO ii;
   1.190 +	GetIconInfo(iCursor, &ii);
   1.191 +	iHotspot.x = ii.xHotspot;
   1.192 +	iHotspot.y = ii.yHotspot;
   1.193 +	HDC hdc = CreateCompatibleDC(NULL);
   1.194 +	SelectObject(hdc, ii.hbmMask);
   1.195 +
   1.196 +	// Get the cursor's pixel size	
   1.197 +	BITMAPINFO bmi;
   1.198 +	bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
   1.199 +	bmi.bmiHeader.biBitCount = 0;
   1.200 +	GetDIBits(hdc, ii.hbmMask, 0, 0, NULL, &bmi, DIB_RGB_COLORS);
   1.201 +	int cx = bmi.bmiHeader.biWidth;
   1.202 +	int cy = bmi.bmiHeader.biHeight;
   1.203 +
   1.204 +	// Monochrome cursors have a double-height hbmMask. The top half contains the AND 
   1.205 +	// bitmap (which we do want) and the bottom half contains the XOR bitmap (which we 
   1.206 +	// dont want). Colour cursors have a single normal-height AND mask.
   1.207 +	BOOL isMonochrome = (ii.hbmColor==NULL);
   1.208 +	int cyy = isMonochrome ? (cy>>1) : cy; 
   1.209 +
   1.210 +	// Draw the number into the mask
   1.211 +	char ach[4];
   1.212 +	int ld = iNumber/10;
   1.213 +	int rd = iNumber % 10;
   1.214 +	if (ld > 0)
   1.215 +		{
   1.216 +		wsprintf((LPTSTR)ach, (LPCTSTR)TEXT("%d%d"), ld,rd);
   1.217 +		}
   1.218 +	else 
   1.219 +		{
   1.220 +		wsprintf((LPTSTR)ach, (LPCTSTR)TEXT("%d"), rd);
   1.221 +		}
   1.222 +
   1.223 +	HFONT hf = CreateFontA(12,0, 0,0,FW_THIN, FALSE,FALSE,FALSE, 0,DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, 0, "Arial");
   1.224 +	SelectObject(hdc, hf);
   1.225 +	SetBkMode(hdc, TRANSPARENT);
   1.226 +	TextOutA(hdc, 0,cyy-12, ach, 2);
   1.227 +	DeleteObject(hf);
   1.228 +
   1.229 +	// Get the bits of the mask (in 32-bit colour)
   1.230 +	HANDLE heap = GetProcessHeap();
   1.231 +	bmi.bmiHeader.biBitCount = 32;
   1.232 +	DWORD* bits = (DWORD*)HeapAlloc(heap, 0, cx*cy*4);
   1.233 +	GetDIBits(hdc, ii.hbmMask, 0, cy, bits, &bmi, DIB_RGB_COLORS);
   1.234 +
   1.235 +	// Set the window to the size of the cursor
   1.236 +	SetWindowPos(iHwnd, NULL,0,0,cx,cyy, SWP_NOMOVE);
   1.237 +
   1.238 +	// Create a cursor-shaped region by starting out with an empty region
   1.239 +	// and ORing in each zero-valued mask pixel.
   1.240 +	HRGN rgn = CreateRectRgn(0,0,0,0);
   1.241 +	for (int y=0 ; y<cyy ; y++) 
   1.242 +		{
   1.243 +		for (int x=0 ; x<cx ; x++) 
   1.244 +			{
   1.245 +			if (bits[(cy-y-1)*cx+x]==0) 
   1.246 +				{
   1.247 +				HRGN rgnPix = CreateRectRgn(x,y, x+1,y+1);
   1.248 +				CombineRgn(rgn, rgn, rgnPix, RGN_OR);
   1.249 +				DeleteObject(rgnPix);
   1.250 +				}
   1.251 +			}
   1.252 +		}
   1.253 +
   1.254 +	// Cleanup
   1.255 +	HeapFree(heap, 0, bits);
   1.256 +	DeleteDC(hdc);
   1.257 +
   1.258 +	// Set the window's clipping region to the cursor-shaped region
   1.259 +	SetWindowRgn(iHwnd, rgn, TRUE);
   1.260 +	return TRUE;
   1.261 +	}
   1.262 +	
   1.263 +void CursorWindow::GetPosition(POINT& pt)
   1.264 +	{
   1.265 +	pt.x = 0;
   1.266 +	pt.y = 0;
   1.267 +	MapWindowPoints(iHwnd, GetParent(iHwnd), &pt, 1);
   1.268 +	pt.x += iHotspot.x;
   1.269 +	pt.y += iHotspot.y;
   1.270 +	}
   1.271 +
   1.272 +void CursorWindow::SetPosition(POINT& pt)
   1.273 +	{
   1.274 +	SetWindowPos(iHwnd, NULL, pt.x - iHotspot.x, pt.y - iHotspot.y, 0, 0, SWP_NOSIZE);
   1.275 +	}
   1.276 +
   1.277 +/** 
   1.278 + * Add the mouse device to the collection
   1.279 + */
   1.280 +TInt DMultiMouse::Add(RAWINPUTDEVICELIST& aDev)
   1.281 +	{
   1.282 +	if (iNumMice < KMaxMice)
   1.283 +		{
   1.284 +		DMultiMouse& mouse = iMice[iNumMice];
   1.285 +		mouse.iDevice = aDev.hDevice;
   1.286 +		iNumMice++;
   1.287 +		return KErrNone;
   1.288 +		}
   1.289 +	else
   1.290 +		{
   1.291 +		return KErrOverflow;
   1.292 +		}
   1.293 +	}
   1.294 +
   1.295 +DMultiMouse::DMultiMouse() :
   1.296 +	iX(-1), iY(-1), iZ(0), iDevice(0),iId(-1) 
   1.297 +	{
   1.298 +	}
   1.299 +
   1.300 +DMultiMouse* DMultiMouse::Find(HANDLE aHandle)
   1.301 +	{
   1.302 +	for (TInt ii=0; ii<iNumMice; ii++)
   1.303 +		{
   1.304 +		DMultiMouse& mouse = iMice[ii];
   1.305 +		if (mouse.iDevice == aHandle)
   1.306 +			return &mouse;
   1.307 +		}
   1.308 +	return NULL;
   1.309 +	}
   1.310 +
   1.311 +void DMultiMouse::HandleRawMouseEvent(RAWMOUSE& aEvent, HWND aWnd)
   1.312 +	{
   1.313 +	// give this pointer an id, if it doesn't already have one
   1.314 +	if (iId == -1)
   1.315 +		{
   1.316 +		iId = iMouseId++;
   1.317 +		}
   1.318 +
   1.319 +	// Create the cursor window and set the cursor if not done yet
   1.320 +	if (iCursorWnd.iHwnd == NULL)
   1.321 +		{
   1.322 +		iCursorWnd.Create((HINSTANCE)0, aWnd,iId);
   1.323 +		iCursorWnd.SetCursor(LoadCursorA(NULL, (LPCSTR)IDC_ARROW));
   1.324 +		}
   1.325 +
   1.326 +	CorrectSystemMouse();
   1.327 +			
   1.328 +	// recalc mouse position
   1.329 +	if (iX == -1)
   1.330 +		{
   1.331 +		// initial position
   1.332 +		iX = iPrimary->iX;
   1.333 +		iY = iPrimary->iY;
   1.334 +		}
   1.335 +
   1.336 +	if (aEvent.usFlags & MOUSE_MOVE_ABSOLUTE)
   1.337 +		{
   1.338 +		// absolute position info can update all pointers
   1.339 +		iX = aEvent.lLastX;
   1.340 +		iY = aEvent.lLastY;
   1.341 +		}
   1.342 +	else if (!iIsPrimary)
   1.343 +			{
   1.344 +			// relative position info updates non-primary pointers,
   1.345 +			iX += aEvent.lLastX;
   1.346 +			iY += aEvent.lLastY;
   1.347 +			}
   1.348 +
   1.349 +	// Show the cursor window
   1.350 +	ShowMousePos(aWnd);
   1.351 +
   1.352 +	TInt message = WM_MOUSEMOVE;
   1.353 +
   1.354 +	// get button state
   1.355 +	if (aEvent.usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN)
   1.356 +		{
   1.357 +		message = WM_LBUTTONDOWN;
   1.358 +		iZ = 0;
   1.359 +		}
   1.360 +	
   1.361 +	if (aEvent.usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP)
   1.362 +		{
   1.363 +		message = WM_LBUTTONUP;
   1.364 +		iZ = 0;
   1.365 +		}
   1.366 +	
   1.367 +	if (aEvent.usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN)
   1.368 +		{
   1.369 +		message = WM_RBUTTONDOWN;
   1.370 +		}
   1.371 +	
   1.372 +	if (aEvent.usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP)
   1.373 +		{
   1.374 +		message = WM_RBUTTONUP;
   1.375 +		}
   1.376 +	
   1.377 +	if (aEvent.usButtonFlags & RI_MOUSE_WHEEL)
   1.378 +		{
   1.379 +		message = WM_MOUSEWHEEL;
   1.380 +		if ((TInt16)(aEvent.usButtonData&0x8000)== 0) // positive number
   1.381 +			{
   1.382 +			if (iZ < TheMultiTouch->iMaxPressure)
   1.383 +				{
   1.384 +				if (iZ>=0)
   1.385 +					{ // pressure range 
   1.386 +					iZ += TheMultiTouch->iPressureStep;//Pressure step
   1.387 +					if (iZ > TheMultiTouch->iMaxPressure)
   1.388 +						{
   1.389 +						iZ = TheMultiTouch->iMaxPressure;
   1.390 +						}
   1.391 +					}
   1.392 +				else
   1.393 +					{ // proximity range
   1.394 +					iZ += TheMultiTouch->iProximityStep; //Proximity step
   1.395 +					}
   1.396 +				}
   1.397 +			}
   1.398 +		else
   1.399 +			{
   1.400 +			if (iZ > TheMultiTouch->iZMaxRange)
   1.401 +				{
   1.402 +				if (iZ <= 0)
   1.403 +					{// proximity range 
   1.404 +					iZ -= TheMultiTouch->iProximityStep;//Proximity step
   1.405 +					if (iZ < TheMultiTouch->iZMaxRange)
   1.406 +						{
   1.407 +						iZ = TheMultiTouch->iZMaxRange;
   1.408 +						}
   1.409 +					}
   1.410 +				else
   1.411 +					{// pressure range
   1.412 +					iZ -= TheMultiTouch->iPressureStep;//Pressure step
   1.413 +					}
   1.414 +				}
   1.415 +			}
   1.416 +		}
   1.417 +	
   1.418 +	MultiTouchWndPointer(message, iX, iY, iZ, iId);
   1.419 +	
   1.420 +	}
   1.421 +
   1.422 +/**
   1.423 + * Show the cursor window when the cursor is inside the client area
   1.424 + */
   1.425 +void DMultiMouse::ShowMousePos(HWND aHWnd)
   1.426 +	{
   1.427 +	RECT client = {0,0,0,0};
   1.428 +	if(aHWnd)
   1.429 +		{
   1.430 +		GetWindowRect(aHWnd, &client); 
   1.431 +		POINT pt = {iX-client.left,iY-client.top};
   1.432 +		iCursorWnd.SetPosition(pt);
   1.433 +		}
   1.434 +	iCursorWnd.Show();
   1.435 +	}
   1.436 +
   1.437 +void DMultiMouse::CorrectSystemMouse()
   1.438 +	{
   1.439 +	if (iIsPrimary)
   1.440 +		{
   1.441 +		POINT pos;
   1.442 +		if (GetCursorPos(&pos)) // if failed, pos contains garbage.
   1.443 +			{
   1.444 +			iX = pos.x;
   1.445 +			iY = pos.y;	
   1.446 +			}
   1.447 +		}
   1.448 +	else
   1.449 +		{
   1.450 +		SetCursorPos(iPrimary->iX,iPrimary->iY);
   1.451 +		}
   1.452 +	}
   1.453 +	
   1.454 +/** 
   1.455 + * a static function to check how many mice are connected 
   1.456 +*/
   1.457 +bool DMultiTouch::Init()
   1.458 +	{
   1.459 +	HMODULE hModule = GetModuleHandleA("user32.dll");
   1.460 +	if(hModule == NULL)
   1.461 +		return FALSE;
   1.462 +	
   1.463 +	OSVERSIONINFO osvi;
   1.464 +	ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
   1.465 +	osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
   1.466 +	
   1.467 +	GetVersionEx(&osvi);
   1.468 +	// Check for Win 2K or higher version
   1.469 +	if (osvi.dwMajorVersion < 5)
   1.470 +		{
   1.471 +		return FALSE;
   1.472 +		}
   1.473 +	
   1.474 +	// Not supported on Win2K
   1.475 +	if ((osvi.dwMajorVersion == 5) && (osvi.dwMinorVersion == 0))
   1.476 +		{
   1.477 +		return FALSE;
   1.478 +		}
   1.479 +		
   1.480 +	pfnRegisterRawInputDevices 	= (TYPEOF_RegisterRawInputDevices)GetProcAddress(hModule, "RegisterRawInputDevices");
   1.481 +	pfnGetRawInputData 			= (TYPEOF_GetRawInputData)GetProcAddress(hModule, "GetRawInputData");
   1.482 +	pfnGetRawInputDeviceList 	= (TYPEOF_GetRawInputDeviceList)GetProcAddress(hModule, "GetRawInputDeviceList");
   1.483 +	
   1.484 +	if((pfnRegisterRawInputDevices == NULL) || (pfnGetRawInputData == NULL) || (pfnGetRawInputDeviceList == NULL))
   1.485 +		{
   1.486 +		return FALSE;
   1.487 +		}
   1.488 +		
   1.489 +	UINT nDevices;
   1.490 +	
   1.491 +	if (pfnGetRawInputDeviceList(NULL, &nDevices, sizeof(RAWINPUTDEVICELIST)) != 0)
   1.492 +		{
   1.493 +		return FALSE;
   1.494 +		}
   1.495 +
   1.496 +	RAWINPUTDEVICELIST* pRawInputDeviceList = new RAWINPUTDEVICELIST[ nDevices ];
   1.497 +	if (!pRawInputDeviceList)
   1.498 +		{
   1.499 +		return FALSE;
   1.500 +		}
   1.501 +
   1.502 +	pfnGetRawInputDeviceList(pRawInputDeviceList, &nDevices,
   1.503 +			sizeof(RAWINPUTDEVICELIST));
   1.504 +
   1.505 +	
   1.506 +	for (UINT i=0; i<nDevices; i++)
   1.507 +		{
   1.508 +		RAWINPUTDEVICELIST& dev = pRawInputDeviceList[i];
   1.509 +		if (dev.dwType == RIM_TYPEMOUSE)
   1.510 +			{
   1.511 +			if (DMultiMouse::Add(dev)!=KErrNone)
   1.512 +				{
   1.513 +				//free the device list
   1.514 +				delete[] pRawInputDeviceList;
   1.515 +				return FALSE;
   1.516 +				}
   1.517 +			}
   1.518 +		}
   1.519 +
   1.520 +	delete[] pRawInputDeviceList;
   1.521 +
   1.522 +	// Multitouch is supported when more than 2 mice are connected (including the hidden RID mouse)
   1.523 +	return DMultiMouse::iNumMice > 2;
   1.524 +	}
   1.525 +