Exemplo n.º 1
0
/*
 Callback triggered when the video mode is set (or changed)
 It will recalibrate the mouse boundaries according to video mode width and height
 */
void PS2_UpdateMouse(_THIS)
{
	if (mouseState == MOUSE_AVAILABLE)
	{
		//recalibrate PS2 mouse depending on video resolution, must be called at resolution change...
		int width = this->screen->w;
		int height = this->screen->h;

		// Set mouse boundaries
		PS2MouseSetBoundary(0, width, 0 , height);
		PS2MouseSetReadMode(PS2MOUSE_READMODE_DIFF);

		// Set initial mouse position, threshold and acceleration
		PS2MouseSetPosition(width/2, height/2);
		PS2MouseSetAccel(ACC_DEF);
		PS2MouseSetThres(THRES_DEF);

		printf("[PS2] Mouse calibrated for (0,0,%d,%d)\n[P22] with threshold %d and acceleration %f\n", width, height, THRES_DEF, ACC_DEF);
	}
	else if (mouseState == PAD_AVAILABLE)
	{
		//recalibrate PS2 pad depending on video resolution, must be called at resolution change...
		int width = this->screen->w;
		int height = this->screen->h;

		PADSTEP = width >> 7;
		printf("[PS2] Mouse Pad calibrated for (0,0,%d,%d)\n[P22] with threshold %d and acceleration %f\n", width, height, PADSTEP, 1.0);
	}
Exemplo n.º 2
0
void Ps2Input::warpTo(uint16 x, uint16 y) {
	if ((x >= _minx) && (x <= _maxx) && (y >= _miny) && (y <= _maxy)) {
		_posX = x;
		_posY = y;
	} else {
		_posX = (x < _minx) ? (_minx) : ((x > _maxx) ? (_maxx) : (x));
		_posY = (y < _miny) ? (_miny) : ((y > _maxy) ? (_maxy) : (y));
	}
	if (_mouseLoaded)
		PS2MouseSetPosition(_posX, _posY);
}