Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1304


Ignore:
Timestamp:
May 15, 2008, 10:35:14 PM (16 years ago)
Author:
rgrieder
Message:
  • updated OIS to the recent most v1.2 CVS checkout
Location:
code/branches/input/src/ois
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • code/branches/input/src/ois/OISJoyStick.cpp

    r1219 r1304  
    3636
    3737//----------------------------------------------------------------------------//
    38 int JoyStick::getNumberOfComponents(ComponentType cType)
     38int JoyStick::getNumberOfComponents(ComponentType cType) const
    3939{
    4040        switch( cType )
     
    5656
    5757//----------------------------------------------------------------------------//
    58 float JoyStick::getVector3Sensitivity()
     58float JoyStick::getVector3Sensitivity() const
    5959{
    6060        return mVector3Sensitivity;
     
    6868
    6969//----------------------------------------------------------------------------//
    70 JoyStickListener* JoyStick::getEventCallback()
     70JoyStickListener* JoyStick::getEventCallback() const
    7171{
    7272        return mListener;
  • code/branches/input/src/ois/OISJoyStick.h

    r1219 r1304  
    168168                        The ComponentType you are interested in knowing about
    169169                */
    170                 int getNumberOfComponents(ComponentType cType);
     170                int getNumberOfComponents(ComponentType cType) const;
    171171
    172172                /**
     
    184184                        Returns the sensitivity cutoff for Vector3 Component
    185185                */
    186                 float getVector3Sensitivity();
     186                float getVector3Sensitivity() const;
    187187
    188188                /**
     
    196196
    197197                /** @remarks Returns currently set callback.. or null */
    198                 JoyStickListener* getEventCallback();
     198                JoyStickListener* getEventCallback() const;
    199199
    200200                /** @remarks Returns the state of the joystick - is valid for both buffered and non buffered mode */
  • code/branches/input/src/ois/OISKeyboard.cpp

    r1219 r1304  
    3333
    3434//----------------------------------------------------------------------//
    35 bool Keyboard::isModifierDown( Modifier mod )
     35bool Keyboard::isModifierDown( Modifier mod ) const
    3636{
    3737#if defined(OIS_MSVC_COMPILER)
  • code/branches/input/src/ois/OISKeyboard.h

    r1219 r1304  
    220220                        A KeyCode to check
    221221                */
    222                 virtual bool isKeyDown( KeyCode key ) = 0;
     222                virtual bool isKeyDown( KeyCode key ) const = 0;
    223223
    224224                /**
     
    235235                        Returns currently set callback.. or 0
    236236                */
    237                 KeyListener* getEventCallback() {return mListener;}
     237                KeyListener* getEventCallback() const {return mListener;}
    238238
    239239                //! TextTranslation Mode
     
    260260                        Returns current translation mode
    261261                */
    262                 TextTranslationMode getTextTranslation(){return mTextMode;}
     262                TextTranslationMode getTextTranslation() const {return mTextMode;}
    263263               
    264264                /**
     
    286286                        Check modifier status
    287287                */
    288                 bool isModifierDown( Modifier mod );
     288                bool isModifierDown( Modifier mod ) const;
    289289
    290290                /**
     
    293293                        (in the form of 1 is down and 0 is up)
    294294                */
    295                 virtual void copyKeyStates( char keys[256] ) = 0;
     295                virtual void copyKeyStates( char keys[256] ) const = 0;
    296296               
    297297        protected:
  • code/branches/input/src/ois/OISMouse.h

    r1219 r1304  
    120120
    121121                /** @remarks Returns currently set callback.. or 0 */
    122                 MouseListener* getEventCallback() {return mListener;}
     122                MouseListener* getEventCallback() const {return mListener;}
    123123
    124124                /** @remarks Returns the state of the mouse - is valid for both buffered and non buffered mode */
  • code/branches/input/src/ois/OISObject.h

    r1219 r1304  
    4545
    4646                /** @remarks Returns this input object's creator */
    47                 InputManager* getCreator() { return mCreator; }
     47                InputManager* getCreator() const { return mCreator; }
    4848
    4949                /** @remarks Sets buffered mode */
  • code/branches/input/src/ois/linux/LinuxKeyboard.cpp

    r1219 r1304  
    290290
    291291//-------------------------------------------------------------------//
    292 bool LinuxKeyboard::isKeyDown( KeyCode key )
     292bool LinuxKeyboard::isKeyDown( KeyCode key ) const
    293293{
    294294        return (KeyBuffer[key]);
     
    449449
    450450//-------------------------------------------------------------------//
    451 void LinuxKeyboard::copyKeyStates( char keys[256] )
     451void LinuxKeyboard::copyKeyStates( char keys[256] ) const
    452452{
    453453        memcpy( keys, KeyBuffer, 256 );
  • code/branches/input/src/ois/linux/LinuxKeyboard.h

    r1219 r1304  
    3838
    3939                /** @copydoc Keyboard::isKeyDown */
    40                 virtual bool isKeyDown( KeyCode key );
     40                virtual bool isKeyDown( KeyCode key ) const;
    4141
    4242                /** @copydoc Keyboard::getAsString */
     
    4444
    4545                /** @copydoc Keyboard::copyKeyStates */
    46                 virtual void copyKeyStates( char keys[256] );
     46                virtual void copyKeyStates( char keys[256] ) const;
    4747
    4848                /** @copydoc Object::setBuffered */
  • code/branches/input/src/ois/mac/MacKeyboard.cpp

    r1219 r1304  
    130130
    131131//-------------------------------------------------------------------//
    132 bool MacKeyboard::isKeyDown( KeyCode key )
     132bool MacKeyboard::isKeyDown( KeyCode key ) const
    133133{
    134134        return (bool)KeyBuffer[key];
     
    321321
    322322//-------------------------------------------------------------------//
    323 void MacKeyboard::copyKeyStates( char keys[256] )
     323void MacKeyboard::copyKeyStates( char keys[256] ) const
    324324{
    325325        memcpy( keys, KeyBuffer, 256 );
  • code/branches/input/src/ois/mac/MacKeyboard.h

    r1219 r1304  
    4343       
    4444        // unbuffered keydown check
    45         virtual bool isKeyDown( KeyCode key );
     45        virtual bool isKeyDown( KeyCode key ) const;
    4646       
    4747        // This will send listener events if buffered is on.
     
    5151       
    5252        // Copies the current key buffer
    53         virtual void copyKeyStates( char keys[256] );
     53        virtual void copyKeyStates( char keys[256] ) const;
    5454       
    5555        // Returns a description of the given key
  • code/branches/input/src/ois/win32/Win32JoyStick.cpp

    r1219 r1304  
    149149        diptr.diph.dwHow        = DIPH_BYID;
    150150        diptr.diph.dwObj        = lpddoi->dwType;
    151         //Add the high bit in so that an axis value of zero does not mean a null userdata
    152         diptr.uData             = 0x80000000 | _this->_AxisNumber;
     151        //Add a magic number to recognise we set seomthing
     152        diptr.uData             = 0x13130000 | _this->_AxisNumber;
    153153
    154154        //Check if axis is slider, if so, do not treat as regular axis
     
    166166
    167167        //Increase for next time through
    168         _this->_AxisNumber += 1;
     168        if(GUID_Slider != lpddoi->guidType)
     169                _this->_AxisNumber += 1;
    169170
    170171        //Set range
     
    238239        for(unsigned int i = 0; i < entries; ++i)
    239240        {
    240                 //First check to see if event entry is a Axis we enumerated earlier
    241                 if( diBuff[i].uAppData != 0xFFFFFFFF && diBuff[i].uAppData > 0 )
     241                //This may seem outof order, but is in order of the way these variables
     242                //are declared in the JoyStick State 2 structure.
     243                switch(diBuff[i].dwOfs)
    242244                {
    243                         int axis = (int)(0x7FFFFFFF & diBuff[i].uAppData); //Mask out the high bit
    244                         assert( axis >= 0 && axis < (int)mState.mAxes.size() && "Axis out of range!");
    245                         mState.mAxes[axis].abs = diBuff[i].dwData;
    246                         axisMoved[axis] = true;
    247                 }
    248                 else
    249                 {
    250                         //This may seem outof order, but is in order of the way these variables
    251                         //are declared in the JoyStick State 2 structure.
    252                         switch(diBuff[i].dwOfs)
     245                //------ slider -//
     246                case DIJOFS_SLIDER0(0):
     247                        sliderMoved[0] = true;
     248                        mState.mSliders[0].abX = diBuff[i].dwData;
     249                        break;
     250                case DIJOFS_SLIDER0(1):
     251                        sliderMoved[0] = true;
     252                        mState.mSliders[0].abY = diBuff[i].dwData;
     253                        break;
     254                //----- Max 4 POVs Next ---------------//
     255                case DIJOFS_POV(0):
     256                        if(!_changePOV(0,diBuff[i]))
     257                                return;
     258                        break;
     259                case DIJOFS_POV(1):
     260                        if(!_changePOV(1,diBuff[i]))
     261                                return;
     262                        break;
     263                case DIJOFS_POV(2):
     264                        if(!_changePOV(2,diBuff[i]))
     265                                return;
     266                        break;
     267                case DIJOFS_POV(3):
     268                        if(!_changePOV(3,diBuff[i]))
     269                                return;
     270                        break;
     271                case DIJOFS_SLIDER1(0):
     272                        sliderMoved[1] = true;
     273                        mState.mSliders[1].abX = diBuff[i].dwData;
     274                        break;
     275                case DIJOFS_SLIDER1(1):
     276                        sliderMoved[1] = true;
     277                        mState.mSliders[1].abY = diBuff[i].dwData;
     278                        break;
     279                case DIJOFS_SLIDER2(0):
     280                        sliderMoved[2] = true;
     281                        mState.mSliders[2].abX = diBuff[i].dwData;
     282                        break;
     283                case DIJOFS_SLIDER2(1):
     284                        sliderMoved[2] = true;
     285                        mState.mSliders[2].abY = diBuff[i].dwData;
     286                        break;
     287                case DIJOFS_SLIDER3(0):
     288                        sliderMoved[3] = true;
     289                        mState.mSliders[3].abX = diBuff[i].dwData;
     290                        break;
     291                case DIJOFS_SLIDER3(1):
     292                        sliderMoved[3] = true;
     293                        mState.mSliders[3].abY = diBuff[i].dwData;
     294                        break;
     295                //-----------------------------------------//
     296                default:
     297                        //Handle Button Events Easily using the DX Offset Macros
     298                        if( diBuff[i].dwOfs >= DIJOFS_BUTTON(0) && diBuff[i].dwOfs < DIJOFS_BUTTON(128) )
    253299                        {
    254                         //------ slider -//
    255                         case DIJOFS_SLIDER0(0):
    256                                 sliderMoved[0] = true;
    257                                 mState.mSliders[0].abX = diBuff[i].dwData;
    258                                 break;
    259                         case DIJOFS_SLIDER0(1):
    260                                 sliderMoved[0] = true;
    261                                 mState.mSliders[0].abY = diBuff[i].dwData;
    262                                 break;
    263                         //----- Max 4 POVs Next ---------------//
    264                         case DIJOFS_POV(0):
    265                                 if(!_changePOV(0,diBuff[i]))
     300                                if(!_doButtonClick((diBuff[i].dwOfs - DIJOFS_BUTTON(0)), diBuff[i]))
    266301                                        return;
    267                                 break;
    268                         case DIJOFS_POV(1):
    269                                 if(!_changePOV(1,diBuff[i]))
    270                                         return;
    271                                 break;
    272                         case DIJOFS_POV(2):
    273                                 if(!_changePOV(2,diBuff[i]))
    274                                         return;
    275                                 break;
    276                         case DIJOFS_POV(3):
    277                                 if(!_changePOV(3,diBuff[i]))
    278                                         return;
    279                                 break;
    280                         case DIJOFS_SLIDER1(0):
    281                                 sliderMoved[1] = true;
    282                                 mState.mSliders[1].abX = diBuff[i].dwData;
    283                                 break;
    284                         case DIJOFS_SLIDER1(1):
    285                                 sliderMoved[1] = true;
    286                                 mState.mSliders[1].abY = diBuff[i].dwData;
    287                                 break;
    288                         case DIJOFS_SLIDER2(0):
    289                                 sliderMoved[2] = true;
    290                                 mState.mSliders[2].abX = diBuff[i].dwData;
    291                                 break;
    292                         case DIJOFS_SLIDER2(1):
    293                                 sliderMoved[2] = true;
    294                                 mState.mSliders[2].abY = diBuff[i].dwData;
    295                                 break;
    296                         case DIJOFS_SLIDER3(0):
    297                                 sliderMoved[3] = true;
    298                                 mState.mSliders[3].abX = diBuff[i].dwData;
    299                                 break;
    300                         case DIJOFS_SLIDER3(1):
    301                                 sliderMoved[3] = true;
    302                                 mState.mSliders[3].abY = diBuff[i].dwData;
    303                                 break;
    304                         //-----------------------------------------//
    305                         default:
    306                                 //Handle Button Events Easily using the DX Offset Macros
    307                                 if( diBuff[i].dwOfs >= DIJOFS_BUTTON(0) && diBuff[i].dwOfs < DIJOFS_BUTTON(128) )
     302                        }
     303                        else if((short)(diBuff[i].uAppData >> 16) == 0x1313)
     304                        {       //If it was nothing else, might be axis enumerated earlier (determined by magic number)
     305                                int axis = (int)(0x0000FFFF & diBuff[i].uAppData); //Mask out the high bit
     306                                assert( axis >= 0 && axis < (int)mState.mAxes.size() && "Axis out of range!");
     307
     308                                if(axis >= 0 && axis < (int)mState.mAxes.size())
    308309                                {
    309                                         if(!_doButtonClick((diBuff[i].dwOfs - DIJOFS_BUTTON(0)), diBuff[i]))
    310                                                 return;
     310                                        mState.mAxes[axis].abs = diBuff[i].dwData;
     311                                        axisMoved[axis] = true;
    311312                                }
    312                                 break;
    313                         } //end case
    314                 } //End else
     313                        }
     314
     315                        break;
     316                } //end case
    315317        } //end for
    316318
  • code/branches/input/src/ois/win32/Win32KeyBoard.cpp

    r1219 r1304  
    105105        DWORD entries = KEYBOARD_DX_BUFFERSIZE;
    106106        HRESULT hr;
     107        //Only one keyboard allowed per app, so static is ok
     108        static bool verifyAfterAltTab = false;
    107109
    108110        hr = mKeyboard->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 );
     
    110112        {
    111113                hr = mKeyboard->Acquire();
     114                if (hr == E_ACCESSDENIED)
     115                        verifyAfterAltTab = true;
     116
    112117                while( hr == DIERR_INPUTLOST )
    113118                        hr = mKeyboard->Acquire();
     119
    114120                return;
    115121        }
     
    121127        for(unsigned int i = 0; i < entries; ++i )
    122128        {
    123                 //If the mListener returns false, that means that we are probably deleted...
     129                //If the listener returns false, that means that we are probably deleted...
    124130                //send no more events and just leave as the this pointer is invalid now...
    125131                bool ret = true;
     
    159165                if(ret == false)
    160166                        break;
     167        }
     168
     169        // If a lost device/access denied was detected, recover gracefully with new events
     170        if(verifyAfterAltTab)
     171        {
     172                bool ret = true;
     173               
     174                //Copy old buffer to temp location to compare against
     175                unsigned char keyBufferCopy[256];
     176                memcpy(keyBufferCopy, KeyBuffer, 256);
     177
     178                //Update new state
     179                _read();
     180
     181                for (unsigned i = 0; i < 256; i++)
     182                {
     183                        if (keyBufferCopy[i] != KeyBuffer[i])
     184                        {
     185                                if (mListener)
     186                                {
     187                                        if (KeyBuffer[i])
     188                                                ret = mListener->keyPressed( KeyEvent( this, (KeyCode)i, _translateText((KeyCode)i) ) );
     189                                        else
     190                                                ret = mListener->keyReleased( KeyEvent( this, (KeyCode)i, 0 ) );
     191                                }
     192                        }
     193
     194                        //If user returned false from callback, return immediately
     195                        if(ret == false)
     196                                return;
     197                }
     198
     199                verifyAfterAltTab = false;
    161200        }
    162201}
     
    243282
    244283//--------------------------------------------------------------------------------------------------//
    245 bool Win32Keyboard::isKeyDown( KeyCode key )
     284bool Win32Keyboard::isKeyDown( KeyCode key ) const
    246285{
    247286        return (KeyBuffer[key] & 0x80) != 0;
     
    272311
    273312//--------------------------------------------------------------------------------------------------//
    274 void Win32Keyboard::copyKeyStates( char keys[256] )
     313void Win32Keyboard::copyKeyStates( char keys[256] ) const
    275314{
    276315        for(int i = 0; i < 256; ++i)
  • code/branches/input/src/ois/win32/Win32KeyBoard.h

    r1219 r1304  
    4646
    4747                /** @copydoc Keyboard::isKeyDown */
    48                 virtual bool isKeyDown( KeyCode key );
     48                virtual bool isKeyDown( KeyCode key ) const;
    4949               
    5050                /** @copydoc Keyboard::getAsString */
     
    5252
    5353                /** @copydoc Keyboard::copyKeyStates */
    54                 virtual void copyKeyStates( char keys[256] );
     54                virtual void copyKeyStates( char keys[256] ) const;
    5555
    5656                /** @copydoc Object::setBuffered */
Note: See TracChangeset for help on using the changeset viewer.