501 |
501 |
502 /* FIXME: This is not thread-safe yet */ |
502 /* FIXME: This is not thread-safe yet */ |
503 void |
503 void |
504 SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) |
504 SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) |
505 { |
505 { |
506 SDL_EventWatcher *watcher; |
506 SDL_EventWatcher *watcher, *tail; |
507 |
507 |
508 watcher = (SDL_EventWatcher *)SDL_malloc(sizeof(*watcher)); |
508 watcher = (SDL_EventWatcher *)SDL_malloc(sizeof(*watcher)); |
509 if (!watcher) { |
509 if (!watcher) { |
510 /* Uh oh... */ |
510 /* Uh oh... */ |
511 return; |
511 return; |
512 } |
512 } |
|
513 |
|
514 /* create the watcher */ |
513 watcher->callback = filter; |
515 watcher->callback = filter; |
514 watcher->userdata = userdata; |
516 watcher->userdata = userdata; |
515 watcher->next = SDL_event_watchers; |
517 watcher->next = NULL; |
516 SDL_event_watchers = watcher; |
518 |
|
519 /* add the watcher to the end of the list */ |
|
520 if (SDL_event_watchers) { |
|
521 for (tail = SDL_event_watchers; tail->next; tail = tail->next) { |
|
522 continue; |
|
523 } |
|
524 tail->next = watcher; |
|
525 } else { |
|
526 SDL_event_watchers = watcher; |
|
527 } |
517 } |
528 } |
518 |
529 |
519 /* FIXME: This is not thread-safe yet */ |
530 /* FIXME: This is not thread-safe yet */ |
520 void |
531 void |
521 SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) |
532 SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) |