comparison src/events/SDL_mouse.c @ 4429:faa9fc8e7f67

General improvements for user custom event registration * Switched event type to enum (int32) * Switched polling by mask to polling by type range * Added SDL_RegisterEvents() to allow dynamic user event registration * Spread events out to allow inserting new related events without breaking binary compatibility * Added padding to event structures so they're the same size regardless of 32-bit compiler structure packing settings * Split SDL_HasEvent() to SDL_HasEvent() for a single event and SDL_HasEvents() for a range of events * Added SDL_GetEventState() as a shortcut for SDL_EventState(X, SDL_QUERY) * Added SDL_FlushEvent() and SDL_FlushEvents() to clear events from the event queue
author Sam Lantinga <slouken@libsdl.org>
date Thu, 25 Mar 2010 01:08:26 -0700
parents f7b03b6838cb
children 3e69e077cb95
comparison
equal deleted inserted replaced
4428:68dfd6df47da 4429:faa9fc8e7f67
363 return 0; 363 return 0;
364 } 364 }
365 365
366 mouse->last_x = x; 366 mouse->last_x = x;
367 mouse->last_y = y; 367 mouse->last_y = y;
368 if (SDL_ProcessEvents[type] == SDL_ENABLE) { 368 if (SDL_GetEventState(type) == SDL_ENABLE) {
369 SDL_Event event; 369 SDL_Event event;
370 event.proximity.which = (Uint8) index; 370 event.proximity.which = (Uint8) index;
371 event.proximity.x = x; 371 event.proximity.x = x;
372 event.proximity.y = y; 372 event.proximity.y = y;
373 event.proximity.cursor = mouse->current_end; 373 event.proximity.cursor = mouse->current_end;
459 mouse->MoveCursor(mouse->cur_cursor); 459 mouse->MoveCursor(mouse->cur_cursor);
460 } 460 }
461 461
462 /* Post the event, if desired */ 462 /* Post the event, if desired */
463 posted = 0; 463 posted = 0;
464 if (SDL_ProcessEvents[SDL_MOUSEMOTION] == SDL_ENABLE && 464 if (SDL_GetEventState(SDL_MOUSEMOTION) == SDL_ENABLE &&
465 mouse->proximity == SDL_TRUE) { 465 mouse->proximity == SDL_TRUE) {
466 SDL_Event event; 466 SDL_Event event;
467 event.motion.type = SDL_MOUSEMOTION; 467 event.motion.type = SDL_MOUSEMOTION;
468 event.motion.which = (Uint8) index; 468 event.motion.which = (Uint8) index;
469 event.motion.state = mouse->buttonstate; 469 event.motion.state = mouse->buttonstate;
491 SDL_SendMouseButton(int id, Uint8 state, Uint8 button) 491 SDL_SendMouseButton(int id, Uint8 state, Uint8 button)
492 { 492 {
493 int index = SDL_GetMouseIndexId(id); 493 int index = SDL_GetMouseIndexId(id);
494 SDL_Mouse *mouse = SDL_GetMouse(index); 494 SDL_Mouse *mouse = SDL_GetMouse(index);
495 int posted; 495 int posted;
496 Uint8 type; 496 Uint32 type;
497 497
498 if (!mouse) { 498 if (!mouse) {
499 return 0; 499 return 0;
500 } 500 }
501 501
522 return 0; 522 return 0;
523 } 523 }
524 524
525 /* Post the event, if desired */ 525 /* Post the event, if desired */
526 posted = 0; 526 posted = 0;
527 if (SDL_ProcessEvents[type] == SDL_ENABLE) { 527 if (SDL_GetEventState(type) == SDL_ENABLE) {
528 SDL_Event event; 528 SDL_Event event;
529 event.type = type; 529 event.type = type;
530 event.button.which = (Uint8) index; 530 event.button.which = (Uint8) index;
531 event.button.state = state; 531 event.button.state = state;
532 event.button.button = button; 532 event.button.button = button;
548 return 0; 548 return 0;
549 } 549 }
550 550
551 /* Post the event, if desired */ 551 /* Post the event, if desired */
552 posted = 0; 552 posted = 0;
553 if (SDL_ProcessEvents[SDL_MOUSEWHEEL] == SDL_ENABLE) { 553 if (SDL_GetEventState(SDL_MOUSEWHEEL) == SDL_ENABLE) {
554 SDL_Event event; 554 SDL_Event event;
555 event.type = SDL_MOUSEWHEEL; 555 event.type = SDL_MOUSEWHEEL;
556 event.wheel.which = (Uint8) index; 556 event.wheel.which = (Uint8) index;
557 event.wheel.x = x; 557 event.wheel.x = x;
558 event.wheel.y = y; 558 event.wheel.y = y;