Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
flykeyboard_generic.cpp
Go to the documentation of this file.
1 #include "flykeyboard.h"
2 #include "cmd/unit_generic.h"
3 #include "autodocking.h"
4 #include "config_xml.h"
5 #include "xml_support.h"
6 #include "vs_globals.h"
7 #include "lin_time.h"
8 
10 {
11  static int axis_scale = XMLSupport::parse_int( vs_config->getVariable( "physics", "slide_start", "3" ) );
13  if (as == 0)
14  as = axis_scale;
15  if (as) {
16  v /= as;
17  if (v > 1)
18  return 1;
19  if (v < -1)
20  return -1;
21  }
22  return v;
23 }
24 
26 {
27  static int axis_scale = XMLSupport::parse_int( vs_config->getVariable( "physics", "slide_end", "2" ) );
28  int as = parent->GetComputerData().slide_end;
29  if (as == 0)
30  as = axis_scale;
31  if (as && fabs( v ) > as) {
32  if (v > 0)
33  v -= as;
34  else
35  v += as;
36  } else {
37  v = 0;
38  }
39  return v;
40 }
41 
43 {
44  if (autopilot)
45  autopilot->Destroy();
47 }
48 
50 
52 {
53  if (v == 0) {
54  axis_key.i = reduce_axis( axis_key.i );
55  } else {
56  if ( (v > 0) == (axis_key.i >= 0) )
57  axis_key.i += v;
58  else
59  axis_key.i = v;
60  }
61  Up( clamp_axis( axis_key.i ) );
62 }
63 
65 {
66  if (v == 0) {
67  axis_key.j = reduce_axis( axis_key.j );
68  } else {
69  if ( (v > 0) == (axis_key.j >= 0) )
70  axis_key.j += v;
71  else
72  axis_key.j = v;
73  }
74  Right( clamp_axis( axis_key.j ) );
75 }
76 
78 {
79  if (v == 0) {
80  axis_key.k = reduce_axis( axis_key.k );
81  } else {
82  if ( (v > 0) == (axis_key.k >= 0) )
83  axis_key.k += v;
84  else
85  axis_key.k = v;
86  }
87  RollRight( clamp_axis( axis_key.k ) );
88 }
89 
91 {
92  FlyByKeyboard::Execute( true );
93 }
94