Changeset 1304 for code/branches
- Timestamp:
- May 15, 2008, 10:35:14 PM (17 years ago)
- Location:
- code/branches/input/src/ois
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/input/src/ois/OISJoyStick.cpp
r1219 r1304 36 36 37 37 //----------------------------------------------------------------------------// 38 int JoyStick::getNumberOfComponents(ComponentType cType) 38 int JoyStick::getNumberOfComponents(ComponentType cType) const 39 39 { 40 40 switch( cType ) … … 56 56 57 57 //----------------------------------------------------------------------------// 58 float JoyStick::getVector3Sensitivity() 58 float JoyStick::getVector3Sensitivity() const 59 59 { 60 60 return mVector3Sensitivity; … … 68 68 69 69 //----------------------------------------------------------------------------// 70 JoyStickListener* JoyStick::getEventCallback() 70 JoyStickListener* JoyStick::getEventCallback() const 71 71 { 72 72 return mListener; -
code/branches/input/src/ois/OISJoyStick.h
r1219 r1304 168 168 The ComponentType you are interested in knowing about 169 169 */ 170 int getNumberOfComponents(ComponentType cType) ;170 int getNumberOfComponents(ComponentType cType) const; 171 171 172 172 /** … … 184 184 Returns the sensitivity cutoff for Vector3 Component 185 185 */ 186 float getVector3Sensitivity() ;186 float getVector3Sensitivity() const; 187 187 188 188 /** … … 196 196 197 197 /** @remarks Returns currently set callback.. or null */ 198 JoyStickListener* getEventCallback() ;198 JoyStickListener* getEventCallback() const; 199 199 200 200 /** @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 33 33 34 34 //----------------------------------------------------------------------// 35 bool Keyboard::isModifierDown( Modifier mod ) 35 bool Keyboard::isModifierDown( Modifier mod ) const 36 36 { 37 37 #if defined(OIS_MSVC_COMPILER) -
code/branches/input/src/ois/OISKeyboard.h
r1219 r1304 220 220 A KeyCode to check 221 221 */ 222 virtual bool isKeyDown( KeyCode key ) = 0;222 virtual bool isKeyDown( KeyCode key ) const = 0; 223 223 224 224 /** … … 235 235 Returns currently set callback.. or 0 236 236 */ 237 KeyListener* getEventCallback() {return mListener;}237 KeyListener* getEventCallback() const {return mListener;} 238 238 239 239 //! TextTranslation Mode … … 260 260 Returns current translation mode 261 261 */ 262 TextTranslationMode getTextTranslation() {return mTextMode;}262 TextTranslationMode getTextTranslation() const {return mTextMode;} 263 263 264 264 /** … … 286 286 Check modifier status 287 287 */ 288 bool isModifierDown( Modifier mod ) ;288 bool isModifierDown( Modifier mod ) const; 289 289 290 290 /** … … 293 293 (in the form of 1 is down and 0 is up) 294 294 */ 295 virtual void copyKeyStates( char keys[256] ) = 0;295 virtual void copyKeyStates( char keys[256] ) const = 0; 296 296 297 297 protected: -
code/branches/input/src/ois/OISMouse.h
r1219 r1304 120 120 121 121 /** @remarks Returns currently set callback.. or 0 */ 122 MouseListener* getEventCallback() {return mListener;}122 MouseListener* getEventCallback() const {return mListener;} 123 123 124 124 /** @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 45 45 46 46 /** @remarks Returns this input object's creator */ 47 InputManager* getCreator() { return mCreator; }47 InputManager* getCreator() const { return mCreator; } 48 48 49 49 /** @remarks Sets buffered mode */ -
code/branches/input/src/ois/linux/LinuxKeyboard.cpp
r1219 r1304 290 290 291 291 //-------------------------------------------------------------------// 292 bool LinuxKeyboard::isKeyDown( KeyCode key ) 292 bool LinuxKeyboard::isKeyDown( KeyCode key ) const 293 293 { 294 294 return (KeyBuffer[key]); … … 449 449 450 450 //-------------------------------------------------------------------// 451 void LinuxKeyboard::copyKeyStates( char keys[256] ) 451 void LinuxKeyboard::copyKeyStates( char keys[256] ) const 452 452 { 453 453 memcpy( keys, KeyBuffer, 256 ); -
code/branches/input/src/ois/linux/LinuxKeyboard.h
r1219 r1304 38 38 39 39 /** @copydoc Keyboard::isKeyDown */ 40 virtual bool isKeyDown( KeyCode key ) ;40 virtual bool isKeyDown( KeyCode key ) const; 41 41 42 42 /** @copydoc Keyboard::getAsString */ … … 44 44 45 45 /** @copydoc Keyboard::copyKeyStates */ 46 virtual void copyKeyStates( char keys[256] ) ;46 virtual void copyKeyStates( char keys[256] ) const; 47 47 48 48 /** @copydoc Object::setBuffered */ -
code/branches/input/src/ois/mac/MacKeyboard.cpp
r1219 r1304 130 130 131 131 //-------------------------------------------------------------------// 132 bool MacKeyboard::isKeyDown( KeyCode key ) 132 bool MacKeyboard::isKeyDown( KeyCode key ) const 133 133 { 134 134 return (bool)KeyBuffer[key]; … … 321 321 322 322 //-------------------------------------------------------------------// 323 void MacKeyboard::copyKeyStates( char keys[256] ) 323 void MacKeyboard::copyKeyStates( char keys[256] ) const 324 324 { 325 325 memcpy( keys, KeyBuffer, 256 ); -
code/branches/input/src/ois/mac/MacKeyboard.h
r1219 r1304 43 43 44 44 // unbuffered keydown check 45 virtual bool isKeyDown( KeyCode key ) ;45 virtual bool isKeyDown( KeyCode key ) const; 46 46 47 47 // This will send listener events if buffered is on. … … 51 51 52 52 // Copies the current key buffer 53 virtual void copyKeyStates( char keys[256] ) ;53 virtual void copyKeyStates( char keys[256] ) const; 54 54 55 55 // Returns a description of the given key -
code/branches/input/src/ois/win32/Win32JoyStick.cpp
r1219 r1304 149 149 diptr.diph.dwHow = DIPH_BYID; 150 150 diptr.diph.dwObj = lpddoi->dwType; 151 //Add the high bit in so that an axis value of zero does not mean a null userdata152 diptr.uData = 0x 80000000 | _this->_AxisNumber;151 //Add a magic number to recognise we set seomthing 152 diptr.uData = 0x13130000 | _this->_AxisNumber; 153 153 154 154 //Check if axis is slider, if so, do not treat as regular axis … … 166 166 167 167 //Increase for next time through 168 _this->_AxisNumber += 1; 168 if(GUID_Slider != lpddoi->guidType) 169 _this->_AxisNumber += 1; 169 170 170 171 //Set range … … 238 239 for(unsigned int i = 0; i < entries; ++i) 239 240 { 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) 242 244 { 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) ) 253 299 { 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])) 266 301 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()) 308 309 { 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; 311 312 } 312 break; 313 } //end case 314 } //End else 313 } 314 315 break; 316 } //end case 315 317 } //end for 316 318 -
code/branches/input/src/ois/win32/Win32KeyBoard.cpp
r1219 r1304 105 105 DWORD entries = KEYBOARD_DX_BUFFERSIZE; 106 106 HRESULT hr; 107 //Only one keyboard allowed per app, so static is ok 108 static bool verifyAfterAltTab = false; 107 109 108 110 hr = mKeyboard->GetDeviceData( sizeof(DIDEVICEOBJECTDATA), diBuff, &entries, 0 ); … … 110 112 { 111 113 hr = mKeyboard->Acquire(); 114 if (hr == E_ACCESSDENIED) 115 verifyAfterAltTab = true; 116 112 117 while( hr == DIERR_INPUTLOST ) 113 118 hr = mKeyboard->Acquire(); 119 114 120 return; 115 121 } … … 121 127 for(unsigned int i = 0; i < entries; ++i ) 122 128 { 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... 124 130 //send no more events and just leave as the this pointer is invalid now... 125 131 bool ret = true; … … 159 165 if(ret == false) 160 166 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; 161 200 } 162 201 } … … 243 282 244 283 //--------------------------------------------------------------------------------------------------// 245 bool Win32Keyboard::isKeyDown( KeyCode key ) 284 bool Win32Keyboard::isKeyDown( KeyCode key ) const 246 285 { 247 286 return (KeyBuffer[key] & 0x80) != 0; … … 272 311 273 312 //--------------------------------------------------------------------------------------------------// 274 void Win32Keyboard::copyKeyStates( char keys[256] ) 313 void Win32Keyboard::copyKeyStates( char keys[256] ) const 275 314 { 276 315 for(int i = 0; i < 256; ++i) -
code/branches/input/src/ois/win32/Win32KeyBoard.h
r1219 r1304 46 46 47 47 /** @copydoc Keyboard::isKeyDown */ 48 virtual bool isKeyDown( KeyCode key ) ;48 virtual bool isKeyDown( KeyCode key ) const; 49 49 50 50 /** @copydoc Keyboard::getAsString */ … … 52 52 53 53 /** @copydoc Keyboard::copyKeyStates */ 54 virtual void copyKeyStates( char keys[256] ) ;54 virtual void copyKeyStates( char keys[256] ) const; 55 55 56 56 /** @copydoc Object::setBuffered */
Note: See TracChangeset
for help on using the changeset viewer.