Changeset 1349 for code/trunk/src/ois/win32
- Timestamp:
- May 21, 2008, 9:07:08 PM (17 years ago)
- Location:
- code/trunk/src/ois/win32
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/ois/win32/Win32JoyStick.cpp
r1219 r1349 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/trunk/src/ois/win32/Win32KeyBoard.cpp
r1219 r1349 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/trunk/src/ois/win32/Win32KeyBoard.h
r1219 r1349 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.