Posted: Fri Aug 31, 2007 5:25 am
Seems like a good idea to me. I have sometimes when I had a very fast ship tinkered with the pitch- and role-rate in its shipdata, simply reducing the values to make it handable more precisely.
For information and discussion about Oolite.
https://bb.oolite.space/
Sounds like a good idea indeed. I've often felt that the movement of MSX's Elite was different to Oolite. If you could control/tweak acc/dec rates for all axes you could finetune your movement to your liking. That's what i would like.Commander McLane wrote:Seems like a good idea to me. I have sometimes when I had a very fast ship tinkered with the pitch- and role-rate in its shipdata, simply reducing the values to make it handable more precisely.
Never mind! There have been older discussions re-animated here before, and...zeep wrote:*ouch sorry to bump a 3 months old post*
Sorry to re-animate a zombie thread.SgtSchultz wrote:If the ability to yaw is left in future versions, it would be nice if yaw could be mapped to a joystick axis, just as one can do so with pitch and roll now. And, of course, the yaw axis should respond to the "precision movement" [joystick] toggle that the other axes respond to.
Wish granted.Gadget wrote:SgtSchultz wrote:Analogue yaw would be very nice.
Code: Select all
~/pkgs/oolite/svn/trunk/src$ svn diff
Index: SDL/JoystickHandler.h
===================================================================
--- SDL/JoystickHandler.h (revision 1501)
+++ SDL/JoystickHandler.h (working copy)
@@ -40,6 +40,7 @@
enum {
AXIS_ROLL,
AXIS_PITCH,
+ AXIS_YAW,
AXIS_PRECISION,
AXIS_THRUST,
AXIS_VIEW,
@@ -140,6 +141,9 @@
// Roll/pitch axis
- (NSPoint) getRollPitchAxis;
+// Yaw axis
+- (NSPoint) getYawAxis;
+
// Setting button and axis functions
- (void) setFunctionForAxis: (int)axis
function: (int)function
Index: SDL/JoystickHandler.m
===================================================================
--- SDL/JoystickHandler.m (revision 1501)
+++ SDL/JoystickHandler.m (working copy)
@@ -97,6 +97,11 @@
return NSMakePoint(axstate[AXIS_ROLL], axstate[AXIS_PITCH]);
}
+- (NSPoint) getYawAxis
+{
+ return NSMakePoint(-axstate[AXIS_YAW], 0.0);
+}
+
- (BOOL) getButtonState: (int)function
{
return butstate[function];
@@ -386,6 +391,7 @@
break;
case AXIS_ROLL:
case AXIS_PITCH:
+ case AXIS_YAW:
if(precisionMode)
{
axstate[function]=axisvalue / STICK_PRECISIONDIV;
@@ -444,11 +450,13 @@
{
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;
}
}
}
Index: Cocoa/JoystickHandler.h
===================================================================
--- Cocoa/JoystickHandler.h (revision 1501)
+++ Cocoa/JoystickHandler.h (working copy)
@@ -60,6 +60,7 @@
enum {
AXIS_ROLL,
AXIS_PITCH,
+ AXIS_YAW,
AXIS_PRECISION,
AXIS_THRUST,
AXIS_VIEW,
@@ -135,6 +136,7 @@
- (int) getNumSticks;
- (NSPoint) getRollPitchAxis;
+- (NSPoint) getYawAxis;
- (const BOOL *)getAllButtonStates;
@end
Index: Cocoa/JoystickHandler.m
===================================================================
--- Cocoa/JoystickHandler.m (revision 1501)
+++ Cocoa/JoystickHandler.m (working copy)
@@ -72,6 +72,12 @@
}
+- (NSPoint)getYawAxis
+{
+ return NSMakePoint(0.0f, 0.0f);
+}
+
+
- (const BOOL *)getAllButtonStates
{
return butstate;
Index: Core/Entities/ShipEntity.m
===================================================================
--- Core/Entities/ShipEntity.m (revision 1501)
+++ Core/Entities/ShipEntity.m (working copy)
@@ -240,7 +240,7 @@
maxFlightSpeed = [shipDict floatForKey:@"max_flight_speed"];
max_flight_roll = [shipDict floatForKey:@"max_flight_roll"];
max_flight_pitch = [shipDict floatForKey:@"max_flight_pitch"];
- max_flight_yaw = [shipDict floatForKey:@"max_flight_yaw" defaultValue:max_flight_pitch];// Note by default yaw == pitch
+ max_flight_yaw = [shipDict floatForKey:@"max_flight_yaw" defaultValue:(max_flight_pitch/2.0)]; // Note by default yaw == pitch/2
thrust = [shipDict floatForKey:@"thrust"];
Index: Core/Entities/PlayerEntityControls.m
===================================================================
--- Core/Entities/PlayerEntityControls.m (revision 1501)
+++ Core/Entities/PlayerEntityControls.m (working copy)
@@ -431,6 +431,7 @@
out the joystick if the player runs to the keyboard)
is reset */
keyboardRollPitchOverride = NO;
+ keyboardYawOverride = NO;
}
else
{
@@ -2139,6 +2140,7 @@
{
MyOpenGLView *gameView = [UNIVERSE gameView];
NSPoint virtualStick = NSZeroPoint;
+ NSPoint virtualYaw = NSZeroPoint;
#define kDeadZone 0.02
// TODO: Rework who owns the stick.
@@ -2158,6 +2160,7 @@
double sensitivity = 2.0;
virtualStick.x *= sensitivity;
virtualStick.y *= sensitivity;
+ virtualYaw.x = 0.0;
}
else if(numSticks)
{
@@ -2175,11 +2178,23 @@
// cancel keyboard override, stick has been waggled
keyboardRollPitchOverride=NO;
}
+ // handle yaw separately from pitch/roll
+ virtualYaw=[stickHandler getYawAxis];
+ if(virtualYaw.x == STICK_AXISUNASSIGNED)
+ {
+ virtualYaw.x=0;
+ printf("STICK_AXISUNASSIGNED: %f\n", virtualYaw.x);
+ }
+ else if(virtualYaw.x != 0)
+ {
+ // cancel keyboard override, stick has been waggled
+ keyboardYawOverride=NO;
+ }
}
double roll_dampner = ROLL_DAMPING_FACTOR * delta_t;
double pitch_dampner = PITCH_DAMPING_FACTOR * delta_t;
- double yaw_dampner = PITCH_DAMPING_FACTOR * delta_t;
+ double yaw_dampner = YAW_DAMPING_FACTOR * delta_t;
rolling = NO;
if (!mouse_control_on )
@@ -2214,7 +2229,7 @@
if (flightRoll < stick_roll)
flightRoll = stick_roll;
}
- rolling = (abs(virtualStick.x) > kDeadZone);
+ rolling = (fabs(virtualStick.x) > kDeadZone);
}
if (!rolling)
{
@@ -2263,7 +2278,7 @@
if (flightPitch < stick_pitch)
flightPitch = stick_pitch;
}
- pitching = (abs(virtualStick.x) > kDeadZone);
+ pitching = (fabs(virtualStick.y) > kDeadZone);
}
if (!pitching)
{
@@ -2284,16 +2299,35 @@
yawing = NO;
if ([gameView isDown:key_yaw_left])
{
+ keyboardYawOverride=YES;
if (flightYaw < 0.0) flightYaw = 0.0;
[self increase_flight_yaw:delta_t*yaw_delta];
yawing = YES;
}
else if ([gameView isDown:key_yaw_right])
{
+ keyboardYawOverride=YES;
if (flightYaw > 0.0) flightYaw = 0.0;
[self decrease_flight_yaw:delta_t*yaw_delta];
yawing = YES;
}
+ if(numSticks && !keyboardRollPitchOverride && !keyboardYawOverride)
+ {
+ double stick_yaw = max_flight_yaw * virtualYaw.x;
+ if (flightYaw < stick_yaw)
+ {
+ [self increase_flight_yaw:delta_t*yaw_delta];
+ if (flightYaw > stick_yaw)
+ flightYaw = stick_yaw;
+ }
+ if (flightYaw > stick_yaw)
+ {
+ [self decrease_flight_yaw:delta_t*yaw_delta];
+ if (flightYaw < stick_yaw)
+ flightYaw = stick_yaw;
+ }
+ yawing = (fabs(virtualYaw.x) > kDeadZone);
+ }
if (!yawing)
{
if (flightYaw > 0.0)
Index: Core/Entities/PlayerEntity.h
===================================================================
--- Core/Entities/PlayerEntity.h (revision 1501)
+++ Core/Entities/PlayerEntity.h (working copy)
@@ -125,6 +125,7 @@
#define ROLL_DAMPING_FACTOR 1.0
#define PITCH_DAMPING_FACTOR 1.0
+#define YAW_DAMPING_FACTOR 1.0
#define PLAYER_MAX_WEAPON_TEMP 256.0
#define PLAYER_MAX_FUEL 70
@@ -448,6 +449,7 @@
isSpeechOn: 1,
keyboardRollPitchOverride: 1,
+ keyboardYawOverride: 1,
waitingForStickCallback: 1;
// Note: joystick stuff does nothing under OS X.
Index: Core/Entities/PlayerEntity.m
===================================================================
--- Core/Entities/PlayerEntity.m (revision 1501)
+++ Core/Entities/PlayerEntity.m (working copy)
@@ -924,7 +924,7 @@
maxFlightSpeed = [shipDict floatForKey:@"max_flight_speed" defaultValue:160.0f];
max_flight_roll = [shipDict floatForKey:@"max_flight_roll" defaultValue:2.0f];
max_flight_pitch = [shipDict floatForKey:@"max_flight_pitch" defaultValue:1.0f];
- max_flight_yaw = [shipDict floatForKey:@"max_flight_yaw" defaultValue:max_flight_pitch];// Note by default yaw == pitch
+ max_flight_yaw = [shipDict floatForKey:@"max_flight_yaw" defaultValue:(max_flight_pitch/2.0f)]; // Note by default yaw == pitch/2
// set control factors..
roll_delta = 2.0 * max_flight_roll;
@@ -3452,6 +3452,7 @@
flightRoll = 0.0;
flightPitch = 0.0;
+ flightYaw = 0.0;
flightSpeed = 0.0;
hyperspeed_engaged = NO;
@@ -6377,6 +6378,7 @@
ADD_FLAG_IF_SET(mouse_control_on);
ADD_FLAG_IF_SET(isSpeechOn);
ADD_FLAG_IF_SET(keyboardRollPitchOverride);
+ ADD_FLAG_IF_SET(keyboardYawOverride);
ADD_FLAG_IF_SET(waitingForStickCallback);
flagsString = [flags count] ? [flags componentsJoinedByString:@", "] : @"none";
OOLog(@"dumpState.playerEntity", @"Flags: %@", flagsString);
Index: Core/Entities/PlayerEntityStickMapper.m
===================================================================
--- Core/Entities/PlayerEntityStickMapper.m (revision 1501)
+++ Core/Entities/PlayerEntityStickMapper.m (working copy)
@@ -289,6 +289,11 @@
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
axisfn: AXIS_THRUST
WOOO!!drumz wrote:Wish granted.
I'm using JoyToKey for that ATM... 'cept I'm using the hat for toggling missiles (vert axis) and targets (horiz axis).[/quote]If I have the time (I just finished Spring Break here), I want to look into adding Joystick hihat support for views.
I’d prefer to leave this to someone with a working SDL build, and maybe even a joystick. :-)drumz wrote:Any chance some (important) people could check this out so it can make it's way in?