+
+ if(cl_movecliptokeyboard.integer)
+ {
+ vec_t f = 1;
+ if (in_speed.state & 1)
+ f *= cl_movespeedkey.value;
+ if(cl_movecliptokeyboard.integer == 2)
+ {
+ // digital direction, analog amount
+ vec_t wishvel_x, wishvel_y;
+ f *= max(cl_sidespeed.value, max(cl_forwardspeed.value, cl_backspeed.value));
+ wishvel_x = fabs(cl.cmd.forwardmove);
+ wishvel_y = fabs(cl.cmd.sidemove);
+ if(wishvel_x != 0 && wishvel_y != 0 && wishvel_x != wishvel_y)
+ {
+ vec_t wishspeed = sqrt(wishvel_x * wishvel_x + wishvel_y * wishvel_y);
+ if(wishvel_x >= 2 * wishvel_y)
+ {
+ // pure X motion
+ if(cl.cmd.forwardmove > 0)
+ cl.cmd.forwardmove = wishspeed;
+ else
+ cl.cmd.forwardmove = -wishspeed;
+ cl.cmd.sidemove = 0;
+ }
+ else if(wishvel_y >= 2 * wishvel_x)
+ {
+ // pure Y motion
+ cl.cmd.forwardmove = 0;
+ if(cl.cmd.sidemove > 0)
+ cl.cmd.sidemove = wishspeed;
+ else
+ cl.cmd.sidemove = -wishspeed;
+ }
+ else
+ {
+ // diagonal
+ if(cl.cmd.forwardmove > 0)
+ cl.cmd.forwardmove = 0.70710678118654752440 * wishspeed;
+ else
+ cl.cmd.forwardmove = -0.70710678118654752440 * wishspeed;
+ if(cl.cmd.sidemove > 0)
+ cl.cmd.sidemove = 0.70710678118654752440 * wishspeed;
+ else
+ cl.cmd.sidemove = -0.70710678118654752440 * wishspeed;
+ }
+ }
+ }
+ else if(cl_movecliptokeyboard.integer)
+ {
+ // digital direction, digital amount
+ if(cl.cmd.sidemove >= cl_sidespeed.value * f * 0.5)
+ cl.cmd.sidemove = cl_sidespeed.value * f;
+ else if(cl.cmd.sidemove <= -cl_sidespeed.value * f * 0.5)
+ cl.cmd.sidemove = -cl_sidespeed.value * f;
+ else
+ cl.cmd.sidemove = 0;
+ if(cl.cmd.forwardmove >= cl_forwardspeed.value * f * 0.5)
+ cl.cmd.forwardmove = cl_forwardspeed.value * f;
+ else if(cl.cmd.forwardmove <= -cl_backspeed.value * f * 0.5)
+ cl.cmd.forwardmove = -cl_backspeed.value * f;
+ else
+ cl.cmd.forwardmove = 0;
+ }
+ }