Allow keyboard arrow keys to override stick

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@143 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Dylan Smith 2005-09-28 20:20:46 +00:00
parent a0bfcbef72
commit e421f6eb56
2 changed files with 22 additions and 2 deletions

View File

@ -435,6 +435,9 @@ Your fair use and other rights are in no way affected by the above.
// Keeping track of joysticks
int numSticks;
JoystickHandler *stickHandler;
BOOL keyboardRollPitchOverride;
// For PlayerEntity (StickMapper)
int selFunctionIdx;
BOOL waitingForStickCallback;
NSArray *stickFunctions;

View File

@ -3148,6 +3148,19 @@ static BOOL taking_snapshot;
else if(numSticks)
{
virtualStick=[stickHandler getRollPitchAxis];
if(virtualStick.x == STICK_AXISUNASSIGNED ||
virtualStick.y == STICK_AXISUNASSIGNED)
{
// Not assigned - set to zero.
virtualStick.x=0;
virtualStick.y=0;
}
else if(virtualStick.x != 0 ||
virtualStick.y != 0)
{
// cancel keyboard override, stick has been waggled
keyboardRollPitchOverride=NO;
}
}
double roll_dampner = ROLL_DAMPING_FACTOR * delta_t;
@ -3158,18 +3171,20 @@ static BOOL taking_snapshot;
{
if ([gameView isDown:key_roll_left])
{
keyboardRollPitchOverride=YES;
if (flight_roll > 0.0) flight_roll = 0.0;
[self decrease_flight_roll:delta_t*roll_delta];
rolling = YES;
}
if ([gameView isDown:key_roll_right])
{
keyboardRollPitchOverride=YES;
if (flight_roll < 0.0) flight_roll = 0.0;
[self increase_flight_roll:delta_t*roll_delta];
rolling = YES;
}
}
if(mouse_control_on || numSticks)
if((mouse_control_on || numSticks) && !keyboardRollPitchOverride)
{
double stick_roll = max_flight_roll * virtualStick.x;
if (flight_roll < stick_roll)
@ -3206,18 +3221,20 @@ static BOOL taking_snapshot;
{
if ([gameView isDown:key_pitch_back])
{
keyboardRollPitchOverride=YES;
if (flight_pitch < 0.0) flight_pitch = 0.0;
[self increase_flight_pitch:delta_t*pitch_delta];
pitching = YES;
}
if ([gameView isDown:key_pitch_forward])
{
keyboardRollPitchOverride=YES;
if (flight_pitch > 0.0) flight_pitch = 0.0;
[self decrease_flight_pitch:delta_t*pitch_delta];
pitching = YES;
}
}
if(mouse_control_on || numSticks)
if((mouse_control_on || numSticks) && !keyboardRollPitchOverride)
{
double stick_pitch = max_flight_pitch * virtualStick.y;
if (flight_pitch < stick_pitch)