Updates by norman vine to controls.hxx.
Joystick auto-coordination tweaks. Additional debuging output when pausing and resuming the sim. Window resizing tweaks by David Megginson (and Norman Vine).
This commit is contained in:
parent
65ea4e8bfc
commit
5f5905f6e8
6 changed files with 64 additions and 51 deletions
src
|
@ -58,6 +58,11 @@ private:
|
|||
double throttle[MAX_ENGINES];
|
||||
double brake[MAX_WHEELS];
|
||||
|
||||
inline void CLAMP(double *x, double min, double max ) {
|
||||
if ( *x < min ) { *x = min; }
|
||||
if ( *x > max ) { *x = max; }
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
FGControls();
|
||||
|
@ -77,8 +82,7 @@ public:
|
|||
// Update functions
|
||||
inline void set_aileron( double pos ) {
|
||||
aileron = pos;
|
||||
if ( aileron < -1.0 ) aileron = -1.0;
|
||||
if ( aileron > 1.0 ) aileron = 1.0;
|
||||
CLAMP( &aileron, -1.0, 1.0 );
|
||||
|
||||
// check for autocoordination
|
||||
if ( current_options.get_auto_coordination() ==
|
||||
|
@ -89,8 +93,7 @@ public:
|
|||
}
|
||||
inline void move_aileron( double amt ) {
|
||||
aileron += amt;
|
||||
if ( aileron < -1.0 ) aileron = -1.0;
|
||||
if ( aileron > 1.0 ) aileron = 1.0;
|
||||
CLAMP( &aileron, -1.0, 1.0 );
|
||||
|
||||
// check for autocoordination
|
||||
if ( current_options.get_auto_coordination() ==
|
||||
|
@ -101,46 +104,38 @@ public:
|
|||
}
|
||||
inline void set_elevator( double pos ) {
|
||||
elevator = pos;
|
||||
if ( elevator < -1.0 ) elevator = -1.0;
|
||||
if ( elevator > 1.0 ) elevator = 1.0;
|
||||
CLAMP( &elevator, -1.0, 1.0 );
|
||||
}
|
||||
inline void move_elevator( double amt ) {
|
||||
elevator += amt;
|
||||
if ( elevator < -1.0 ) elevator = -1.0;
|
||||
if ( elevator > 1.0 ) elevator = 1.0;
|
||||
CLAMP( &elevator, -1.0, 1.0 );
|
||||
}
|
||||
inline void set_elevator_trim( double pos ) {
|
||||
elevator_trim = pos;
|
||||
if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
|
||||
if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
|
||||
CLAMP( &elevator_trim, -1.0, 1.0 );
|
||||
}
|
||||
inline void move_elevator_trim( double amt ) {
|
||||
elevator_trim += amt;
|
||||
if ( elevator_trim < -1.0 ) elevator_trim = -1.0;
|
||||
if ( elevator_trim > 1.0 ) elevator_trim = 1.0;
|
||||
CLAMP( &elevator_trim, -1.0, 1.0 );
|
||||
}
|
||||
inline void set_rudder( double pos ) {
|
||||
rudder = pos;
|
||||
if ( rudder < -1.0 ) rudder = -1.0;
|
||||
if ( rudder > 1.0 ) rudder = 1.0;
|
||||
CLAMP( &rudder, -1.0, 1.0 );
|
||||
}
|
||||
inline void move_rudder( double amt ) {
|
||||
rudder += amt;
|
||||
if ( rudder < -1.0 ) rudder = -1.0;
|
||||
if ( rudder > 1.0 ) rudder = 1.0;
|
||||
CLAMP( &rudder, -1.0, 1.0 );
|
||||
}
|
||||
inline void set_throttle( int engine, double pos ) {
|
||||
if ( engine == ALL_ENGINES ) {
|
||||
for ( int i = 0; i < MAX_ENGINES; i++ ) {
|
||||
throttle[i] = pos;
|
||||
if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
|
||||
if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
|
||||
CLAMP( &throttle[i], 0.0, 1.0 );
|
||||
}
|
||||
} else {
|
||||
if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
|
||||
throttle[engine] = pos;
|
||||
if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
|
||||
if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
|
||||
CLAMP( &throttle[engine], 0.0, 1.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,14 +143,12 @@ public:
|
|||
if ( engine == ALL_ENGINES ) {
|
||||
for ( int i = 0; i < MAX_ENGINES; i++ ) {
|
||||
throttle[i] += amt;
|
||||
if ( throttle[i] < 0.0 ) throttle[i] = 0.0;
|
||||
if ( throttle[i] > 1.0 ) throttle[i] = 1.0;
|
||||
CLAMP( &throttle[i], 0.0, 1.0 );
|
||||
}
|
||||
} else {
|
||||
if ( (engine >= 0) && (engine < MAX_ENGINES) ) {
|
||||
throttle[engine] += amt;
|
||||
if ( throttle[engine] < 0.0 ) throttle[engine] = 0.0;
|
||||
if ( throttle[engine] > 1.0 ) throttle[engine] = 1.0;
|
||||
CLAMP( &throttle[engine], 0.0, 1.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,14 +156,12 @@ public:
|
|||
if ( wheel == ALL_WHEELS ) {
|
||||
for ( int i = 0; i < MAX_WHEELS; i++ ) {
|
||||
brake[i] = pos;
|
||||
if ( brake[i] < 0.0 ) brake[i] = 0.0;
|
||||
if ( brake[i] > 1.0 ) brake[i] = 1.0;
|
||||
CLAMP( &brake[i], 0.0, 1.0 );
|
||||
}
|
||||
} else {
|
||||
if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
|
||||
brake[wheel] = pos;
|
||||
if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
|
||||
if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
|
||||
CLAMP( &brake[wheel], 0.0, 1.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,14 +169,12 @@ public:
|
|||
if ( wheel == ALL_WHEELS ) {
|
||||
for ( int i = 0; i < MAX_WHEELS; i++ ) {
|
||||
brake[i] += amt;
|
||||
if ( brake[i] < 0.0 ) brake[i] = 0.0;
|
||||
if ( brake[i] > 1.0 ) brake[i] = 1.0;
|
||||
CLAMP( &brake[i], 0.0, 1.0 );
|
||||
}
|
||||
} else {
|
||||
if ( (wheel >= 0) && (wheel < MAX_WHEELS) ) {
|
||||
brake[wheel] += amt;
|
||||
if ( brake[wheel] < 0.0 ) brake[wheel] = 0.0;
|
||||
if ( brake[wheel] > 1.0 ) brake[wheel] = 1.0;
|
||||
CLAMP( &brake[wheel], 0.0, 1.0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,9 +360,9 @@ int fgLaRCsim_2_FGInterface (FGInterface& f) {
|
|||
// f.set_Cos_beta( Cos_beta );
|
||||
// f.set_Sin_beta( Sin_beta );
|
||||
|
||||
// f.set_Cos_phi( Cos_phi );
|
||||
f.set_Cos_phi( Cos_phi );
|
||||
// f.set_Sin_phi( Sin_phi );
|
||||
// f.set_Cos_theta( Cos_theta );
|
||||
f.set_Cos_theta( Cos_theta );
|
||||
// f.set_Sin_theta( Sin_theta );
|
||||
// f.set_Cos_psi( Cos_psi );
|
||||
// f.set_Sin_psi( Sin_psi );
|
||||
|
|
|
@ -665,12 +665,12 @@ public:
|
|||
// inline void set_Sin_beta( double sb ) { sin_beta = sb; }
|
||||
|
||||
double cos_phi, sin_phi, cos_theta, sin_theta, cos_psi, sin_psi;
|
||||
// inline double get_Cos_phi() const { return cos_phi; }
|
||||
// inline void set_Cos_phi( double cp ) { cos_phi = cp; }
|
||||
inline double get_Cos_phi() const { return cos_phi; }
|
||||
inline void set_Cos_phi( double cp ) { cos_phi = cp; }
|
||||
// inline double get_Sin_phi() const { return sin_phi; }
|
||||
// inline void set_Sin_phi( double sp ) { sin_phi = sp; }
|
||||
// inline double get_Cos_theta() const { return cos_theta; }
|
||||
// inline void set_Cos_theta( double ct ) { cos_theta = ct; }
|
||||
inline double get_Cos_theta() const { return cos_theta; }
|
||||
inline void set_Cos_theta( double ct ) { cos_theta = ct; }
|
||||
// inline double get_Sin_theta() const { return sin_theta; }
|
||||
// inline void set_Sin_theta( double st ) { sin_theta = st; }
|
||||
// inline double get_Cos_psi() const { return cos_psi; }
|
||||
|
|
|
@ -208,7 +208,11 @@ int fgJoystickRead( void ) {
|
|||
((-js_ax0[2] + 1) / 2) );
|
||||
}
|
||||
if ( js0->getNumAxes() > 3 ) {
|
||||
controls.set_rudder( js_ax0[3] );
|
||||
if ( current_options.get_auto_coordination() !=
|
||||
fgOPTIONS::FG_AUTO_COORD_ENABLED )
|
||||
{
|
||||
controls.set_rudder( js_ax0[3] );
|
||||
}
|
||||
}
|
||||
// End of William's code
|
||||
|
||||
|
@ -216,7 +220,11 @@ int fgJoystickRead( void ) {
|
|||
|
||||
if ( ! js1->notWorking() ) {
|
||||
js1->read( &b, js_ax1 ) ;
|
||||
controls.set_rudder( js_ax1[0] );
|
||||
if ( current_options.get_auto_coordination() !=
|
||||
fgOPTIONS::FG_AUTO_COORD_ENABLED )
|
||||
{
|
||||
controls.set_rudder( js_ax1[0] );
|
||||
}
|
||||
controls.set_throttle( FGControls::ALL_ENGINES, -js_ax1[1] * 1.05 );
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@
|
|||
#include <Cockpit/hud.hxx>
|
||||
#include <GUI/gui.h>
|
||||
#include <Include/fg_constants.h>
|
||||
#include <Misc/fgpath.hxx>
|
||||
#include <Scenery/tilemgr.hxx>
|
||||
#include <Objects/materialmgr.hxx>
|
||||
#include <Time/fg_time.hxx>
|
||||
|
@ -286,15 +287,27 @@ void GLUTkey(unsigned char k, int x, int y) {
|
|||
return;
|
||||
case 112: // p key
|
||||
t->togglePauseMode();
|
||||
// printf position and attitude information
|
||||
FG_LOG( FG_INPUT, FG_INFO,
|
||||
"Lon = " << f->get_Longitude() * RAD_TO_DEG
|
||||
<< " Lat = " << f->get_Latitude() * RAD_TO_DEG
|
||||
<< " Altitude = " << f->get_Altitude() * FEET_TO_METER );
|
||||
FG_LOG( FG_INPUT, FG_INFO,
|
||||
"Heading = " << f->get_Psi() * RAD_TO_DEG
|
||||
<< " Roll = " << f->get_Phi() * RAD_TO_DEG
|
||||
<< " Pitch = " << f->get_Theta() * RAD_TO_DEG );
|
||||
|
||||
{
|
||||
FGBucket p( f->get_Longitude() * RAD_TO_DEG,
|
||||
f->get_Latitude() * RAD_TO_DEG );
|
||||
FGPath tile_path( current_options.get_fg_root() );
|
||||
tile_path.append( "Scenery" );
|
||||
tile_path.append( p.gen_base_path() );
|
||||
tile_path.append( p.gen_index_str() );
|
||||
|
||||
// printf position and attitude information
|
||||
FG_LOG( FG_INPUT, FG_INFO,
|
||||
"Lon = " << f->get_Longitude() * RAD_TO_DEG
|
||||
<< " Lat = " << f->get_Latitude() * RAD_TO_DEG
|
||||
<< " Altitude = " << f->get_Altitude() * FEET_TO_METER
|
||||
);
|
||||
FG_LOG( FG_INPUT, FG_INFO,
|
||||
"Heading = " << f->get_Psi() * RAD_TO_DEG
|
||||
<< " Roll = " << f->get_Phi() * RAD_TO_DEG
|
||||
<< " Pitch = " << f->get_Theta() * RAD_TO_DEG );
|
||||
FG_LOG( FG_INPUT, FG_INFO, tile_path.c_str());
|
||||
}
|
||||
return;
|
||||
case 116: // t key
|
||||
t->adjust_warp_delta (+30);
|
||||
|
|
|
@ -944,11 +944,14 @@ void fgReshape( int width, int height ) {
|
|||
ssgSetFOV( x_fov, y_fov );
|
||||
|
||||
glViewport ( 0, 0, width, height );
|
||||
float fov = current_options.get_fov();
|
||||
ssgSetFOV(fov * current_view.get_win_ratio(), fov);
|
||||
|
||||
if ( idle_state == 1000 ) {
|
||||
// yes we've finished all our initializations and are running
|
||||
// the main loop, so this will now work without seg faulting
|
||||
// the system.
|
||||
solarSystemRebuild();
|
||||
current_view.UpdateViewParams(cur_fdm_state);
|
||||
if ( current_options.get_panel_status() ) {
|
||||
FGPanel::OurPanel->ReInit(0, 0, 1024, 768);
|
||||
|
|
Loading…
Add table
Reference in a new issue