Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 00030 00031 00032 00033 00034 00035 00036 00037 00038 00039 00040 00041 00042 00043 00044 00045 00046 00047 00048 00049 00050 00051 00052 00053 00054 00055 00056 00057 00058 00059 00060 00061 00062 00063 00064 00065 00066 00067 00068 00069 00070 00071 00072 00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 00101 00102 00103 00104 00105 00106 00107 00108 00109 00110 00111 00112 00113 00114 00115 00116 00117 00118 00119 00120 00121 00122 00123 00124 00125 00126 00127 00128 00129 00130 00131 00132 00133 00134 00135 00136 00137 00138 00139 00140 00141 00142 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158 00159 00160 00161 00162 00163 00164 00165 00166 00167 00168 00169 00170 00171 00172 00173 00174 00175 00176 00177 00178 00179 00180 00181 00182 00183 00184 00185 00186 00187 00188 00189 00190 00191 00192 00193 00194 00195 00196 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 00208 00209 00210 00211 00212 00213 00214 00215 00216 00217 00218 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00236 00237 00238 00239 00240 |
//============================================================================= // PlayerInput // Object within playercontroller that manages player input. // only spawned on client //============================================================================= class PlayerInput extends Object within PlayerController config(User) native transient; var globalconfig bool bMaxMouseSmoothing; var globalconfig bool bInvertMouse; var bool bWasForward; // used for doubleclick move var bool bWasBack; var bool bWasLeft; var bool bWasRight; var bool bEdgeForward; var bool bEdgeBack; var bool bEdgeLeft; var bool bEdgeRight; // Mouse smoothing var globalconfig float MouseSensitivity; var float SmoothMouseX, SmoothMouseY, BorrowedMouseX, BorrowedMouseY; var globalconfig float MouseSmoothThreshold; var float MouseZeroTime; //!!MJL (mdf) do we even need this any more given that I made dodging identical // in terms of physics to jumping? Just have animation controller occasionally // pick dodge animation instead of jump animation for 3rd person views (dm)? var float DoubleClickTimer; // max double click interval for double click move var globalconfig float DoubleClickTime; //============================================================================= // Input related functions. // Postprocess the player's input. event PlayerInput( float DeltaTime ) { local float FOVScale, MouseScale, AbsSmoothX, AbsSmoothY, MouseTime; // Check for Double click move // flag transitions bEdgeForward = (bWasForward ^^ (aBaseY > 0)); bEdgeBack = (bWasBack ^^ (aBaseY < 0)); bEdgeLeft = (bWasLeft ^^ (aStrafe > 0)); bEdgeRight = (bWasRight ^^ (aStrafe < 0)); bWasForward = (aBaseY > 0); bWasBack = (aBaseY < 0); bWasLeft = (aStrafe > 0); bWasRight = (aStrafe < 0); // Smooth and amplify mouse movement FOVScale = DesiredFOV * 0.01111; MouseScale = MouseSensitivity * FOVScale; aMouseX *= MouseScale; aMouseY *= MouseScale; MouseTime = (Level.TimeSeconds - MouseZeroTime)/Level.TimeDilation; SmoothMouse(aMouseX, MouseTime, SmoothMouseX, BorrowedMouseX, AbsSmoothX); SmoothMouse(aMouseY, MouseTime, SmoothMouseY, BorrowedMouseY, AbsSmoothY); if ( (aMouseX != 0) || (aMouseY != 0) ) MouseZeroTime = Level.TimeSeconds; // adjust keyboard and joystick movements aLookUp *= FOVScale; aTurn *= FOVScale; // Remap raw x-axis movement. if( bStrafe!=0 ) // strafe aStrafe += aBaseX + SmoothMouseX; else // forward aTurn += aBaseX * FOVScale + SmoothMouseX; aBaseX = 0; // Remap mouse y-axis movement. if( (bStrafe == 0) && (bAlwaysMouseLook || (bLook!=0)) ) { // Look up/down. if ( bInvertMouse ) aLookUp -= SmoothMouseY; else aLookUp += SmoothMouseY; } else // Move forward/backward. aForward += SmoothMouseY; SmoothMouseX = AbsSmoothX; SmoothMouseY = AbsSmoothY; if ( bSnapLevel != 0 ) { bCenterView = true; bKeyboardLook = false; } else if (aLookUp != 0) { bCenterView = false; bKeyboardLook = true; } else if ( bSnapToLevel && !bAlwaysMouseLook ) { bCenterView = true; bKeyboardLook = false; } // Remap other y-axis movement. if ( bFreeLook != 0 ) { bKeyboardLook = true; aLookUp += 0.5 * aBaseY * FOVScale; } else aForward += aBaseY; aBaseY = 0; // scale inputs FIXME REMOVE aForward *= 4; aStrafe *= 4; aLookup *= 0.24; aTurn *= 0.24; aUp *= 1; // Handle walking. HandleWalking(); } function SmoothMouse(float aMouse, float MouseTime, out float SmoothMouse, out float BorrowedMouse, out float AbsSmooth) { AbsSmooth = SmoothMouse; if ( bMaxMouseSmoothing && (aMouse == 0) && (MouseTime < MouseSmoothThreshold) ) { SmoothMouse = 0.5 * (MouseSmoothThreshold - MouseTime) * AbsSmooth/MouseSmoothThreshold; BorrowedMouse += SmoothMouse; } else { if ( (SmoothMouse == 0) || (aMouse == 0) || ((SmoothMouse > 0) != (aMouse > 0)) ) { SmoothMouse = aMouse; BorrowedMouse = 0; } else { SmoothMouse = 0.5 * (SmoothMouse + aMouse - BorrowedMouse); if ( (SmoothMouse > 0) != (aMouse > 0) ) { if ( AMouse > 0 ) SmoothMouse = 1; else SmoothMouse = -1; } BorrowedMouse = SmoothMouse - aMouse; } AbsSmooth = SmoothMouse; } } function UpdateSensitivity(float F) { MouseSensitivity = FMax(0,F); } function ChangeSnapView( bool B ) { bSnapToLevel = B; } exec function SetMouseSmoothThreshold( float F ) { MouseSmoothThreshold = FClamp(F, 0, 0.1); SaveConfig(); } // check for double click move function Actor.eDoubleClickDir CheckForDoubleClickMove(float DeltaTime) { local Actor.eDoubleClickDir DoubleClickMove, OldDoubleClick; if ( DoubleClickDir == DCLICK_Active ) DoubleClickMove = DCLICK_Active; else DoubleClickMove = DCLICK_None; if (DoubleClickTime > 0.0) { if ( DoubleClickDir < DCLICK_Active ) { OldDoubleClick = DoubleClickDir; DoubleClickDir = DCLICK_None; if (bEdgeForward && bWasForward) DoubleClickDir = DCLICK_Forward; else if (bEdgeBack && bWasBack) DoubleClickDir = DCLICK_Back; else if (bEdgeLeft && bWasLeft) DoubleClickDir = DCLICK_Left; else if (bEdgeRight && bWasRight) DoubleClickDir = DCLICK_Right; if ( DoubleClickDir == DCLICK_None) DoubleClickDir = OldDoubleClick; else if ( DoubleClickDir != OldDoubleClick ) DoubleClickTimer = DoubleClickTime + 0.5 * DeltaTime; else DoubleClickMove = DoubleClickDir; } if (DoubleClickDir == DCLICK_Done) { DoubleClickTimer -= DeltaTime; if (DoubleClickTimer < -0.35) { DoubleClickDir = DCLICK_None; DoubleClickTimer = DoubleClickTime; } } else if ((DoubleClickDir != DCLICK_None) && (DoubleClickDir != DCLICK_Active)) { DoubleClickTimer -= DeltaTime; if (DoubleClickTimer < 0) { DoubleClickDir = DCLICK_None; DoubleClickTimer = DoubleClickTime; } } } return DoubleClickMove; } defaultproperties { MouseSensitivity=3.031496 MouseSmoothThreshold=0.070000 DoubleClickTime=0.196850 } |
Overview | Package | Class | Source | Class tree | Glossary | UnrealScript Documentation |
previous class next class | frames no frames |