Page 5 of 6

Posted: Wed Apr 15, 2015 10:14 pm
by jbansk
Djole88 wrote:QUOTE (Djole88 @ Apr 14 2015, 06:06 PM) In my view by changing the underlying resolution of the JoystickImage or the base sensitivity (which I believe is what its ctor does) you changed how mouse acts. MOUSE alone.
WRONG! & WRONG AGAIN!....either change the value to 2048 and test with a joystick or STFU! Toggle between 512 and 2048 and test if your talent prevents you from detecting the difference.

This has been confirmed over and over by myself, Imago and now Blacksun. If you'd take 10 seconds to test it, you'd realize that you're talking out the side of your ass.

Your R8 BETA has the controller screwed up and you're not even capable of detecting it. 15 seconds into the game and I noticed it right away. You've got the deadzone out of whack and anyone with a joystick will be pissed when they can't track squat because of the screw up you're responsible for.

So test it or STFU. I'm tired of listening to your Bull@#(! reasoning of why it shouldn't work while you refuse to confirm what others bothered to test for themselves. Windows MOUSE acceleration curve affects JOYSTICKS!!...don't believe it?...change your windows accel curve and see. Even Imago's acceleration code affects joysticks! When it was first coded, I discovered that in the absence of a declared registry value for that acceleration option (such as a new installation where the player hasn't yet set the acceleration option in game), that the mouse acceleration was indeed invoked and affecting....yes, you guessed it,....JOYSTICKS!

How can you be so ignorant? Are you just too ashamed to admit that you can't code worth squat? If you're so sure of your ability, why are you stealing Imago's code and then saying that it doesn't do anything? Why are you so set against testing it for yourself? Are you afraid you will realize just how ignorant you really are? Do you think after 15 years of playing this game, using the same joystick, that I am making this up?


Cyd,

I apologize for derailing this thread however, I wanted you to have a working copy of the game. When you use a joystick, change the in-game settings to use "Quadratic Control Response" instead of "Linear" and also you want to change the in-game deadzone to "small". Try the training mission again and you'll be more capable of hitting targets and noticing the bug that I pointed out.

Posted: Wed Apr 15, 2015 10:23 pm
by minigun
I think i can be helpful. Funny i'm a keyboard mouse player, everything you don't have. I can at least
let you know what to assign (like dropping probes/proximity mines) or the important ones. communication
is key in allegiance, with no keyboard, i would think you would need mumble or teamspeak. allegiance uses mumble
online. Also i know enough about commanding to help you in that area. commanding without mouse sounds challenging.
I might be putting the horse in front of the cart here, but i'll stop by and help anyway i can.

Posted: Thu Apr 16, 2015 12:21 am
by Djole88

Code: Select all

class JoystickImageImpl : public JoystickImage {
private:
    TArray<TRef<ModifiableNumber> , 20> m_ppnumber; //imago increased 8/12/09, again 7/10
    TArray<TRef<ModifiableBoolean>, 20> m_ppboolButton; //imago increased 8/12/09, again 7/10
    bool                               m_bJoystickEnabled;
    bool                               m_bButtonsEnabled;
    bool                               m_bJustEnabled;
    float                              m_sensitivity;

public:
    JoystickImageImpl(float sensitivity) :
        m_sensitivity(sensitivity),
        m_bJoystickEnabled(false),
        m_bButtonsEnabled(false),
        m_bJustEnabled(false)
    {

        //Imago 7/10
        for (int index = 0; index < m_ppboolButton.GetCount(); index++) {
            m_ppnumber[index] = new ModifiableNumber(false);
        }

        for (int index = 0; index < m_ppboolButton.GetCount(); index++) {
            m_ppboolButton[index] = new ModifiableBoolean(false);
        }
    }

    //////////////////////////////////////////////////////////////////////////////
    //
    // JoystickImage members
    //
    //////////////////////////////////////////////////////////////////////////////

    void SetEnabled(bool bJoystickEnabled, bool bButtonsEnabled)
    {
        if (m_bJoystickEnabled != bJoystickEnabled) {
            m_bJoystickEnabled = bJoystickEnabled;

            if (m_bJoystickEnabled) {
                m_bJustEnabled = true;
            } else {
                m_ppnumber[0]->SetValue(0);
                m_ppnumber[1]->SetValue(0);
                m_ppnumber[2]->SetValue(0);
            }
        }

        if (m_bButtonsEnabled != bButtonsEnabled) {
            m_bButtonsEnabled = bButtonsEnabled;

            if (!m_bButtonsEnabled) {
                for (int index = 0; index < m_ppboolButton.GetCount(); index++) {
                    m_ppboolButton[index]->SetValue(false);
                }
            }
        }
    }

    void SetSensitivity(float sensitivity)
    {
        m_sensitivity = sensitivity;
    }

    bool GetJoystickEnabled()
    {
        return m_bJoystickEnabled;
    }

    bool GetButtonsEnabled()
    {
        return m_bButtonsEnabled;
    }

    //////////////////////////////////////////////////////////////////////////////
    //
    // JoystickInputStream members
    //
    //////////////////////////////////////////////////////////////////////////////

    bool HasForceFeedback()
    {
        return false;
    }
    //Imago 7/10 #187
    void SetRanges() {

    }
    void CreateEffects()
    {
    }

    void PlayFFEffect(short effectID, LONG lDirection)
    {
    }

    ZString GetShortDescription(int index)
    {
        return "Mouse";
    }

    ZString GetDescription()
    {
        return "Mouse";
    }

    ZString GetValueDescription(int id)
    {
        switch(id) {
            case 0: return "Left";
            case 1: return "Right";
            case 2: return "Middle";
            case 3: return "XButton1";
            case 4: return "XButton2";
            case 5: return "XButton3";
            case 6: return "XButton4";
            case 7: return "XButton5";
            case 8: return "Wheel Up";
            case 9: return "Wheel Down";
        }

        return ZString();
    }

    //////////////////////////////////////////////////////////////////////////////
    //
    // InputStream members
    //
    //////////////////////////////////////////////////////////////////////////////

    int GetValueCount()
    {
        return 3; //Imago 8/13/09 was 2
    }

    int GetButtonCount()
    {
        return 10; //Imago 8/13/09 was 3
    }

    Boolean* IsDown(int id)
    {
        return m_ppboolButton[id];
    }

    Number* GetValue(int id)
    {
        return m_ppnumber[id];
    }

    ButtonEvent::Source* GetEventSource()
    {
        ZUnimplemented();
        return NULL;
    }

    //////////////////////////////////////////////////////////////////////////////
    //
    // IMouseInput members
    //
    //////////////////////////////////////////////////////////////////////////////

    MouseResult HitTest(IInputProvider* pprovider, const Point& point, bool bCaptured)
    { 
        return (m_bJoystickEnabled || m_bButtonsEnabled) ? MouseResultHit() : MouseResult(); 
    }

    void MouseMove(IInputProvider* pprovider, const Point& pointMouse, bool bCaptured, bool bInside)
    {
        if (m_bJoystickEnabled) {
            if (m_bJustEnabled) {
                m_bJustEnabled = false;
            } else {
                //<Djole date="2014-12-14">
                //Stolen from Imago
                //float dx = (pointMouse.X() - 320) * m_sensitivity;
                //float dy = (pointMouse.Y() - 240) * m_sensitivity;
                float dx = (pointMouse.X() - 640) * m_sensitivity;
                float dy = (pointMouse.Y() - 480) * m_sensitivity;
                //</Djole>

                Point 
                    point(
                        m_ppnumber[0]->GetValue() - dx, 
                        m_ppnumber[1]->GetValue() - dy
                    );

                float length = point.Length();

                if (length > 1) {
                    point = point / length;
                }
                
                m_ppnumber[0]->SetValue(point.X());
                m_ppnumber[1]->SetValue(point.Y());
            }
            //<Djole date="2014-12-14">
            //Stolen from Imago
            //pprovider->SetCursorPos(Point(320, 240));
            pprovider->SetCursorPos(Point(640, 480));
            //</Djole>

        }
    }

    //NYI WheelMove Imago m_ppnumber[2]

    MouseResult Button(IInputProvider* pprovider, const Point& point, int button, bool bCaptured, bool bInside, bool bDown)
    {
        if (m_bButtonsEnabled) {
            if (button <= 20) { //was 3 Imago 8/13/09, 7/10
                m_ppboolButton[button]->SetValue(bDown);
            }
        }

        return MouseResult();
    }
};

TRef<JoystickImage> CreateJoystickImage(float sensitivity)
{
    return new JoystickImageImpl(sensitivity);
}

Code: Select all

bool SenseJoystick(JoystickResults* js, bool bInternalCamera, bool bReadKeyboard, bool &bHandleThrottle) //Spunky #76
    {
        bool bThrottleChange = false;

        //
        // Read the joystick
        //

        if (m_pjoystickImage->GetJoystickEnabled()) {
            js->controls.jsValues[c_axisYaw  ] = m_pjoystickImage->GetValue(0)->GetValue();
            js->controls.jsValues[c_axisPitch] = m_pjoystickImage->GetValue(1)->GetValue();
            js->controls.jsValues[c_axisRoll ] = 0;
        } else {

            //<Djole date="2014-09-22">
            
            /*if (m_ptrekInput->IsTrekKeyDown(TK_RollModifier, bReadKeyboard)) {
                js->controls.jsValues[c_axisYaw ] = 0;
                js->controls.jsValues[c_axisRoll] = MapJoystick(m_ptrekInput->GetAxis(0));
            } else {
                js->controls.jsValues[c_axisYaw ] = MapJoystick(m_ptrekInput->GetAxis(0));
                js->controls.jsValues[c_axisRoll] = MapJoystick(m_ptrekInput->GetAxis(2));
            }

            js->controls.jsValues[c_axisPitch   ] =  MapJoystick(m_ptrekInput->GetAxis(1));*/

            D3DXVECTOR2 dzone;
            dzone.x = m_ptrekInput->GetAxis(0);
            dzone.y = m_ptrekInput->GetAxis(1);
            float dlen = D3DXVec2Length(&dzone);
            if(dlen<g_fJoystickDeadZone){
                dzone.x=0;
                dzone.y=0;
            } else{
                D3DXVECTOR2 norm;
                memset(&norm,0,sizeof(norm));
                D3DXVec2Normalize(&norm,&dzone);                
                dzone = norm * ((dlen - g_fJoystickDeadZone) / (1.0f-g_fJoystickDeadZone));                
            }

            if(!m_bLinearControls){
                dzone.x *= fabsf(dzone.x);
                dzone.y *= fabsf(dzone.y);
            }
            if(m_ptrekInput->IsTrekKeyDown(TK_RollModifier, bReadKeyboard)){                
                js->controls.jsValues[c_axisYaw]=0;
                js->controls.jsValues[c_axisRoll] = dzone.x;
            } else{
                js->controls.jsValues[c_axisRoll] = MapJoystick(m_ptrekInput->GetAxis(2));
                js->controls.jsValues[c_axisYaw] = dzone.x;
            }
            
            js->controls.jsValues[c_axisPitch] = dzone.y;
            //</Djole>
        }

        js->controls.jsValues[c_axisThrottle] = -m_ptrekInput->GetAxis(3);
        js->hat                               =  m_ptrekInput->GetAxis(4) * pi;

        //
        // Flip the y axis if requested
        //

        if (m_bFlipY) {
            js->controls.jsValues[c_axisPitch] = -js->controls.jsValues[c_axisPitch];
        }

        //<Djole date="2014-09-22>
        if(m_bFlipX){
            js->controls.jsValues[c_axisYaw] = -js->controls.jsValues[c_axisYaw];
        }
        if(m_bFlipZ){
            js->controls.jsValues[c_axisRoll] = -js->controls.jsValues[c_axisRoll];
        }
        //</Djole>

        //
        // If the throttle system needs to be initialized, we do that. Otherwise, if the joystick
        // throttle has changed significantly, then we start using the joystick throttle.
        //

        if (trekClient.bInitTrekThrottle)
        {
            // see Training::StartMission for initialization of trekClient.trekThrottle
            // it is 1.0f for on-line play, and -1.0f for off-line.
            trekClient.joyThrottle = false;
            trekClient.fOldJoyThrottle = js->controls.jsValues[c_axisThrottle];
            trekClient.bInitTrekThrottle = false;
        }
        else if (fabs(js->controls.jsValues[c_axisThrottle] - trekClient.fOldJoyThrottle) > g_fJoystickDeadZone)
        {
            bThrottleChange = true;
            trekClient.joyThrottle = true;
        }

        //
        // Read buttons and keyboard
        //

        bool newButton1 = m_ptrekInput->IsTrekKeyDown(TK_FireWeapon , bReadKeyboard);
        bool newButton2 = m_ptrekInput->IsTrekKeyDown(TK_FireMissile, bReadKeyboard);
        bool newButton3 = m_ptrekInput->IsTrekKeyDown(TK_FireBooster, bReadKeyboard);
        //bool newButton4 = m_ptrekInput->GetButton(3); // !!! was next weapon
        //bool newButton5 = m_ptrekInput->GetButton(4); // !!! was vector lock
        bool newButton6 = m_ptrekInput->IsTrekKeyDown(TK_MatchSpeed , bReadKeyboard);

        if (bInternalCamera)
        {
            // roll left/right

            if (m_ptrekInput->IsTrekKeyDown(TK_RollRight, bReadKeyboard)) {
                js->controls.jsValues[c_axisRoll] = -1.0f;
            } else if (m_ptrekInput->IsTrekKeyDown(TK_RollLeft, bReadKeyboard)) {
                js->controls.jsValues[c_axisRoll] = 1.0f;
            }

            // yaw left/right

            if (m_ptrekInput->IsTrekKeyDown(TK_RollModifier, bReadKeyboard)) {
                if (m_ptrekInput->IsTrekKeyDown(TK_YawRight, bReadKeyboard)) {
                    js->controls.jsValues[c_axisRoll] = -1.0f;
                } else if (m_ptrekInput->IsTrekKeyDown(TK_YawLeft, bReadKeyboard)) {
                    js->controls.jsValues[c_axisRoll] = 1.0f;
                }
            } else {
                if (m_ptrekInput->IsTrekKeyDown(TK_YawRight, bReadKeyboard)) {
                    js->controls.jsValues[c_axisYaw] = -1.0f;
                } else if (m_ptrekInput->IsTrekKeyDown(TK_YawLeft, bReadKeyboard)) {
                    js->controls.jsValues[c_axisYaw] = 1.0f;
                }
            }

            // up/down == pitch

            if (m_ptrekInput->IsTrekKeyDown(TK_PitchDown, bReadKeyboard)) {
                js->controls.jsValues[c_axisPitch] = -1.0f;
            } else if (m_ptrekInput->IsTrekKeyDown(TK_PitchUp, bReadKeyboard)) {
                js->controls.jsValues[c_axisPitch] = 1.0f;
            }

            if (bHandleThrottle && m_ptrekInput->IsTrekKeyDown(TK_ThrottleUp, bReadKeyboard)) //Spunky #76
            {
                trekClient.trekThrottle =
                      (trekClient.trekThrottle < 0.8f)
                    ? (trekClient.trekThrottle + 0.2f)
                    : 1.0f;
                trekClient.joyThrottle = false;
                bThrottleChange = true;
                bHandleThrottle=false;
            }
            else if (bHandleThrottle && m_ptrekInput->IsTrekKeyDown(TK_ThrottleDown, bReadKeyboard)) //Spunky #76
            {
                trekClient.trekThrottle =
                      (trekClient.trekThrottle > -0.8f)
                    ? (trekClient.trekThrottle - 0.2f)
                    : -1.0f;
                trekClient.joyThrottle = false;
                bThrottleChange = true;
                bHandleThrottle=false;
            }
        }

        if (m_ptrekInput->IsTrekKeyDown(TK_ThrottleZero, bReadKeyboard))
        {
            trekClient.trekThrottle = -1.0f;
            trekClient.joyThrottle = false;
            bThrottleChange = true;
        }
        else if (m_ptrekInput->IsTrekKeyDown(TK_Throttle33, bReadKeyboard))
        {
            trekClient.trekThrottle = -0.3f;
            trekClient.joyThrottle = false;
            bThrottleChange = true;
        }
        else if (m_ptrekInput->IsTrekKeyDown(TK_Throttle66, bReadKeyboard))
        {
            trekClient.trekThrottle = 0.3f;
            trekClient.joyThrottle = false;
            bThrottleChange = true;
        }
        else if (m_ptrekInput->IsTrekKeyDown(TK_ThrottleFull, bReadKeyboard))
        {
            trekClient.trekThrottle = 1.0f;
            trekClient.joyThrottle = false;
            bThrottleChange = true;
        }

        //
        // Handle match speed
        //

        if (newButton6)
        {
            ImodelIGC* pmodel = GetCurrentTarget();
            if (pmodel)
            {
                trekClient.trekThrottle = GetThrottle(pmodel);
                trekClient.joyThrottle = false;
                bThrottleChange = true;
            }
        }

        if (trekClient.joyThrottle)
        {
            trekClient.fOldJoyThrottle = js->controls.jsValues[c_axisThrottle];
        }
        else
        {
            js->controls.jsValues[c_axisThrottle] = trekClient.trekThrottle;
        }

        // Process joystick buttons, keeping track of whether the button has changed
        // since the last poll.

        static bool oldButton1 = false;
        static bool oldButton2 = false;
        static bool oldButton3 = false;
        //static bool oldButton4 = false;
        //static bool oldButton5 = false;
        static bool oldButton6 = false;


        js->button1 = (newButton1 ? buttonDown : 0x00) | (newButton1 != oldButton1 ? buttonChanged : 0x00);
        js->button2 = (newButton2 ? buttonDown : 0x00) | (newButton2 != oldButton2 ? buttonChanged : 0x00);
        js->button3 = (newButton3 ? buttonDown : 0x00) | (newButton3 != oldButton3 ? buttonChanged : 0x00);
        //!!!js->button4 = (newButton4 ? buttonDown : 0x00) | (newButton4 != oldButton4 ? buttonChanged : 0x00);
        //!!!js->button5 = (newButton5 ? buttonDown : 0x00) | (newButton5 != oldButton5 ? buttonChanged : 0x00);
        js->button4 = 0;
        js->button5 = 0;
        js->button6 = (newButton6 ? buttonDown : 0x00) | (newButton6 != oldButton6 ? buttonChanged : 0x00);

        oldButton1 = newButton1;
        oldButton2 = newButton2;
        oldButton3 = newButton3;
        //oldButton4 = newButton4;
        //oldButton5 = newButton5;
        oldButton6 = newButton6;

        return bThrottleChange;
    }

Posted: Thu Apr 16, 2015 12:44 am
by jbansk
What's your point?...you can copy / paste code to a forum and still can't test it for yourself? Imago's GitHub Read the fine print... "decrease mouse/joystick sensitivity...

Test it or STFU



Posted: Thu Apr 16, 2015 3:31 pm
by Cyd
I was trying to pay specific attention to the how the joystick felt, I did notice the large deadzone, but never poked around for the settings. Minigun (if he stops by) and I will play with those setting this evening.

Also remember that these are old arcade cabinets, while they were the most advanced pieces of equipment designed at that point in time, that point was 20 years ago...

The cockpits use optical encoders for all 5 axis, the resolution of the encoders is 512 clicks/revolution, thus the joystick (and peddles, and throttle) have about 180 "clicks" of resolution on each axis.

Who works on the video/rendering sub systems? I have several questions.

Posted: Thu Apr 16, 2015 3:50 pm
by jbansk
Cyd wrote:QUOTE (Cyd @ Apr 16 2015, 12:31 PM) Who works on the video/rendering sub systems? I have several questions.
Imago is who you want to talk to. He knows this code like nobody else.

Derail time: As it turns out, Djole disclosed to me last night in game that he was incapable of testing the joystick sensitivity because his joystick is software controlled. His only argument is that the code doesn't make sense to him so he cannot accept the actual findings of those who DID test and confirm the sensitivity bug.

Now back to your project.... Imago forked this game awhile back and did extensive development on it which took it far beyond where it is now. The copy you have installed is bug riddled and frankly speaking, trash. Ask Imago to give you a working copy of his version. He has it on Github where you can pull it yourself. If you wish, I can give you a copy of it ready to install. I really suggest you talk to him though, he's very helpful and codes for pizza.

Posted: Thu Apr 16, 2015 4:09 pm
by minigun
i think imago still lives in minneapolis. i'll be racing down 35w tonight in my bucket of bolts.
try and get there by 8pm.

Posted: Thu Apr 16, 2015 4:51 pm
by Cyd
If he is in Minneapolis I will buy all the pizzas! (and beverages of choice)

Drive safe, you're no good to me if I have to hose you out of a cockpit ;)

Posted: Thu Apr 16, 2015 5:26 pm
by jbansk
Cyd wrote:QUOTE (Cyd @ Apr 16 2015, 01:51 PM) If he is in Minneapolis I will buy all the pizzas! (and beverages of choice)
I should have added that you must include a 2 liter bottle of Barq's root beer with any pizza order. Given the amount of coding he does, he should weigh about 450lbs. :)

Posted: Thu Jul 09, 2015 8:45 pm
by Imago
just saw this thread searching for "mumble" - necroposting cause this idea is farking cool!