the never ending refactor
[carveJwlIkooP6JGAAIwe30JlM.git] / player_common.c
1 #ifndef PLAYER_COMMON_C
2 #define PLAYER_COMMON_C
3
4 #include "player.h"
5
6 void player_look( player_instance *player, v3f angles )
7 {
8 angles[2] = 0.0f;
9 v2_muladds( angles, vg.mouse_delta, 0.0025f, angles );
10
11 if( vg_input.controller_should_use_trackpad_look )
12 {
13 static v2f last_input;
14 static v2f vel;
15 static v2f vel_smooth;
16
17 v2f input = { player->input_js2h->axis.value,
18 player->input_js2v->axis.value };
19
20 if( (v2_length2(last_input) > 0.001f) && (v2_length2(input) > 0.001f) )
21 {
22 v2_sub( input, last_input, vel );
23 v2_muls( vel, 1.0f/vg.time_delta, vel );
24 }
25 else
26 {
27 v2_zero( vel );
28 }
29
30 v2_lerp( vel_smooth, vel, vg.time_delta*8.0f, vel_smooth );
31
32 v2_muladds( angles, vel_smooth, vg.time_delta, angles );
33 v2_copy( input, last_input );
34 }
35 else
36 {
37 angles[0] += player->input_js2h->axis.value * vg.time_delta * 4.0f;
38 angles[1] += player->input_js2v->axis.value * vg.time_delta * 4.0f;
39 }
40
41 angles[1] = vg_clampf( angles[1], -VG_PIf*0.5f, VG_PIf*0.5f );
42 }
43
44 #endif /* PLAYER_COMMON_C */