Beispiel #1
0
void Platform::process_events() {
  event_thread_running_ = true;

  while (event_thread_running_) {
    SDL_Event event;
    while (SDL_WaitEventTimeout(&event, 100)) {
      switch (event.type) {
        case SDL_QUIT:
          break;
        case SDL_WINDOWEVENT:
          for (auto &iter : windows_) {
            if (auto w = iter.second.lock()) {
              if (w->window_id() == event.window.windowID) {
                w->process_event(event);
                break;
              }
            }
          }
          break;
        case SDL_MOUSEMOTION:
        case SDL_MOUSEBUTTONDOWN:
        case SDL_MOUSEBUTTONUP:
        case SDL_MOUSEWHEEL:
        case SDL_KEYDOWN:
        case SDL_KEYUP:
          process_input_event(event);
          break;
        default:
          break;
      }
    }
  }
}
Beispiel #2
0
static VOID inputtask_entry()
{
    struct EventHandler * eh;
    struct inputtask_params itp;
    BYTE * buff = NULL;
    int ioerr;
    LONG bytesread = 0, items = 0, i;
    BYTE * ptr = NULL;

    /* We must copy the parameter struct because they are allocated
     on the parent's stack */

    D(bug("INSIDE INPUT TASK\n"));
    itp = *((struct inputtask_params *)FindTask(NULL)->tc_UserData);
    eh = itp.eh;
    D(bug("in inputtask: lsd = %p\n", lsd));
    D(bug("FDS: %d\n", lsd->mousedev));

    buff = AllocMem(BUFF_SIZE, MEMF_PUBLIC);
    if (!buff)
        goto failexit;

    Signal(itp.creator, itp.ok_signal);

    for (;;)
    {
        /* TODO: wait for SIGBREAKF_CTRL_C and then signal "caller" task */

        Hidd_UnixIO_Wait(eh->unixio, eh->eventdev, vHidd_UnixIO_Read);
        bytesread = Hidd_UnixIO_ReadFile(eh->unixio, eh->eventdev, buff, BUFF_SIZE, &ioerr);
        items = bytesread / sizeof(struct input_event);

        ptr = buff;

        for (i = 0; i < items; i++)
        {
            process_input_event((struct input_event *)ptr, eh);
            ptr += sizeof(struct input_event);
        }
    }

    FreeMem(buff, BUFF_SIZE);

    return;

failexit:

    if (buff)
        FreeMem(buff, BUFF_SIZE);

    Signal(itp.creator, itp.nok_signal);

    return;
    
}