Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- inline float CALCULATE_RADIANS2(float line_length)
- {
- return acos((2 - (line_length * line_length)) / 2);
- }
- void IN_MouseMove(float frametime, usercmd_t* cmd)
- {
- int mx, my;
- vec3_t viewangles;
- //LiTHiuM
- float current_frame_time_ratio = 1 / frametime;
- //float current_frame_time_ratio = MAX_FRAME_TIME / frametime;
- float max_move_x = gEngfuncs.GetWindowCenterX() / current_frame_time_ratio;
- float max_move_y = gEngfuncs.GetWindowCenterY() / current_frame_time_ratio;
- //END LiTHiuM
- gEngfuncs.GetViewAngles((float*)viewangles);
- // Ricochet: Don't let them move the mouse when they're in spectator mode
- int iSpectator = !bCanMoveMouse();
- //jjb - this disbles normal mouse control if the user is trying to
- // move the camera
- if (!iMouseInUse && !g_iVisibleMouse && !iSpectator)
- {
- GetCursorPos(¤t_pos);
- mx = (current_pos.x) - gEngfuncs.GetWindowCenterX();
- my = (current_pos.y) - gEngfuncs.GetWindowCenterY();
- IN_ResetMouse();
- if (m_filter->value)
- {
- float accel_multiplier_x = max_move_x / 0.2;
- float accel_multiplier_y = max_move_y / 0.2;
- //XVAL and YVAL are the number of radians
- float xval = mx / max_move_x;
- float yval = my / max_move_y;
- //float xval = (mx * sensitivity->value) / max_move_x;
- //float yval = (my * sensitivity->value) / max_move_y;
- float x_mul = CALCULATE_RADIANS2(min(abs(xval), 1) * 2) / 0.5;
- float y_mul = CALCULATE_RADIANS2(min(abs(yval), 1) * 2) / 0.5;
- //float x_mul = CALCULATE_RADIANS2(min(abs(xval), 1) * 2) * accel_multiplier_x / 0.5;
- //float y_mul = CALCULATE_RADIANS2(min(abs(yval), 1) * 2) * accel_multiplier_y / 0.5;
- mouse_x = x_mul * mx;
- mouse_y = y_mul * my;
- //IN_MOUSE_MOVE: frametime = 0.009950, mx = 0, my = 0, mouse_x : 0 mouse_y : 0 xval : 0.000000, yval : 0.000000, accel_multiplier_x : 20.099693, accel_multiplier_y : 35.732788, max_move_x : 47.761921, max_move_y : 26.866081
- char msg[256];
- _snprintf(msg, sizeof(msg), "IN_MOUSE_MOVE: frametime=%f, mx=%d, my=%d, mouse_x: %d mouse_y: %d xval: %f, yval: %f, accel_multiplier_x: %f, accel_multiplier_y: %f, max_move_x: %f, max_move_y: %f\n", frametime, mx, my, mouse_x, mouse_y, xval, yval, accel_multiplier_x, accel_multiplier_y, max_move_x, max_move_y);
- ConsolePrint(msg);
- }
- else
- {
- mouse_x = mx;
- mouse_y = my;
- }
- /*
- //IF FOV IS NOT DEFAULT_FOV
- if (gHUD.GetSensitivity() != 0)
- {
- //mouse_x *= gHUD.GetSensitivity();
- //mouse_y *= gHUD.GetSensitivity();
- }
- //ELSE
- else
- {
- //mouse_x *= sensitivity->value;
- //mouse_y *= sensitivity->value;
- }
- */
- // add mouse X/Y movement to cmd
- if ((in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1)))
- cmd->sidemove += m_side->value * mouse_x;
- else
- viewangles[YAW] -= m_yaw->value * mouse_x;
- if (in_mlook.state & 1)
- {
- V_StopPitchDrift();
- }
- if ((in_mlook.state & 1) && !(in_strafe.state & 1))
- {
- viewangles[PITCH] += m_pitch->value * mouse_y;
- if (viewangles[PITCH] > cl_pitchdown->value)
- viewangles[PITCH] = cl_pitchdown->value;
- if (viewangles[PITCH] < -cl_pitchup->value)
- viewangles[PITCH] = -cl_pitchup->value;
- }
- else
- {
- if ((in_strafe.state & 1) && gEngfuncs.IsNoClipping())
- {
- cmd->upmove -= m_forward->value * mouse_y;
- }
- else
- {
- cmd->forwardmove -= m_forward->value * mouse_y;
- }
- }
- // if the mouse has moved, force it to the center, so there's room to move
- //if (mx || my)
- //{
- // IN_ResetMouse();
- //}
- }
- gEngfuncs.SetViewAngles((float*)viewangles);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement