Example #1
0
void CG_MouseEvent(int x, int y) {
	switch ((int)cgs.eventHandling) {
	case CGAME_EVENT_SPEAKEREDITOR:
	case CGAME_EVENT_GAMEVIEW:
	case CGAME_EVENT_CAMPAIGNBREIFING:
	case CGAME_EVENT_FIRETEAMMSG:
		cgs.cursorX += x;
		if (cgs.cursorX < 0) {
			cgs.cursorX = 0;
		} else if (cgs.cursorX > 640) {
			cgs.cursorX = 640;
		}

		cgs.cursorY += y;
		if (cgs.cursorY < 0) {
			cgs.cursorY = 0;
		} else if (cgs.cursorY > 480) {
			cgs.cursorY = 480;
		}

		if ((int)cgs.eventHandling == CGAME_EVENT_SPEAKEREDITOR) {
			CG_SpeakerEditorMouseMove_Handling(x, y);
		}

		break;
	case CGAME_EVENT_DEMO:
		cgs.cursorX += x;
		if (cgs.cursorX < 0) {
			cgs.cursorX = 0;
		} else if (cgs.cursorX > 640) {
			cgs.cursorX = 640;
		}

		cgs.cursorY += y;
		if (cgs.cursorY < 0) {
			cgs.cursorY = 0;
		} else if (cgs.cursorY > 480) {
			cgs.cursorY = 480;
		}

		if (x != 0 || y != 0) {
			cgs.cursorUpdate = cg.time + 5000;
		}
		break;


	default:
		// default handling
		if ((cg.predictedPlayerState.pm_type == PM_NORMAL ||
		     cg.predictedPlayerState.pm_type == PM_SPECTATOR) &&
		    cg.showScores == qfalse) {
			trap_Key_SetCatcher(trap_Key_GetCatcher() & ~KEYCATCH_CGAME);
			return;
		}
		break;
	}
}
Example #2
0
/**
 * @brief CG_MouseEvent
 * @param[in] x
 * @param[in] y
 */
void CG_MouseEvent(int x, int y)
{
	switch (cgs.eventHandling)
	{
	case CGAME_EVENT_DEMO:
	case CGAME_EVENT_MULTIVIEW:
		if (x != 0 || y != 0)
		{
			cgs.cursorUpdate = cg.time + 5000;
		} // fall through
	case CGAME_EVENT_SPEAKEREDITOR:
	case CGAME_EVENT_GAMEVIEW:
	case CGAME_EVENT_CAMPAIGNBREIFING:
	case CGAME_EVENT_FIRETEAMMSG:

#ifdef FEATURE_EDV
		if (!cgs.demoCamera.renderingFreeCam)
		{
#endif

		cgs.cursorX += x;
		if (cgs.cursorX < 0)
		{
			cgs.cursorX = 0;
		}
		else if (cgs.cursorX > SCREEN_WIDTH_SAFE)
		{
			cgs.cursorX = SCREEN_WIDTH_SAFE;
		}

		cgs.cursorY += y;
		if (cgs.cursorY < 0)
		{
			cgs.cursorY = 0;
		}
		else if (cgs.cursorY > SCREEN_HEIGHT_SAFE)
		{
			cgs.cursorY = SCREEN_HEIGHT_SAFE;
		}

		if (cgs.eventHandling == CGAME_EVENT_SPEAKEREDITOR)
		{
			CG_SpeakerEditorMouseMove_Handling(x, y);
		}
#ifdef FEATURE_EDV
	}
	else
	{
		// mousemovement *should* feel the same as ingame
		char buffer[64];
		int  mx = 0, my = 0;
		int  mouse_x_pos = 0, mouse_y_pos = 0;

		float sensitivity, m_pitch, m_yaw;
		int   m_filter = 0;

		if (demo_lookat.integer != -1)
		{
			return;
		}

		mx += x;
		my += y;

		trap_Cvar_VariableStringBuffer("m_filter", buffer, sizeof(buffer));
		m_filter = atoi(buffer);

		trap_Cvar_VariableStringBuffer("sensitivity", buffer, sizeof(buffer));
		sensitivity = atof(buffer);

		trap_Cvar_VariableStringBuffer("m_pitch", buffer, sizeof(buffer));
		m_pitch = atof(buffer);

		trap_Cvar_VariableStringBuffer("m_yaw", buffer, sizeof(buffer));
		m_yaw = atof(buffer);

		if (m_filter)
		{
			mouse_x_pos = (mx + old_mouse_x_pos) / 2;
			mouse_y_pos = (my + old_mouse_y_pos) / 2;
		}
		else
		{
			mouse_x_pos = mx;
			mouse_y_pos = my;
		}

		old_mouse_x_pos = mx;
		old_mouse_y_pos = my;

		mouse_x_pos *= sensitivity;
		mouse_y_pos *= sensitivity;

		cg.refdefViewAngles[YAW]   -= m_yaw * mouse_x_pos;
		cg.refdefViewAngles[PITCH] += m_pitch * mouse_y_pos;

		if (cg.refdefViewAngles[PITCH] < -90)
		{
			cg.refdefViewAngles[PITCH] = -90;
		}

		if (cg.refdefViewAngles[PITCH] > 90)
		{
			cg.refdefViewAngles[PITCH] = 90;
		}
	}
#endif
		break;
	default:
		if (cg.snap->ps.pm_type == PM_INTERMISSION)
		{
			CG_Debriefing_MouseEvent(x, y);
			return;
		}

		// default handling
		if ((cg.predictedPlayerState.pm_type == PM_NORMAL ||
		     cg.predictedPlayerState.pm_type == PM_SPECTATOR) &&
		    cg.showScores == qfalse)
		{
			trap_Key_SetCatcher(trap_Key_GetCatcher() & ~KEYCATCH_CGAME);
			return;
		}
		break;
	}
}