comparison src/video/windx5/SDL_dx5events.c @ 460:a888b3ae31ff

Reset mouse state when changing video modes
author Sam Lantinga <slouken@libsdl.org>
date Tue, 20 Aug 2002 06:01:20 +0000
parents a8a0a4f19df7
children da6a7e859616
comparison
equal deleted inserted replaced
459:2a778055dbba 460:a888b3ae31ff
219 219
220 /* DirectInput is ready! */ 220 /* DirectInput is ready! */
221 return(0); 221 return(0);
222 } 222 }
223 223
224 /* Change cooperative level based on whether or not we are fullscreen */
225 void DX5_DInputReset(_THIS, int fullscreen)
226 {
227 DWORD level;
228 int i;
229 HRESULT result;
230
231 for ( i=0; i<MAX_INPUTS; ++i ) {
232 if ( SDL_DIdev[i] != NULL ) {
233 if ( fullscreen ) {
234 level = inputs[i].raw_level;
235 } else {
236 level = inputs[i].win_level;
237 }
238 IDirectInputDevice2_Unacquire(SDL_DIdev[i]);
239 result = IDirectInputDevice2_SetCooperativeLevel(
240 SDL_DIdev[i], SDL_Window, level);
241 IDirectInputDevice2_Acquire(SDL_DIdev[i]);
242 if ( result != DI_OK ) {
243 SetDIerror(
244 "DirectInputDevice::SetCooperativeLevel", result);
245 }
246 }
247 }
248 mouse_lost = 1;
249 }
250
251 /* Clean up DirectInput */ 224 /* Clean up DirectInput */
252 static void DX5_DInputQuit(_THIS) 225 static void DX5_DInputQuit(_THIS)
253 { 226 {
254 int i; 227 int i;
255 228
394 0, 1, xrel, yrel); 367 0, 1, xrel, yrel);
395 xrel = 0; 368 xrel = 0;
396 yrel = 0; 369 yrel = 0;
397 } 370 }
398 if((int)ptrbuf[i].dwData > 0) 371 if((int)ptrbuf[i].dwData > 0)
399 button = 4; 372 button = SDL_BUTTON_WHEELUP;
400 else 373 else
401 button = 5; 374 button = SDL_BUTTON_WHEELDOWN;
402 posted = SDL_PrivateMouseButton( 375 posted = SDL_PrivateMouseButton(
403 SDL_PRESSED, button, 0, 0); 376 SDL_PRESSED, button, 0, 0);
404 posted |= SDL_PrivateMouseButton( 377 posted |= SDL_PrivateMouseButton(
405 SDL_RELEASED, button, 0, 0); 378 SDL_RELEASED, button, 0, 0);
406 break; 379 break;
407 case DIMOFS_BUTTON0: 380 case DIMOFS_BUTTON0:
541 514
542 /* This function checks the windows message queue and DirectInput and returns 515 /* This function checks the windows message queue and DirectInput and returns
543 1 if there was input, 0 if there was no input, or -1 if the application has 516 1 if there was input, 0 if there was no input, or -1 if the application has
544 posted a quit message. 517 posted a quit message.
545 */ 518 */
546 static int DX5_CheckInput(_THIS, int timeout) 519 static int DX5_CheckInput(_THIS, int timeout, BOOL processInput)
547 { 520 {
548 MSG msg; 521 MSG msg;
549 int i; 522 int i;
550 HRESULT result; 523 HRESULT result;
551 DWORD event; 524 DWORD event;
600 result = IDirectInputDevice2_GetDeviceData( 573 result = IDirectInputDevice2_GetDeviceData(
601 SDL_DIdev[event], sizeof(DIDEVICEOBJECTDATA), 574 SDL_DIdev[event], sizeof(DIDEVICEOBJECTDATA),
602 evtbuf, &numevents, 0); 575 evtbuf, &numevents, 0);
603 } 576 }
604 /* Handle the events */ 577 /* Handle the events */
605 if ( result == DI_OK ) { 578 if ( result == DI_OK && processInput ) {
606 /* Note: This can post multiple events to event queue 579 /* Note: This can post multiple events to event queue
607 */ 580 */
608 (*SDL_DIfun[event])((int)numevents, evtbuf); 581 (*SDL_DIfun[event])((int)numevents, evtbuf);
609 return(1); 582 return(1);
610 } 583 }
621 } 594 }
622 } 595 }
623 return(0); 596 return(0);
624 } 597 }
625 598
599 /* Change cooperative level based on whether or not we are fullscreen */
600 void DX5_DInputReset(_THIS, int fullscreen)
601 {
602 DWORD level;
603 int i;
604 HRESULT result;
605
606 for ( i=0; i<MAX_INPUTS; ++i ) {
607 if ( SDL_DIdev[i] != NULL ) {
608 if ( fullscreen ) {
609 level = inputs[i].raw_level;
610 } else {
611 level = inputs[i].win_level;
612 }
613 IDirectInputDevice2_Unacquire(SDL_DIdev[i]);
614 result = IDirectInputDevice2_SetCooperativeLevel(
615 SDL_DIdev[i], SDL_Window, level);
616 IDirectInputDevice2_Acquire(SDL_DIdev[i]);
617 if ( result != DI_OK ) {
618 SetDIerror(
619 "DirectInputDevice::SetCooperativeLevel", result);
620 }
621 }
622 }
623 mouse_lost = 1;
624
625 /* Flush pending input */
626 DX5_CheckInput(this, 0, FALSE);
627 }
628
626 void DX5_PumpEvents(_THIS) 629 void DX5_PumpEvents(_THIS)
627 { 630 {
628 /* Wait for messages and DirectInput */ 631 /* Wait for messages and DirectInput */
629 while ( DX5_CheckInput(this, 0) > 0 ) { 632 while ( DX5_CheckInput(this, 0, TRUE) > 0 ) {
630 /* Loop and check again */; 633 /* Loop and check again */;
631 } 634 }
632 } 635 }
633 636
634 void DX5_InitOSKeymap(_THIS) 637 void DX5_InitOSKeymap(_THIS)