For the love of god, yaw thrusters please!
Moderators: winston, another_commander
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
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.
I remember playing Elite on the MSX with the kb and joystick, steering went fluidly, i was in sync with my ships location and heading all the time. For a certain turn i knew how long i had to keep the directional button pressed, only slightly correcting now and then. This was most valued during combats ofcourse. With Oolite i seem to never quite get in sync with my ship. It's not because of the keyboard because i'm fine with that, it's the movement speed.
*ouch sorry to bump a 3 months old post*
*edit: spelling*
Last edited by zeep on Mon Dec 03, 2007 6:58 am, edited 1 time in total.
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
- Phrostbyte
- Competent
- Posts: 36
- Joined: Mon Feb 14, 2005 4:40 pm
- Location: Fort Bragg, NC, USA
- Commander McLane
- ---- E L I T E ----
- Posts: 9520
- Joined: Thu Dec 14, 2006 9:08 am
- Location: a Hacker Outpost in a moderately remote area
- Contact:
Re: Yaw mapping to joystick axis
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.
But, I assume this has not been implemented yet?
I have the yaw controls (,< and .> keys) mapped to the yaw axis of my joystick, but they are a bit vicious! I have increased the dead zone on the yaw axis, which has helped a bit, not perfect tho'.
Analogue yaw would be very nice.
Re: Yaw mapping to joystick axis
Wish granted.Gadget wrote:SgtSchultz wrote:Analogue yaw would be very nice.
The following is the output of 'svn diff' against svn current (rev 1501).
Some notes:
After applying this you'll have to go to the joystick config page and remap thrust, as well as yaw.
I've made the max default yaw half of the max default pitch. IMHO, you should have more pitch command than yaw command. This can be overriding in the ship plists (currently I don't think any ships define a max yaw), or you can choose not to apply that portion of my patch (only 2 lines are different)
I've changed some abs() calls to fabs(). Took me forever to figure out why my joystick wasn't working in yaw; this was it.
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
If I have the time (I just finished Spring Break here), I want to look into adding Joystick hihat support for views. Mine is mapped as 2 axes (only returns -1, 0, and 1), and currently the game just supports buttons for changing views.
- Commander Mysenses
- Deadly
- Posts: 214
- Joined: Sat Mar 08, 2008 9:30 am
- Location: Devon, a backward little planet scourged by evil weather
Re: Yaw mapping to joystick axis
WOOO!!drumz wrote:Wish granted.
Will check this out later. Thanks.
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.
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Re: Yaw mapping to joystick axis
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?
E-mail: [email protected]
Got sdl, but I know what you mean about the joystick...
Hmmm, I suspect another_commander doesn't have one either...
Hmmm, I suspect another_commander doesn't have one either...
Hey, free OXPs: farsun v1.05 & tty v0.5! :0)
Ok, I was reviewing the code a bit more, and while that code works, I'm going to change it just a bit. Basically I copied the method of getting the joystick info from the pitch/roll code, which uses getPitchRollAxis, which returns an NSPoint, which is 2 doubles. I used that, so virtualYaw.y was always 0. I noticed that instead I can use the getAxisState function, which just returns a double. This implementation will be a bit nicer. Expect a new version (hopefully soon).
-
- Quite Grand Sub-Admiral
- Posts: 6683
- Joined: Wed Feb 28, 2007 7:54 am
- Commander Mysenses
- Deadly
- Posts: 214
- Joined: Sat Mar 08, 2008 9:30 am
- Location: Devon, a backward little planet scourged by evil weather