本文整理汇总了C++中ClampChar函数的典型用法代码示例。如果您正苦于以下问题:C++ ClampChar函数的具体用法?C++ ClampChar怎么用?C++ ClampChar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ClampChar函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: CL_Xbox360ControllerMove
void CL_Xbox360ControllerMove( usercmd_t *cmd )
{
// int movespeed;
float anglespeed;
if ( !( kb[ KB_SPEED ].active ^ cl_run->integer ) )
{
usercmdPressButton( cmd->buttons, BUTTON_WALKING );
}
if ( kb[ KB_SPEED ].active )
{
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
}
else
{
anglespeed = 0.001 * cls.frametime;
}
cl.viewangles[ PITCH ] += anglespeed * cl_pitchspeed->value * ( cl.joystickAxis[ AXIS_PITCH ] / 127.0f );
cl.viewangles[ YAW ] += anglespeed * cl_yawspeed->value * ( cl.joystickAxis[ AXIS_YAW ] / 127.0f );
cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[ AXIS_SIDE ] );
cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[ AXIS_FORWARD ] );
cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[ AXIS_UP ] );
}
开发者ID:Wattos,项目名称:Unvanquished,代码行数:26,代码来源:cl_input.c
示例2: CL_JoystickMove
/*
=================
CL_JoystickMove
=================
*/
void CL_JoystickMove( usercmd_t *cmd ) {
float anglespeed;
if ( !(in_speed.active ^ cl_run->integer) ) {
cmd->buttons |= BUTTON_WALKING;
}
if ( in_speed.active ) {
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
} else {
anglespeed = 0.001 * cls.frametime;
}
if ( !in_strafe.active ) {
cl.viewangles[YAW] += anglespeed * j_yaw->value * cl.joystickAxis[j_yaw_axis->integer];
cmd->rightmove = ClampChar( cmd->rightmove + (int) (j_side->value * cl.joystickAxis[j_side_axis->integer]) );
} else {
cl.viewangles[YAW] += anglespeed * j_side->value * cl.joystickAxis[j_side_axis->integer];
cmd->rightmove = ClampChar( cmd->rightmove + (int) (j_yaw->value * cl.joystickAxis[j_yaw_axis->integer]) );
}
if ( in_mlooking ) {
cl.viewangles[PITCH] += anglespeed * j_forward->value * cl.joystickAxis[j_forward_axis->integer];
cmd->forwardmove = ClampChar( cmd->forwardmove + (int) (j_pitch->value * cl.joystickAxis[j_pitch_axis->integer]) );
} else {
cl.viewangles[PITCH] += anglespeed * j_pitch->value * cl.joystickAxis[j_pitch_axis->integer];
cmd->forwardmove = ClampChar( cmd->forwardmove + (int) (j_forward->value * cl.joystickAxis[j_forward_axis->integer]) );
}
cmd->upmove = ClampChar( cmd->upmove + (int) (j_up->value * cl.joystickAxis[j_up_axis->integer]) );
}
开发者ID:qrealka,项目名称:ioq3,代码行数:36,代码来源:cl_input.c
示例3: CL_Xbox360ControllerMove
void CL_Xbox360ControllerMove(usercmd_t * cmd) {
int movespeed;
float anglespeed;
if(kb[KB_SPEED].active ^ cl_run->integer ) {
movespeed = 2;
}
else {
movespeed = 1;
cmd->buttons |= BUTTON_WALKING;
}
if(kb[KB_SPEED].active) {
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
}
else {
anglespeed = 0.001 * cls.frametime;
}
cl.viewangles[PITCH] += anglespeed * cl_pitchspeed->value * (cl.joystickAxis[j_pitch_axis->integer] / 127.0f);
cl.viewangles[YAW] += anglespeed * cl_yawspeed->value * (cl.joystickAxis[j_yaw_axis->integer] / 127.0f);
cmd->rightmove = ClampChar(cmd->rightmove + cl.joystickAxis[j_side_axis->integer]);
cmd->forwardmove = ClampChar(cmd->forwardmove + cl.joystickAxis[j_forward_axis->integer]);
cmd->upmove = ClampChar(cmd->upmove + cl.joystickAxis[j_up_axis->integer]);
}
开发者ID:TheDushan,项目名称:OpenWolf,代码行数:26,代码来源:cl_input.cpp
示例4: CL_JoystickMove
/*
=================
CL_JoystickMove
=================
*/
void CL_JoystickMove( usercmd_t *cmd ) {
int movespeed;
float anglespeed;
if ( kb[KB_SPEED].active ^ cl_run->integer ) {
movespeed = 2;
} else {
movespeed = 1;
cmd->buttons |= BUTTON_WALKING;
}
if ( kb[KB_SPEED].active ) {
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
} else {
anglespeed = 0.001 * cls.frametime;
}
#ifdef __MACOS__
cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
#else
if ( !kb[KB_STRAFE].active ) {
cl.viewangles[YAW] += anglespeed * cl_yawspeed->value * cl.joystickAxis[AXIS_SIDE];
} else {
cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
}
#endif
if ( kb[KB_MLOOK].active ) {
cl.viewangles[PITCH] += anglespeed * cl_pitchspeed->value * cl.joystickAxis[AXIS_FORWARD];
} else {
cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] );
}
cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] );
}
开发者ID:chegestar,项目名称:omni-bot,代码行数:39,代码来源:cl_input.c
示例5: CL_JoystickMove
/*
=================
CL_JoystickMove
=================
*/
void CL_JoystickMove( usercmd_t *cmd ) {
int movespeed;
float anglespeed;
if ( in_speed.active ^ cl_run->integer ) {
movespeed = 2;
} else {
movespeed = 1;
cmd->buttons |= BUTTON_WALKING;
}
if ( in_speed.active ) {
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
} else {
anglespeed = 0.001 * cls.frametime;
}
if ( !in_strafe.active ) {
cl.viewangles[YAW] += anglespeed * cl_yawspeed->value * cl.joystickAxis[AXIS_SIDE];
} else {
cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
}
if ( in_mlooking ) {
cl.viewangles[PITCH] += anglespeed * cl_pitchspeed->value * cl.joystickAxis[AXIS_FORWARD];
} else {
cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] );
}
cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] );
}
开发者ID:Amanieu,项目名称:tremfusion,代码行数:36,代码来源:cl_input.c
示例6: CL_JoystickMove
/*
=================
CL_JoystickMove
=================
*/
void CL_JoystickMove( usercmd_t *cmd ) {
float anglespeed;
if ( !in_joystick->integer )
{
return;
}
if( in_joystick->integer == 2 )
{
if(abs(cl.joystickAxis[AXIS_FORWARD]) >= 30) cmd->forwardmove = cl.joystickAxis[AXIS_FORWARD];
if(abs(cl.joystickAxis[AXIS_SIDE]) >= 30) cmd->rightmove = cl.joystickAxis[AXIS_SIDE];
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
cl.viewangles[YAW] -= (cl_yawspeed->value / 100.0f) * (cl.joystickAxis[AXIS_YAW]/1024.0f);
cl.viewangles[PITCH] += (cl_pitchspeed->value / 100.0f) * (cl.joystickAxis[AXIS_PITCH]/1024.0f);
}
else
{
if ( !(in_speed.active ^ cl_run->integer) ) {
cmd->buttons |= BUTTON_WALKING;
}
if ( in_speed.active ) {
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
} else {
anglespeed = 0.001 * cls.frametime;
}
if ( !in_strafe.active ) {
if ( cl_mYawOverride )
{
cl.viewangles[YAW] += 5.0f * cl_mYawOverride * cl.joystickAxis[AXIS_SIDE];
}
else
{
cl.viewangles[YAW] += anglespeed * (cl_yawspeed->value / 100.0f) * cl.joystickAxis[AXIS_SIDE];
}
} else
{
cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
}
if ( in_mlooking ) {
if ( cl_mPitchOverride )
{
cl.viewangles[PITCH] += 5.0f * cl_mPitchOverride * cl.joystickAxis[AXIS_FORWARD];
}
else
{
cl.viewangles[PITCH] += anglespeed * (cl_pitchspeed->value / 100.0f) * cl.joystickAxis[AXIS_FORWARD];
}
} else {
cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] );
}
cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] );
}
}
开发者ID:Malchio,项目名称:OpenJK,代码行数:63,代码来源:cl_input.cpp
示例7: CL_MouseMove
/*
=================
CL_MouseMove
=================
*/
void CL_MouseMove( usercmd_t *cmd ) {
float mx, my;
float accelSensitivity;
float rate;
// allow mouse smoothing
if ( m_filter->integer ) {
mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;
my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;
} else {
mx = cl.mouseDx[cl.mouseIndex];
my = cl.mouseDy[cl.mouseIndex];
}
cl.mouseIndex ^= 1;
cl.mouseDx[cl.mouseIndex] = 0;
cl.mouseDy[cl.mouseIndex] = 0;
rate = sqrt( mx * mx + my * my ) / (float)frame_msec;
accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;
// scale by FOV
accelSensitivity *= cl.cgameSensitivity;
if ( rate && cl_showMouseRate->integer ) {
Com_Printf( "%f : %f\n", rate, accelSensitivity );
}
mx *= accelSensitivity;
my *= accelSensitivity;
if (!mx && !my) {
return;
}
// add mouse X/Y movement to cmd
if ( in_strafe.active ) {
cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
} else {
// hmm inverted?!
cl.viewangles[YAW] += m_yaw->value * mx;
}
if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
cl.viewangles[PITCH] += m_pitch->value * my;
} else {
cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );
}
}
开发者ID:alexander-pick,项目名称:Quake3-HD--iPAD-,代码行数:53,代码来源:cl_input.c
示例8: haptic_stuff
void haptic_stuff(cvar_t sens)
{
int i;
if(!haptic_ok)
return;
dhdGetPosition(&axes[0],&axes[1],&axes[2],DHD);
if(axes[0] == 0 && axes[1] == 0 && axes[2] == 0)
return;
for(i=0;i<BTN_CNT;i++)
buf->buttons[i] = (char)(haptic_btn() == 1<<i);
if(cnt > 0)
cnt -= 1;
if(buf->buttons[0] && cnt < 5)
cnt += (rand()%5)+3;
//haptic_print(axes,"sts");
// 0 -> down
// 1 -> right -> 3
buf->views[0] = (float)axes[2] * -15.0 * sens.value;
buf->views[1] = (float)axes[1];
//buf->views[0] = (float)axes[2];
//buf->views[1] = (float)axes[1];
haptic_move(buf->views,(sens.value)*15.0);
double Y = axes[0]*100;
if(Y < 1.0 && Y > -1.0)
Y = 0;
else
Y *= -32.0;
buf->fmove = ClampChar(Y);
haptic_joystick(axes,cnt);
//haptic_force(axes);
dhdSetForce(axes[0],axes[1],axes[2],DHD);
return;
}
开发者ID:pvtmert,项目名称:ioq3_dhd,代码行数:33,代码来源:haptics.cpp
示例9: CL_MouseMove
static void CL_MouseMove( usercmd_t* cmd )
{
float mx, my;
// allow mouse smoothing
if ( m_filter->integer ) {
mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;
my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;
} else {
mx = cl.mouseDx[cl.mouseIndex];
my = cl.mouseDy[cl.mouseIndex];
}
cl.mouseIndex ^= 1;
cl.mouseDx[cl.mouseIndex] = 0;
cl.mouseDy[cl.mouseIndex] = 0;
if (!mx && !my)
return;
float rate = sqrt( mx * mx + my * my ) / (float)frame_msec;
float speed = m_speed->value + rate * m_accel->value;
if (m_limit->value && (speed > m_limit->value))
speed = m_limit->value;
// scale by FOV (+zoom only)
speed *= cl.cgameSensitivity;
if ( cl_showMouseRate->integer )
Com_Printf( "%f %f : %f\n", mx, my, speed );
mx *= speed;
my *= speed;
// add mouse X/Y movement to cmd
if ( in_strafe.active ) {
cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
} else {
cl.viewangles[YAW] -= m_yaw->value * mx;
}
if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
cl.viewangles[PITCH] += m_pitch->value * my;
} else {
cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );
}
}
开发者ID:DaTa-,项目名称:cnq3x,代码行数:47,代码来源:cl_input.cpp
示例10: CL_KeyMove
/*
================
CL_KeyMove
Sets the usercmd_t based on key states
================
*/
void
CL_KeyMove(usercmd_t * cmd)
{
int movespeed;
int forward, side, up;
//
// adjust for speed key / running
// the walking flag is to keep animations consistant
// even during acceleration and develeration
//
if (in_speed.active ^ cl_run->integer)
{
movespeed = 127;
cmd->buttons &= ~BUTTON_WALKING;
}
else
{
cmd->buttons |= BUTTON_WALKING;
movespeed = 64;
}
forward = 0;
side = 0;
up = 0;
if (in_strafe.active)
{
side += movespeed * CL_KeyState(&in_right);
side -= movespeed * CL_KeyState(&in_left);
}
side += movespeed * CL_KeyState(&in_moveright);
side -= movespeed * CL_KeyState(&in_moveleft);
up += movespeed * CL_KeyState(&in_up);
up -= movespeed * CL_KeyState(&in_down);
forward += movespeed * CL_KeyState(&in_forward);
forward -= movespeed * CL_KeyState(&in_back);
cmd->forwardmove = ClampChar(forward);
cmd->rightmove = ClampChar(side);
cmd->upmove = ClampChar(up);
}
开发者ID:lrq3000,项目名称:ioquake3-anti-cheat,代码行数:52,代码来源:cl_input.c
示例11: CG_MouseMove
/*
=================
CG_MouseMove
=================
*/
void CG_MouseMove( localPlayer_t *player, clientInput_t *ci, usercmd_t *cmd, float mx, float my )
{
// ingame FOV
mx *= player->zoomSensitivity;
my *= player->zoomSensitivity;
// add mouse X/Y movement to cmd
if(ci->in_strafe.active)
{
cmd->rightmove = ClampChar(cmd->rightmove + m_side.value * mx);
}
else
player->viewangles[YAW] -= m_yaw.value * mx;
if ((ci->in_mlooking || cg_freelook.integer) && !ci->in_strafe.active)
player->viewangles[PITCH] += m_pitch.value * my;
else
cmd->forwardmove = ClampChar(cmd->forwardmove - m_forward.value * my);
}
开发者ID:KuehnhammerTobias,项目名称:ioid3-game,代码行数:24,代码来源:cg_input.c
示例12: CL_AndroidMove
void CL_AndroidMove( usercmd_t *cmd )
{
//cmd->forwardmove += forwardmove * cl_forwardspeed->value * 2; //Always run! (x2)
//cmd->rightmove += sidemove * cl_sidespeed->value * 2;
cmd->forwardmove = ClampChar(cmd->forwardmove + forwardmove * 127 );
cmd->rightmove = ClampChar(cmd->rightmove + sidemove * 127 );
if ((abs(cmd->forwardmove) > 80) || (abs(cmd->rightmove) > 80))
cmd->buttons &= ~BUTTON_WALKING;
else
cmd->buttons |= BUTTON_WALKING;
switch(look_pitch_mode)
{
case LOOK_MODE_MOUSE:
cl.viewangles[PITCH] += look_pitch_mouse * 300;
look_pitch_mouse = 0;
break;
case LOOK_MODE_ABSOLUTE:
cl.viewangles[PITCH] = look_pitch_abs * 80;
break;
case LOOK_MODE_JOYSTICK:
cl.viewangles[PITCH] += look_pitch_joy * 6;
break;
}
switch(look_yaw_mode)
{
case LOOK_MODE_MOUSE:
cl.viewangles[YAW] += look_yaw_mouse * 300;
look_yaw_mouse = 0;
break;
case LOOK_MODE_JOYSTICK:
cl.viewangles[YAW] += look_yaw_joy * 6;
break;
}
}
开发者ID:emileb,项目名称:OpenJK,代码行数:40,代码来源:in_android.cpp
示例13: BotDirectionToUsercmd
void BotDirectionToUsercmd( gentity_t *self, vec3_t dir, usercmd_t *cmd )
{
vec3_t forward;
vec3_t right;
float forwardmove;
float rightmove;
signed char speed = BotGetMaxMoveSpeed( self );
AngleVectors( self->client->ps.viewangles, forward, right, nullptr );
forward[2] = 0;
VectorNormalize( forward );
right[2] = 0;
VectorNormalize( right );
// get direction and non-optimal magnitude
forwardmove = speed * DotProduct( forward, dir );
rightmove = speed * DotProduct( right, dir );
// find optimal magnitude to make speed as high as possible
if ( Q_fabs( forwardmove ) > Q_fabs( rightmove ) )
{
float highestforward = forwardmove < 0 ? -speed : speed;
float highestright = highestforward * rightmove / forwardmove;
cmd->forwardmove = ClampChar( highestforward );
cmd->rightmove = ClampChar( highestright );
}
else
{
float highestright = rightmove < 0 ? -speed : speed;
float highestforward = highestright * forwardmove / rightmove;
cmd->forwardmove = ClampChar( highestforward );
cmd->rightmove = ClampChar( highestright );
}
}
开发者ID:ChunHungLiu,项目名称:Unvanquished,代码行数:39,代码来源:sg_bot_nav.cpp
示例14: CL_AccelMove
/*
==============
CL_AccelMove
==============
*/
void CL_AccelMove( usercmd_t *cmd ) {
if (!cl_accelLook->integer) {
if ( labs( cl.accelAngles[ROLL] ) > cl_accelDeadZone->integer )
{
int roll = cl.accelAngles[ROLL];
roll+= (roll > 0) ? -cl_accelDeadZone->integer : cl_accelDeadZone->integer;
cmd->rightmove = ClampChar( cmd->rightmove + roll * cl_accelScale->value );
}
if ( labs( cl.accelAngles[PITCH] ) > cl_accelDeadZone->integer )
{
int pitch = cl.accelAngles[PITCH];
pitch+= (pitch > 0 ) ? -cl_accelDeadZone->integer : cl_accelDeadZone->integer;
cmd->forwardmove = ClampChar( cmd->forwardmove + pitch * cl_accelScale->value );
}
} else {
// TODO: Scale by FPS:
cl.viewangles[YAW]-= cl.accelAngles[ROLL] * cl_accelLookScale->value;
cl.viewangles[PITCH]+= cl.accelAngles[PITCH] * cl_accelLookScale->value;
}
}
开发者ID:alexander-pick,项目名称:Quake3-HD--iPAD-,代码行数:28,代码来源:cl_input.c
示例15: CL_JoystickMove
/*
=================
CL_JoystickMove
=================
*/
void CL_JoystickMove(usercmd_t* cmd) {
// int movespeed;
float anglespeed;
if (kb[KB_SPEED].active == (cl_run->integer != 0)) {
usercmdPressButton(cmd->buttons, BUTTON_WALKING);
}
if (kb[KB_SPEED].active) {
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
} else {
anglespeed = 0.001 * cls.frametime;
}
#ifdef __MACOS__
cmd->rightmove = ClampChar(cmd->rightmove + cl.joystickAxis[AXIS_SIDE]);
#else
if (!kb[KB_STRAFE].active) {
cl.viewangles[YAW] +=
anglespeed * j_yaw->value * cl.joystickAxis[j_yaw_axis->integer];
cmd->rightmove =
ClampChar(cmd->rightmove +
(int) (j_side->value * cl.joystickAxis[j_side_axis->integer]));
} else {
cl.viewangles[YAW] +=
anglespeed * j_side->value * cl.joystickAxis[j_side_axis->integer];
cmd->rightmove =
ClampChar(cmd->rightmove +
(int) (j_yaw->value * cl.joystickAxis[j_yaw_axis->integer]));
}
#endif
if (kb[KB_MLOOK].active) {
cl.viewangles[PITCH] += anglespeed * j_forward->value *
cl.joystickAxis[j_forward_axis->integer];
cmd->forwardmove = ClampChar(
cmd->forwardmove +
(int) (j_pitch->value * cl.joystickAxis[j_pitch_axis->integer]));
} else {
cl.viewangles[PITCH] +=
anglespeed * j_pitch->value * cl.joystickAxis[j_pitch_axis->integer];
cmd->forwardmove = ClampChar(
cmd->forwardmove +
(int) (j_forward->value * cl.joystickAxis[j_forward_axis->integer]));
}
cmd->upmove = ClampChar(
cmd->upmove + (int) (j_up->value * cl.joystickAxis[j_up_axis->integer]));
}
开发者ID:Kangz,项目名称:Unvanquished,代码行数:56,代码来源:cl_input.cpp
示例16: haptic_dealwith
void haptic_dealwith(cvar_t **arr, usercmd_t *cmd, float *va, void *btns)
{
int i;
if(!arr || !arr[0] || !(arr[0]->value) || !cmd || !va || !btns || va == NULL)
return;
if(!haptic_ok)
return;
haptic_getpos(axes);
if(axes[0] == 0 && axes[1] == 0 && axes[2] == 0)
return;
{
//char fire = haptic_press(2);
//char jump = haptic_press(0);
for(i=0;i<BTN_CNT;i++)
((kbutton_t*)btns)[i].active = (qboolean)(haptic_btn() == 1<<i);
if(cnt > 0)
cnt -= 1;
if(((kbutton_t*)btns)[0].active && cnt < 5)
cnt += (rand()%5)+3;
if(!arr[1] || !arr[2])
return;
haptic_move(va,(arr[2]->value)*15.0);
//in_speed.active = qtrue;
if(arr[1]->value)
{
double Y = axes[0]*100;
if(Y < 1.0 && Y > -1.0)
Y = 0;
else
Y *= -32.0;
cmd->forwardmove = ClampChar(Y);
}
//if(!(axes[1] < -0.045 && axes[1] > 0.046 && axes[2] < -0.045 && axes[2] > 0.054))
{
haptic_joystick(axes,cnt);
haptic_force(axes);
}
}
return;
}
开发者ID:pvtmert,项目名称:ioq3_dhd,代码行数:40,代码来源:haptics.cpp
示例17: CL_JoystickMove
void CL_JoystickMove( usercmd_t *cmd ) {
if ( !in_joystick->integer )
{
return;
}
#ifdef _WIN32
if( in_joystick->integer == 2 )
{
if(abs(cl.joystickAxis[AXIS_FORWARD]) >= 30) cmd->forwardmove = cl.joystickAxis[AXIS_FORWARD];
if(abs(cl.joystickAxis[AXIS_SIDE]) >= 30) cmd->rightmove = cl.joystickAxis[AXIS_SIDE];
}
else
{
#endif
float anglespeed;
if ( !(in_speed.active ^ cl_run->integer) ) {
cmd->buttons |= BUTTON_WALKING;
}
if ( in_speed.active ) {
anglespeed = 0.001 * cls.frametime * cl_anglespeedkey->value;
} else {
anglespeed = 0.001 * cls.frametime;
}
if ( !in_strafe.active ) {
if ( cl_mYawOverride )
{
if ( cl_mSensitivityOverride )
{
cl.viewangles[YAW] += cl_mYawOverride * cl_mSensitivityOverride * cl.joystickAxis[AXIS_SIDE]/2.0f;
}
else
{
cl.viewangles[YAW] += cl_mYawOverride * OVERRIDE_MOUSE_SENSITIVITY * cl.joystickAxis[AXIS_SIDE]/2.0f;
}
}
else
{
cl.viewangles[YAW] += anglespeed * (cl_yawspeed->value / 100.0f) * cl.joystickAxis[AXIS_SIDE];
}
} else
{
cmd->rightmove = ClampChar( cmd->rightmove + cl.joystickAxis[AXIS_SIDE] );
}
if ( in_mlooking || cl_freelook->integer ) {
if ( cl_mPitchOverride )
{
if ( cl_mSensitivityOverride )
{
cl.viewangles[PITCH] += cl_mPitchOverride * cl_mSensitivityOverride * cl.joystickAxis[AXIS_FORWARD]/2.0f;
}
else
{
cl.viewangles[PITCH] += cl_mPitchOverride * OVERRIDE_MOUSE_SENSITIVITY * cl.joystickAxis[AXIS_FORWARD]/2.0f;
}
}
else
{
cl.viewangles[PITCH] += anglespeed * (cl_pitchspeed->value / 100.0f) * cl.joystickAxis[AXIS_FORWARD];
}
} else
{
cmd->forwardmove = ClampChar( cmd->forwardmove + cl.joystickAxis[AXIS_FORWARD] );
}
cmd->upmove = ClampChar( cmd->upmove + cl.joystickAxis[AXIS_UP] );
#ifdef _WIN32
}
#endif
}
开发者ID:Almightygir,项目名称:OpenJK,代码行数:74,代码来源:cl_input.cpp
示例18: CL_MouseMove
/*
=================
CL_MouseMove
=================
*/
void CL_MouseMove( usercmd_t *cmd ) {
float mx, my;
float accelSensitivity;
float rate;
const float speed = static_cast<float>(frame_msec);
const float pitch = cl_bUseFighterPitch?m_pitchVeh->value:m_pitch->value;
// allow mouse smoothing
if ( m_filter->integer ) {
mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5;
my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5;
} else {
mx = cl.mouseDx[cl.mouseIndex];
my = cl.mouseDy[cl.mouseIndex];
}
cl.mouseIndex ^= 1;
cl.mouseDx[cl.mouseIndex] = 0;
cl.mouseDy[cl.mouseIndex] = 0;
rate = SQRTFAST( mx * mx + my * my ) / speed;
if ( cl_mYawOverride || cl_mPitchOverride )
{//FIXME: different people have different speed mouses,
if ( cl_mSensitivityOverride )
{
//this will fuck things up for them, need to clamp
//max input?
accelSensitivity = cl_mSensitivityOverride;
}
else
{
accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;
// scale by FOV
accelSensitivity *= cl.cgameSensitivity;
}
}
else
{
accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;
// scale by FOV
accelSensitivity *= cl.cgameSensitivity;
}
if ( rate && cl_showMouseRate->integer ) {
Com_Printf( "%f : %f\n", rate, accelSensitivity );
}
mx *= accelSensitivity;
my *= accelSensitivity;
if (!mx && !my) {
return;
}
// add mouse X/Y movement to cmd
if ( in_strafe.active ) {
cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
} else {
if ( cl_mYawOverride )
{
cl.viewangles[YAW] -= cl_mYawOverride * mx;
}
else
{
cl.viewangles[YAW] -= m_yaw->value * mx;
}
}
if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
// VVFIXME - This is supposed to be a CVAR
const float cl_pitchSensitivity = 1.0f;
if ( cl_mPitchOverride )
{
if ( pitch > 0 )
{
cl.viewangles[PITCH] += cl_mPitchOverride * my * cl_pitchSensitivity;
}
else
{
cl.viewangles[PITCH] -= cl_mPitchOverride * my * cl_pitchSensitivity;
}
}
else
{
cl.viewangles[PITCH] += pitch * my * cl_pitchSensitivity;
}
} else {
cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );
}
}
开发者ID:Almightygir,项目名称:OpenJK,代码行数:95,代码来源:cl_input.cpp
示例19: CL_MouseMove
void CL_MouseMove( usercmd_t *cmd ) {
float mx, my;
// allow mouse smoothing
if ( m_filter->integer ) {
mx = ( cl.mouseDx[0] + cl.mouseDx[1] ) * 0.5f;
my = ( cl.mouseDy[0] + cl.mouseDy[1] ) * 0.5f;
} else {
mx = cl.mouseDx[cl.mouseIndex];
my = cl.mouseDy[cl.mouseIndex];
}
cl.mouseIndex ^= 1;
cl.mouseDx[cl.mouseIndex] = 0;
cl.mouseDy[cl.mouseIndex] = 0;
if ( mx == 0.0f && my == 0.0f ) {
return;
}
if ( cl_mouseAccel->value != 0.0f ) {
if ( cl_mouseAccelStyle->integer == 0 ) {
float accelSensitivity;
float rate;
rate = sqrt( mx * mx + my * my ) / (float)frame_msec;
accelSensitivity = cl_sensitivity->value + rate * cl_mouseAccel->value;
mx *= accelSensitivity;
my *= accelSensitivity;
} else {
// sensitivity remains pretty much unchanged at low speeds
// cl_mouseAccel is a power value to how the acceleration is shaped
// cl_mouseAccelOffset is the rate for which the acceleration will have doubled the non accelerated amplificatio
// NOTE: decouple the config cvars for independent acceleration setup along X and Y?
float rate[2];
float power[2];
rate[0] = fabs( mx ) / (float)frame_msec;
rate[1] = fabs( my ) / (float)frame_msec;
power[0] = powf( rate[0] / cl_mouseAccelOffset->value, cl_mouseAccel->value );
power[1] = powf( rate[1] / cl_mouseAccelOffset->value, cl_mouseAccel->value );
mx = cl_sensitivity->value * ( mx + ( 1.0f - 2.0f * FLOATSIGNBITSET( mx ) ) * power[0] * cl_mouseAccelOffset->value );
my = cl_sensitivity->value * ( my + ( 1.0f - 2.0f * FLOATSIGNBITSET( my ) ) * power[1] * cl_mouseAccelOffset->value );
}
} else {
mx *= cl_sensitivity->value;
my *= cl_sensitivity->value;
}
// ingame FOV
mx *= cl.cgameSensitivity;
my *= cl.cgameSensitivity;
// add mouse X/Y movement to cmd
if ( in_strafe.active ) {
cmd->rightmove = ClampChar( cmd->rightmove + m_side->value * mx );
} else {
cl.viewangles[YAW] -= m_yaw->value * mx;
}
if ( (in_mlooking || cl_freelook->integer) && !in_strafe.active ) {
cl.viewangles[PITCH] += m_pitch->value * my;
} else {
cmd->forwardmove = ClampChar( cmd->forwardmove - m_forward->value * my );
}
}
开发者ID:Amanieu,项目名称:tremfusion,代码行数:67,代码来源:cl_input.c
示例20: CL_MouseMove
void CL_MouseMove(usercmd_t *cmd) {
float mx, my;
// allow mouse smoothing
if (m_filter->boolean) {
mx = (cl.mouseDx[0] + cl.mouseDx[1]) * 0.5f;
my = (cl.mouseDy[0] + cl.mouseDy[1]) * 0.5f;
}
else {
mx = (float)cl.mouseDx[cl.mouseIndex];
my = (float)cl.mouseDy[cl.mouseIndex];
}
cl.mouseIndex ^= 1;
cl.mouseDx[cl.mouseIndex] = 0;
cl.mouseDy[cl.mouseIndex] = 0;
if (mx == 0.0f && my == 0.0f)
return;
if (m_accel->value > 0.0f)
{
if(m_accelStyle->integer == 0)
{
float accelSensitivity;
float rate;
rate = sqrtf(mx*mx + my*my) / (float) frame_msec;
accelSensitivity = 1.0f + rate * m_accel->value;
mx *= accelSensitivity;
my *= accelSensitivity;
if(cl_showMouseRate->integer)
Com_Printf("rate: %f, accelSensitivity: %f\n", rate, accelSensitivity);
}
else
{
float rate[2];
float power[2];
// sensitivity remains pretty much unchanged at low speeds
// cl_mouseAccel is a power value to how the acceleration is shaped
// cl_mouseAccelOffset is the rate for which the acceleration will have doubled the non accelerated amplification
// NOTE: decouple the config cvars for independent acceleration setup along X and Y?
rate[0] = fabsf(mx) / (float) frame_msec;
rate[1] = fabsf(my) / (float) frame_msec;
power[0] = powf(rate[0] / m_accelOffset->value, m_accel->value);
power[1] = powf(rate[1] / m_accelOffset->value, m_accel->value);
mx = (mx + ((mx < 0) ? -power[0] : power[0]) * m_accelOffset->value);
my = (my + ((my < 0) ? -power[1] : power[1]) * m_accelOffset->value);
if(cl_showMouseRate->integer)
Com_Printf("ratex: %f, ratey: %f, powx: %f, powy: %f\n", rate[0], rate[1], power[0], power[1]);
}
}
// ingame FOV
mx *= cl.cgameSensitivity;
my *= cl.cgameSensitivity;
if ( in_mouseDebug->integer > 2 )
Com_Printf( "CL_MouseMove: mx my (%.2f, %.2f)\n", mx, my );
if ( in_mouseDebug->integer == 3 )
Com_Printf( "CL_MouseMove: cl.viewangles (%.2f %.2f) -> ", cl.viewangles.yaw, cl.viewangles.pitch );
// add mouse X/Y movement to cmd
if(in_strafe.active)
cmd->rightmove = ClampChar( cmd->rightmove + (int)(m_side->value * mx) );
else
cl.viewangles.yaw -= mx * m_sensitivity->value;
if ((in_mlooking || cl_freelook->integer) && !in_strafe.active)
cl.viewangles.pitch += my * m_sensitivity->value;
else
cmd->forwardmove = ClampChar( cmd->forwardmove - (int)(m_forward->value * my) );
if ( in_mouseDebug->integer == 3 )
Com_Printf( "(%.2f %.2f)\n", cl.viewangles.yaw, cl.viewangles.pitch );
}
开发者ID:Razish,项目名称:QtZ,代码行数:83,代码来源:cl_input.c
注:本文中的ClampChar函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论