Changeset 1349 for code/trunk/src/ois/win32/Win32KeyBoard.cpp
- Timestamp:
- May 21, 2008, 9:07:08 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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)
Note: See TracChangeset
for help on using the changeset viewer.