Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 30, 2009, 2:22:00 AM (15 years ago)
Author:
rgrieder
Message:

Merged resource2 branch back to trunk.

IMPORTANT NOTE:
Upon this merge you need to specifically call your data directory "data_extern" when checking it out (when you don't provide a name, it will be just called 'trunk').
The new CMake variable is EXTERNAL_DATA_DIRECTORY. DATA_DIRECTORY now points to the one the source part of the repository.
UPDATE YOUR DATA DIRECTORY AS WELL!!!

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/ois/win32/Win32JoyStick.cpp

    r1505 r5695  
    8282        mState.mAxes.clear();
    8383
    84         delete ff_device;
    85         ff_device = 0;
    86 
     84        if (ff_device)
     85        {
     86                delete ff_device;
     87                ff_device = 0;
     88        }
     89
     90        // Create direct input joystick device.
     91        if(FAILED(mDirectInput->CreateDevice(deviceGuid, &mJoyStick, NULL)))
     92                OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> Could not initialize joy device!");
     93
     94        // Set DIJoystick2 data format.
     95        if(FAILED(mJoyStick->SetDataFormat(&c_dfDIJoystick2)))
     96                OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> data format error!");
     97
     98        // Set cooperative level as specified when creating input manager.
     99        HWND hwin = ((Win32InputManager*)mCreator)->getWindowHandle();
     100        if(FAILED(mJoyStick->SetCooperativeLevel( hwin, coopSetting)))
     101                OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> failed to set cooperation level!");
     102
     103        // Set buffer size.
    87104        DIPROPDWORD dipdw;
    88 
    89105        dipdw.diph.dwSize       = sizeof(DIPROPDWORD);
    90106        dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER);
     
    93109        dipdw.dwData            = JOYSTICK_DX_BUFFERSIZE;
    94110
    95         if(FAILED(mDirectInput->CreateDevice(deviceGuid, &mJoyStick, NULL)))
    96                 OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> Could not initialize joy device!");
    97 
    98         if(FAILED(mJoyStick->SetDataFormat(&c_dfDIJoystick2)))
    99                 OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> data format error!");
    100 
    101         HWND hwin = ((Win32InputManager*)mCreator)->getWindowHandle();
    102 
    103         if(FAILED(mJoyStick->SetCooperativeLevel( hwin, coopSetting)))
    104                 OIS_EXCEPT( E_General, "Win32JoyStick::_initialize() >> failed to set cooperation level!");
    105 
    106111        if( FAILED(mJoyStick->SetProperty(DIPROP_BUFFERSIZE, &dipdw.diph)) )
    107                 OIS_EXCEPT( E_General, "Win32Mouse::Win32Mouse >> Failed to set buffer size property" );
    108 
    109         //Enumerate all axes/buttons/sliders/etc before aquiring
     112                OIS_EXCEPT( E_General, "Win32JoyStick::_initialize >> Failed to set buffer size property" );
     113
     114        // Enumerate all axes/buttons/sliders/force feedback/etc before aquiring
    110115        _enumerate();
    111116
     
    118123void Win32JoyStick::_enumerate()
    119124{
    120         //We can check force feedback here too
    121         DIDEVCAPS  DIJoyCaps;
    122         DIJoyCaps.dwSize = sizeof(DIDEVCAPS);
    123         mJoyStick->GetCapabilities(&DIJoyCaps);
    124 
    125         mPOVs = (short)DIJoyCaps.dwPOVs;
    126 
    127         mState.mButtons.resize(DIJoyCaps.dwButtons);
    128         mState.mAxes.resize(DIJoyCaps.dwAxes);
     125        // Get joystick capabilities.
     126        mDIJoyCaps.dwSize = sizeof(DIDEVCAPS);
     127        if( FAILED(mJoyStick->GetCapabilities(&mDIJoyCaps)) )
     128                OIS_EXCEPT( E_General, "Win32JoyStick::_enumerate >> Failed to get capabilities" );
     129
     130        // => Number of POVs
     131        mPOVs = (short)mDIJoyCaps.dwPOVs;
     132
     133        // => Number of buttons and axes.
     134        mState.mButtons.resize(mDIJoyCaps.dwButtons);
     135        mState.mAxes.resize(mDIJoyCaps.dwAxes);
     136
     137        // Enumerate all Force Feedback effects (if any)
     138        mJoyStick->EnumEffects(DIEnumEffectsCallback, this, DIEFT_ALL);
    129139
    130140        //Reset the axis mapping enumeration value
    131141        _AxisNumber = 0;
    132142
    133         //Enumerate Force Feedback (if any)
    134         mJoyStick->EnumEffects(DIEnumEffectsCallback, this, DIEFT_ALL);
    135 
    136         //Enumerate and set axis constraints (and check FF Axes)
     143        // Enumerate and set axis constraints (and check FF Axes)
    137144        mJoyStick->EnumObjects(DIEnumDeviceObjectsCallback, this, DIDFT_AXIS);
    138145}
     
    181188                OIS_EXCEPT( E_General, "Win32JoyStick::_DIEnumDeviceObjectsCallback >> Failed to set min/max range property" );
    182189
    183         //Check if FF Axes
     190        //Check if FF Axes, and if so, increment counter
    184191        if((lpddoi->dwFlags & DIDOI_FFACTUATOR) != 0 )
    185192        {
    186193                if( _this->ff_device )
    187194                {
    188                         //todo - increment force feedback axis count
     195                        _this->ff_device->_addFFAxis();
    189196                }
    190197        }
    191198
     199        //Force the flags for gain and auto-center support to true,
     200        //as DInput has no API to query the device for these capabilities
     201        //(the only way to know is to try them ...)
     202        if( _this->ff_device )
     203        {
     204            _this->ff_device->_setGainSupport(true);
     205            _this->ff_device->_setAutoCenterSupport(true);
     206        }
     207
    192208        return DIENUM_CONTINUE;
    193209}
     
    198214        Win32JoyStick* _this = (Win32JoyStick*)pvRef;
    199215
    200         //Create the FF class after we know there is at least one effect type
     216        //Create the FF instance only after we know there is at least one effect type
    201217        if( _this->ff_device == 0 )
    202                 _this->ff_device = new Win32ForceFeedback(_this->mJoyStick);
     218          _this->ff_device = new Win32ForceFeedback(_this->mJoyStick, &_this->mDIJoyCaps);
    203219
    204220        _this->ff_device->_addEffectSupport( pdei );
Note: See TracChangeset for help on using the changeset viewer.