Page 4 of 6

Posted: Fri Aug 31, 2007 5:25 am
by Commander McLane
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.

Posted: Fri Aug 31, 2007 7:06 am
by TGHC
I paint go faster stripes on mine!

Posted: Sat Dec 01, 2007 5:46 pm
by zeep
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.
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.

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*

Posted: Mon Dec 03, 2007 6:00 am
by Commander McLane
zeep wrote:
*ouch sorry to bump a 3 months old post*
Never mind! There have been older discussions re-animated here before, and...

It lives! :shock:

Posted: Mon Dec 03, 2007 4:56 pm
by nijineko
you know, it would be nice to have rough and fine movement controls. perhaps 'fnct'+(movement key) for large scale rough movement, and the regular keys for fine control movement. =D

Posted: Thu Jan 24, 2008 12:42 am
by Phrostbyte
Yay, another suggestion I requested made it into the trunk! Gosh, I've been away too long (or, for you readers, perhaps not long enough). :wink:

Posted: Thu Jan 24, 2008 9:15 am
by Commander McLane
Yes, it has made it into the trunk, but there is a but!

For the time being this is an experimental addition. Our current Supreme Grand Admiral hasn't yet decided whether it will stay in the trunk for the MNSR*.

_______
*the Mythical Next Stable Release

Re: Yaw mapping to joystick axis

Posted: Fri Mar 07, 2008 12:31 pm
by Gadget
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.
Sorry to re-animate a zombie thread.
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

Posted: Mon Mar 24, 2008 6:30 am
by drumz
Gadget wrote:
SgtSchultz wrote:
Analogue yaw would be very nice. :)
Wish granted.

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

Any chance some (important) people could check this out so it can make it's way in?

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.

Re: Yaw mapping to joystick axis

Posted: Mon Mar 24, 2008 8:21 am
by Commander Mysenses
drumz wrote:
Wish granted.
WOOO!!
Will check this out later. Thanks.
If I have the time (I just finished Spring Break here), I want to look into adding Joystick hihat support for views.
I'm using JoyToKey for that ATM... 'cept I'm using the hat for toggling missiles (vert axis) and targets (horiz axis).[/quote]

Re: Yaw mapping to joystick axis

Posted: Mon Mar 24, 2008 12:21 pm
by JensAyton
drumz wrote:
Any chance some (important) people could check this out so it can make it's way in?
I’d prefer to leave this to someone with a working SDL build, and maybe even a joystick. :-)

Posted: Mon Mar 24, 2008 12:59 pm
by Kaks
Got sdl, but I know what you mean about the joystick... :)
Hmmm, I suspect another_commander doesn't have one either...

Posted: Mon Mar 24, 2008 2:12 pm
by drumz
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).

Posted: Mon Mar 24, 2008 2:57 pm
by another_commander
I cannot check this code myself either, as I do not use joystick, but if I prepare a test build, based on 1.70, maybe someone with a joystick could give it a go? If all is reported good, then we could go on and add it, I guess.

Posted: Mon Mar 24, 2008 4:28 pm
by Commander Mysenses
ME-ME-ME-ME-ME-ME-ME!! :D

Currently rollin' on v.1.70 and v.1.71(build 1499) under Win XP