Code: Select all
*** JoystickHandler.h.old 2007-01-22 11:27:09.000000000 -0600
--- JoystickHandler.h.new 2007-01-22 00:55:40.000000000 -0600
***************
*** 27,32 ****
--- 27,33 ----
enum {
AXIS_ROLL,
AXIS_PITCH,
+ AXIS_YAW,
AXIS_PRECISION,
AXIS_THRUST,
AXIS_VIEW,
***************
*** 37,42 ****
--- 38,45 ----
enum {
BUTTON_INCTHRUST,
BUTTON_DECTHRUST,
+ BUTTON_INCYAW,
+ BUTTON_DECYAW,
BUTTON_SCANNERZOOM,
BUTTON_JETTISON,
BUTTON_COMPASSMODE,
***************
*** 127,132 ****
--- 130,138 ----
// Roll/pitch axis
- (NSPoint) getRollPitchAxis;
+ // Yaw axis
+ - (double) getYawAxis;
+
// Setting button and axis functions
- (void) setFunctionForAxis: (int)axis
function: (int)function
Code: Select all
*** JoystickHandler.m.old 2007-01-22 11:27:24.000000000 -0600
--- JoystickHandler.m.new 2007-01-22 13:30:05.000000000 -0600
***************
*** 87,92 ****
--- 87,97 ----
return NSMakePoint(axstate[AXIS_ROLL], axstate[AXIS_PITCH]);
}
+ - (double) getYawAxis
+ {
+ return axstate[AXIS_YAW];
+ }
+
- (BOOL) getButtonState: (int)function
{
return butstate[function];
***************
*** 376,381 ****
--- 381,387 ----
break;
case AXIS_ROLL:
case AXIS_PITCH:
+ case AXIS_YAW:
if(precisionMode)
{
axstate[function]=axisvalue / STICK_PRECISIONDIV;
***************
*** 434,444 ****
--- 440,452 ----
{
axstate[AXIS_PITCH] /= STICK_PRECISIONFAC;
axstate[AXIS_ROLL] /= STICK_PRECISIONFAC;
+ axstate[AXIS_YAW] /= STICK_PRECISIONFAC;
}
else
{
axstate[AXIS_PITCH] *= STICK_PRECISIONFAC;
axstate[AXIS_ROLL] *= STICK_PRECISIONFAC;
+ axstate[AXIS_YAW] *= STICK_PRECISIONFAC;
}
}
}
Code: Select all
*** PlayerEntity.h.old 2007-01-22 11:28:20.000000000 -0600
--- PlayerEntity.h.new 2007-01-22 00:42:54.000000000 -0600
***************
*** 126,131 ****
--- 126,132 ----
#define ROLL_DAMPING_FACTOR 1.0
#define PITCH_DAMPING_FACTOR 1.0
+ #define YAW_DAMPING_FACTOR 1.0
#define PLAYER_MAX_FORWARD_SHIELD (128.0 * (shield_booster + shield_enhancer))
#define PLAYER_MAX_AFT_SHIELD (128.0 * (shield_booster + shield_enhancer))
***************
*** 511,516 ****
--- 512,518 ----
int numSticks;
JoystickHandler *stickHandler;
BOOL keyboardRollPitchOverride;
+ BOOL keyboardYawOverride;
// For PlayerEntity (StickMapper)
int selFunctionIdx;
Code: Select all
*** PlayerEntity_StickMapper.m.old 2007-01-22 11:28:41.000000000 -0600
--- PlayerEntity_StickMapper.m.new 2007-01-22 13:30:17.000000000 -0600
***************
*** 279,284 ****
--- 279,289 ----
allowable: HW_AXIS
axisfn: AXIS_PITCH
butfn: STICK_NOFUNCTION]];
+ [funcList addObject:
+ [self makeStickGuiDict: @"Yaw"
+ allowable: HW_AXIS
+ axisfn: AXIS_YAW
+ butfn: STICK_NOFUNCTION]];
[funcList addObject:
[self makeStickGuiDict: @"Increase thrust"
allowable: HW_AXIS|HW_BUTTON
Code: Select all
*** PlayerEntity (Controls).m.old 2007-01-22 11:27:59.000000000 -0600
--- PlayerEntity (Controls).m.new 2007-01-22 22:31:07.000000000 -0600
***************
*** 257,262 ****
--- 257,345 ----
}
#endif
+ // Start Yaw control
+ #ifdef GNUSTEP
+ // DJS: Yaw can be an axis or a button. Axis takes precidence.
+ double virtualYaw=-([stickHandler getAxisState: AXIS_YAW]);
+ double yaw_dampner = YAW_DAMPING_FACTOR * delta_t;
+ yawing = NO;
+ keyboardYawOverride=NO;
+ if ([gameView isDown:key_yaw_left])
+ {
+ keyboardYawOverride=YES;
+ if (flight_yaw < 0.0) flight_yaw = 0.0;
+ [self increase_flight_yaw:delta_t*yaw_delta];
+ yawing = YES;
+ }
+ if ([gameView isDown:key_yaw_right])
+ {
+ keyboardYawOverride=YES;
+ if (flight_yaw > 0.0) flight_yaw = 0.0;
+ [self decrease_flight_yaw:delta_t*yaw_delta];
+ yawing = YES;
+ }
+ if(numSticks && !keyboardYawOverride)
+ {
+ double stick_yaw = max_flight_yaw * virtualYaw;
+ if (flight_yaw < stick_yaw)
+ {
+ [self increase_flight_yaw:delta_t*yaw_delta];
+ if (flight_yaw > stick_yaw)
+ flight_yaw = stick_yaw;
+ }
+ if (flight_yaw > stick_yaw)
+ {
+ [self decrease_flight_yaw:delta_t*yaw_delta];
+ if (flight_yaw < stick_yaw)
+ flight_yaw = stick_yaw;
+ }
+ yawing = (abs(virtualYaw) > .10);
+ }
+ if (!yawing)
+ {
+ if (flight_yaw > 0.0)
+ {
+ if (flight_yaw > yaw_dampner) [self decrease_flight_yaw:yaw_dampner];
+ else flight_yaw = 0.0;
+ }
+ if (flight_yaw < 0.0)
+ {
+ if (flight_yaw < -yaw_dampner) [self increase_flight_yaw:yaw_dampner];
+ else flight_yaw = 0.0;
+ }
+ }
+ #else
+ double yaw_dampner = YAW_DAMPING_FACTOR * delta_t;
+ yawing = NO;
+ if ([gameView isDown:key_yaw_left])
+ {
+ if (flight_yaw < 0.0) flight_yaw = 0.0;
+ [self increase_flight_yaw:delta_t*yaw_delta];
+ yawing = YES;
+ }
+ else if ([gameView isDown:key_yaw_right])
+ {
+ if (flight_yaw > 0.0) flight_yaw = 0.0;
+ [self decrease_flight_yaw:delta_t*yaw_delta];
+ yawing = YES;
+ }
+ if (!yawing)
+ {
+ if (flight_yaw > 0.0)
+ {
+ if (flight_yaw > yaw_dampner) [self decrease_flight_yaw:yaw_dampner];
+ else flight_yaw = 0.0;
+ }
+ if (flight_yaw < 0.0)
+ {
+ if (flight_yaw < -yaw_dampner) [self increase_flight_yaw:yaw_dampner];
+ else flight_yaw = 0.0;
+ }
+ }
+ #endif
+ // End Yaw control
+
+
//
// hyperspeed controls
//
***************
*** 1181,1187 ****
double roll_dampner = ROLL_DAMPING_FACTOR * delta_t;
double pitch_dampner = PITCH_DAMPING_FACTOR * delta_t;
- double yaw_dampner = PITCH_DAMPING_FACTOR * delta_t;
rolling = NO;
if (!mouse_control_on )
--- 1264,1269 ----
***************
*** 1280,1312 ****
else flight_pitch = 0.0;
}
}
-
- yawing = NO;
- if ([gameView isDown:key_yaw_left])
- {
- if (flight_yaw < 0.0) flight_yaw = 0.0;
- [self increase_flight_yaw:delta_t*yaw_delta];
- yawing = YES;
- }
- else if ([gameView isDown:key_yaw_right])
- {
- if (flight_yaw > 0.0) flight_yaw = 0.0;
- [self decrease_flight_yaw:delta_t*yaw_delta];
- yawing = YES;
- }
- if (!yawing)
- {
- if (flight_yaw > 0.0)
- {
- if (flight_yaw > yaw_dampner) [self decrease_flight_yaw:yaw_dampner];
- else flight_yaw = 0.0;
- }
- if (flight_yaw < 0.0)
- {
- if (flight_yaw < -yaw_dampner) [self increase_flight_yaw:yaw_dampner];
- else flight_yaw = 0.0;
- }
- }
}
#else // ifdef GNUSTEP else
- (void) pollFlightArrowKeyControls:(double) delta_t
--- 1362,1367 ----
I'm not sure how to test the non-GNUstep code. I just know the code works both with and without my joystick plugged in. Using a combination of keyboard and joystick at the same time behaves the same for yaw and pitch.
EDIT: Whoops, when I redid the code I forgot to add in joystick button control for yaw. Should support for that really be added in? I'm thinking most multi-button sticks will be multi-axis as well.