ryzom_client_x11_free_look_cam_look.patch

rti, 05/19/2010 01:22 am

Download (4.5 kB)

b/code/ryzom/client/src/events_listener.cpp Wed May 19 00:38:24 2010 +0200
145 145
	// Event from the Mouse (ANGLE)
146 146
	if(event == EventGDMouseMove)
147 147
	{
148
#ifdef NL_OS_WINDOWS
148 149
		CGDMouseMove* mouseEvent=(CGDMouseMove*)&event;
149 150
		// Mouse acceleration
150 151
		sint dX = mouseEvent->X;
151 152
		sint dY = ClientCfg.FreeLookInverted ? -mouseEvent->Y : mouseEvent->Y;
152 153
		updateFreeLookPos((float) dX, (float) dY);
154
#else
155
		// just to make sure that there is no game device implementation un unix
156
		nlerror("not expecting EventGDMouseMove on unix");
157
#endif
153 158
	}
154 159
	// Event from the Mouse (MOVE)
155 160
	else if(event == EventMouseMoveId)
b/code/ryzom/client/src/input.cpp Wed May 19 00:38:24 2010 +0200
65 65
// mask for mouse buttons that are known to be down
66 66
uint							DownMouseButtons = 0;
67 67

68
#ifdef NL_OS_UNIX
69
// on X11, store whether the mouse was captured or not
70
bool							MouseCapture = false;
71
#endif
72

68 73
//////////////
69 74
// FUNCTION //
70 75
//////////////
......
244 249
		}
245 250
		UpdateMouse ();
246 251
	}
252
	
253
#ifdef NL_OS_UNIX
254
	// on X11 the mouse needs to get pulled into the middle each update, else
255
	// the cursor would reach the border of the window / desktop 
256
	// and freelook would hang
257
	Driver->setMousePos(0.5f, 0.5f);
258
#endif
247 259
}
248 260

249 261
//*********************************************************************************
......
360 372
	HWND drvWnd = (HWND) Driver->getDisplay();
361 373
	if (!drvWnd) return;
362 374
	SetCapture(drvWnd);
375
#else
376
	// on X11, set driver mouse capture on and store it locally as well
377
	Driver->setCapture(MouseCapture = true);
363 378
#endif
364 379
}
365 380

366 381
//*********************************************************************************
367 382
void ReleaseSystemCursor()
368 383
{
384
	if (!IsSystemCursorCaptured()) return;
369 385
#ifdef NL_OS_WINDOWS
370
	if (IsSystemCursorCaptured())
386
	// if hardware mouse and not in client area, then force to update its aspect by updating its pos
387
	if (!IsSystemCursorInClientArea())
371 388
	{
372
		// if hardware mouse and not in client area, then force to update its aspect by updating its pos
373
		if (!IsSystemCursorInClientArea())
374
		{
375
			// force update
376
			ShowCursor(FALSE);
377
			ShowCursor(TRUE);
378
		}
379
		ReleaseCapture();
389
		// force update
390
		ShowCursor(FALSE);
391
		ShowCursor(TRUE);
380 392
	}
393
	ReleaseCapture();
394
#else
395
	// on X11, set driver mouse capture off and store it locally as well
396
	Driver->setCapture(MouseCapture = false);
381 397
#endif
382 398
}
383 399

......
388 404
#ifdef NL_OS_WINDOWS
389 405
	return GetCapture() == (HWND) Driver->getDisplay();
390 406
#else
391
	return false;
407
	return MouseCapture;
392 408
#endif
393 409
}
394 410

b/code/ryzom/client/src/motion/user_controls.cpp Wed May 19 00:38:24 2010 +0200
431 431
	// The mouse may still "StandardMove" ie through a CEventMouseMove
432 432
	// This can happens cause DirectInputDisabled, or because of the "Rotation Anti-Lag system"
433 433
	// which start to rotate before the mouse is hid and message mode passed to RawMode
434
	// 
435
	// If we are not on Windows; on X11 there is always StandardMove/CEventMouseMove.
436
	// Currently, there is only a direct input IMouseDevice, not available on X11.
437

438
#ifdef NL_OS_WINDOWS
434 439
	extern IMouseDevice				*MouseDevice;
435 440
	if (MouseDevice)
436 441
	{
......
446 451
			EventsListener.updateFreeLookPos(dmpx, dmpy);
447 452
		}
448 453
	}
454
#else
455
	// On X11, do the thing without IMouseDevice implementation
456
	if( EventsListener.getMousePosX() != _LastFrameMousePosX ||
457
		EventsListener.getMousePosY() != _LastFrameMousePosY )
458
	{
459
		float	dmpx, dmpy;
460
		
461
		// On X11 in free look mode, the mouse is pulled back to (0.5, 0.5) 
462
		// every update to prevent reaching a border and get stuck.
463
		if(IsMouseFreeLook()) 
464
		{
465
			dmpx = EventsListener.getMousePosX() - 0.5;
466
			dmpy = EventsListener.getMousePosY() - 0.5;
467
		}
468
		else 
469
		{
470
			dmpx = EventsListener.getMousePosX() - _LastFrameMousePosX;
471
			dmpy = EventsListener.getMousePosY() - _LastFrameMousePosY;
472
		}
473
		
474
		// TODO: read desktop mouse speed value on X11 / implement X11MouseDevice
475
		dmpx *= 450.0f; 
476
		dmpy *= 450.0f;
477

478
		if(ClientCfg.FreeLookInverted) dmpy = -dmpy;
479
		// update free look
480
		EventsListener.updateFreeLookPos(dmpx, dmpy);
481
	}
482
#endif
449 483

450 484
	// If the mouse move on the axis X, with a CGDMouseMove
451 485
	if(EventsListener.isMouseAngleX())