static int x11_xinput2_poll(ManyMouseEvent *event) { if (dequeue_event(event)) /* ...favor existing events in the queue... */ return 1; pump_events(); /* pump runloop for new hardware events... */ return dequeue_event(event); /* see if anything had shown up... */ } /* x11_xinput2_poll */
/* function :: heartbeat() * arguments :: none * ====================================================== * This function is called once per game pulse, and it will * check the queue, and execute any pending events, which * has been enqueued to execute at this specific time. */ void heartbeat() { EVENT_DATA *event; ITERATOR Iter; /* current_bucket should be global, it is also used in enqueue_event * to figure out what bucket to place the new event in. */ current_bucket = (current_bucket + 1) % MAX_EVENT_HASH; AttachIterator(&Iter, eventqueue[current_bucket]); while ((event = (EVENT_DATA *) NextInList(&Iter)) != NULL) { /* Here we use the event->passes integer, to keep track of * how many times we have ignored this event. */ if (event->passes-- > 0) continue; /* execute event and extract if needed. We assume that all * event functions are of the following prototype * * bool event_function ( EVENT_DATA *event ); * * Any event returning TRUE is not dequeued, it is assumed * that the event has dequeued itself. */ if (!((*event->fun)(event))) dequeue_event(event); } DetachIterator(&Iter); }
static uint32_t events_read(void *x, target_phys_addr_t off) { events_state *s = (events_state *) x; int offset = off; // - s->base; /* This gross hack below is used to ensure that we * only raise the IRQ when the kernel driver is * properly ready! If done before this, the driver * becomes confused and ignores all input events * as soon as one was buffered! */ if (offset == REG_LEN && s->page == PAGE_ABSDATA) { if (s->state == STATE_BUFFERED) qemu_irq_raise(s->irq); s->state = STATE_LIVE; } if (offset == REG_READ) return dequeue_event(s); else if (offset == REG_LEN) return get_page_len(s); else if (offset >= REG_DATA) return get_page_data(s, offset - REG_DATA); return 0; // this shouldn't happen, if the driver does the right thing }
static ssize_t fw_device_op_read(struct file *file, char __user *buffer, size_t count, loff_t *offset) { struct client *client = file->private_data; return dequeue_event(client, buffer, count); }
static uint32_t events_read(void *x, target_phys_addr_t off) { events_state *s = (events_state *) x; int offset = off; // - s->base; if (offset == REG_READ) return dequeue_event(s); else if (offset == REG_LEN) return get_page_len(s); else if (offset >= REG_DATA) return get_page_data(s, offset - REG_DATA); return 0; // this shouldn't happen, if the driver does the right thing }
/* function :: strip_event_mobile() * arguments :: the mobile and the type of event * ====================================================== * This function will dequeue all events of a given type * from the given mobile. */ void strip_event_mobile(D_MOBILE *dMob, int type) { EVENT_DATA *event; ITERATOR Iter; AttachIterator(&Iter, dMob->events); while ((event = (EVENT_DATA *) NextInList(&Iter)) != NULL) { if (event->type == type) dequeue_event(event); } DetachIterator(&Iter); }
/* function :: strip_event_socket() * arguments :: the socket and the type of event * ====================================================== * This function will dequeue all events of a given type * from the given socket. */ void strip_event_socket(D_SOCKET *dSock, int type) { EVENT_DATA *event; ITERATOR Iter; AttachIterator(&Iter, dSock->events); while ((event = (EVENT_DATA *) NextInList(&Iter)) != NULL) { if (event->type == type) dequeue_event(event); } DetachIterator(&Iter); }
bool event_instance_decay( EVENT_DATA *event ) { ENTITY_INSTANCE *corpse; if( event->ownertype != EVENT_OWNER_INSTANCE ) { bug( "%s: bad event owner.", __FUNCTION__ ); return FALSE; } if( ( corpse = (ENTITY_INSTANCE *)event->owner ) == NULL ) { bug( "%s: event had a NULL owner.", __FUNCTION__ ); return FALSE; } text_around_entity( corpse->contained_by, 0, "%s decays into nothingness.\r\n", instance_long_descr( corpse ) ); dequeue_event( event ); delete_eInstance( corpse ); return TRUE; }