1
0
Fork 0

Ralf Gerlich:

- automatic detection of axis directionality, so that axis inputs are appropriately inverted only when necessary
- fixed trim axis names for better understandability
- fixed signs for flaps up/down property increments
- button 0 was previously used for skipping axes and buttons in both loops. Now button 0 can be assigned a binding (e.g., brakes). Instead, moving any axis during the button-assignment-loop indicates skipping.
- The user is now told how to skip a control.
This commit is contained in:
ehofman 2005-07-31 14:05:55 +00:00
parent 83b414482f
commit 5430d87f01
3 changed files with 16 additions and 6 deletions

View file

@ -50,15 +50,18 @@ string axes_propnames[8]={ "/controls/flight/aileron","/controls/flight/elevator
"/sim/current-view/goal-pitch-offset-deg" "/sim/current-view/goal-pitch-offset-deg"
}; };
string axis_posdir[8]= { "right", "down/forward", "right", "forward", "forward", "forward", "left", "upward" };
bool half_range[8]={ false,false,false,true,true,true,false,false }; bool half_range[8]={ false,false,false,true,true,true,false,false };
bool repeatable[8]={ false,false,false,false,false,false,true,true }; bool repeatable[8]={ false,false,false,false,false,false,true,true };
bool invert[8]= { false,true,false,false,false,false,false,true }; bool invert[8]= { false,false,false,false,false,false,false,false };
string button_humannames[8]= { "Left Brake", "Right Brake", string button_humannames[8]= { "Left Brake", "Right Brake",
"Flaps Up", "Flaps Down", "Flaps Up", "Flaps Down",
"Elevator Trim Up", "Elevator Trim Down", "Elevator Trim Forward", "Elevator Trim Backward",
"Landing Gear Up", "Landing Gear Down" "Landing Gear Up", "Landing Gear Down"
}; };
@ -76,7 +79,7 @@ bool button_modup[8]={ true,true,false,false,false,false,false,false };
bool button_boolean[8]={ false,false,false,false,false,false,true,true }; bool button_boolean[8]={ false,false,false,false,false,false,true,true };
float button_step[8]={ 1.0, 1.0, 0.34, -0.34, 0.001, -0.001, 0.0, 1.0 }; float button_step[8]={ 1.0, 1.0, -0.34, 0.34, 0.001, -0.001, 0.0, 1.0 };
string button_repeat[8]={ "false", "false", "false", "false", "true", "true", "false", "false" }; string button_repeat[8]={ "false", "false", "false", "false", "true", "true", "false", "false" };
@ -379,7 +382,8 @@ int main( int argc, char *argv[] ) {
for(control=0;control<=7;control++) { for(control=0;control<=7;control++) {
cout << "Move the control you wish to use for " << axes_humannames[control] cout << "Move the control you wish to use for " << axes_humannames[control]
<< endl; << " " << axis_posdir[control] << endl;
cout << "Pressing a button skips this axis\n";
fflush( stdout ); fflush( stdout );
jsi->getInput(); jsi->getInput();
@ -397,6 +401,7 @@ int main( int argc, char *argv[] ) {
if (strcmp(answer,"n")==0) { if (strcmp(answer,"n")==0) {
control--; control--;
} else { } else {
invert[control]=!jsi->getInputAxisPositive();
if (usexml) { if (usexml) {
writeAxisXML( xfs[jsi->getInputJoystick()], control, jsi->getInputAxis() ); writeAxisXML( xfs[jsi->getInputJoystick()], control, jsi->getInputAxis() );
} else { } else {
@ -424,6 +429,7 @@ int main( int argc, char *argv[] ) {
} else { } else {
cout << "Press the button you wish to use for " << button_humannames[control] << endl; cout << "Press the button you wish to use for " << button_humannames[control] << endl;
} }
cout << "Moving a joystick axis skips this button\n";
fflush( stdout ); fflush( stdout );
jsi->getInput(); jsi->getInput();
if(jsi->getInputButton() != -1) { if(jsi->getInputButton() != -1) {

View file

@ -29,7 +29,7 @@ jsInput::jsInput(jsSuper *j) {
jsInput::~jsInput(void) {} jsInput::~jsInput(void) {}
int jsInput::getInput(void){ int jsInput::getInput(){
bool gotit=false; bool gotit=false;
@ -37,6 +37,7 @@ int jsInput::getInput(void){
int i, current_button = 0, button_bits = 0; int i, current_button = 0, button_bits = 0;
joystick=axis=button=-1; joystick=axis=button=-1;
axis_positive=false;
if(pretty_display) { if(pretty_display) {
printf ( "+----------------------------------------------\n" ) ; printf ( "+----------------------------------------------\n" ) ;
@ -79,6 +80,7 @@ int jsInput::getInput(void){
gotit=true; gotit=true;
joystick=jss->getCurrentJoystickId(); joystick=jss->getCurrentJoystickId();
axis=i; axis=i;
axis_positive=(delta>0);
} else if( current_button != 0 ) { } else if( current_button != 0 ) {
gotit=true; gotit=true;
joystick=jss->getCurrentJoystickId(); joystick=jss->getCurrentJoystickId();
@ -102,7 +104,7 @@ int jsInput::getInput(void){
ulMilliSecondSleep(1); ulMilliSecondSleep(1);
} }
if(button_bits != 0) { if(button_bits != 0) {
for(int i=1;i<=31;i++) { for(int i=0;i<=31;i++) {
if( ( button_bits & (1 << i) ) > 0 ) { if( ( button_bits & (1 << i) ) > 0 ) {
button=i; button=i;
break; break;

View file

@ -34,6 +34,7 @@ class jsInput {
int button_iv[MAX_JOYSTICKS]; int button_iv[MAX_JOYSTICKS];
int joystick,axis,button; int joystick,axis,button;
bool axis_positive;
float axis_threshold; float axis_threshold;
@ -48,6 +49,7 @@ class jsInput {
inline int getInputJoystick(void) { return joystick; } inline int getInputJoystick(void) { return joystick; }
inline int getInputAxis(void) { return axis; } inline int getInputAxis(void) { return axis; }
inline int getInputButton(void) { return button; } inline int getInputButton(void) { return button; }
inline bool getInputAxisPositive(void) { return axis_positive; }
inline float getReturnThreshold(void) { return axis_threshold; } inline float getReturnThreshold(void) { return axis_threshold; }
inline void setReturnThreshold(float ff) inline void setReturnThreshold(float ff)