MCPcopy Create free account
hub / github.com/JACoders/OpenJK / CL_KeyState

Function CL_KeyState

code/client/cl_input.cpp:238–270  ·  view source on GitHub ↗

=============== CL_KeyState Returns the fraction of the frame that the key was down =============== */

Source from the content-addressed store, hash-verified

236===============
237*/
238float CL_KeyState( kbutton_t *key ) {
239 float val;
240 int msec;
241
242 msec = key->msec;
243 key->msec = 0;
244
245 if ( key->active ) {
246 // still down
247 if ( !key->downtime ) {
248 msec = com_frameTime;
249 } else {
250 msec += com_frameTime - key->downtime;
251 }
252 key->downtime = com_frameTime;
253 }
254
255#if 0
256 if (msec) {
257 Com_Printf ("%i ", msec);
258 }
259#endif
260
261 val = (float)msec / frame_msec;
262 if ( val < 0 ) {
263 val = 0;
264 }
265 if ( val > 1 ) {
266 val = 1;
267 }
268
269 return val;
270}
271
272
273

Callers 2

CL_AdjustAnglesFunction · 0.70
CL_KeyMoveFunction · 0.70

Calls 1

Com_PrintfFunction · 0.50

Tested by

no test coverage detected