void Window::initializeEventHandler() { if (!m_eventHandler) return; glfwMakeContextCurrent(m_window); m_eventHandler->initialize(*this); glfwMakeContextCurrent(nullptr); queueEvent(new ResizeEvent(size())); queueEvent(new ResizeEvent(framebufferSize(), true)); }
void LwipNetTcpSocket::errCb(err_t err) { DBG("NetTcpSocket %p - Error %d in LwipNetTcpSocket::errCb.\n", (void*)this, err); //WARN: At this point, m_pPcb has been freed by lwIP m_pPcb = NULL; //These errors are fatal, discard all events queued before so that the errors are handled first discardEvents(); m_closed = true; cleanUp(); if( err == ERR_ABRT) queueEvent(NETTCPSOCKET_CONABRT); else //if( err == ERR_RST) queueEvent(NETTCPSOCKET_CONRST); }
cl_int clEnqueueTask(cl_command_queue command_queue, cl_kernel kernel, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) { cl_int rs = CL_SUCCESS; if (!command_queue->isA(Coal::Object::T_CommandQueue)) { return CL_INVALID_COMMAND_QUEUE; } Coal::TaskEvent *command = new Coal::TaskEvent( (Coal::CommandQueue *)command_queue, (Coal::Kernel *)kernel, num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs ); if (rs != CL_SUCCESS) { delete command; return rs; } return queueEvent(command_queue, command, event, false); }
cl_int clEnqueueNDRangeKernel(cl_command_queue command_queue, cl_kernel kernel, cl_uint work_dim, const size_t * global_work_offset, const size_t * global_work_size, const size_t * local_work_size, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) { cl_int rs = CL_SUCCESS; if (!command_queue->isA(Coal::Object::T_CommandQueue)) { return CL_INVALID_COMMAND_QUEUE; } Coal::KernelEvent *command = new Coal::KernelEvent( (Coal::CommandQueue *)command_queue, (Coal::Kernel *)kernel, work_dim, global_work_offset, global_work_size, local_work_size, num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs ); if (rs != CL_SUCCESS) { delete command; return rs; } return queueEvent(command_queue, command, event, false); }
cl_int clEnqueueUnmapMemObject(cl_command_queue command_queue, cl_mem memobj, void * mapped_ptr, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) { cl_int rs = CL_SUCCESS; if (!command_queue->isA(Coal::Object::T_CommandQueue)) { return CL_INVALID_COMMAND_QUEUE; } Coal::UnmapBufferEvent *command = new Coal::UnmapBufferEvent( (Coal::CommandQueue *)command_queue, (Coal::MemObject *)memobj, mapped_ptr, num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs ); if (rs != CL_SUCCESS) { delete command; return rs; } return queueEvent(command_queue, command, event, false); }
// Enqueued Commands APIs cl_int clEnqueueReadBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_read, size_t offset, size_t cb, void * ptr, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) { cl_int rs = CL_SUCCESS; if (!command_queue->isA(Coal::Object::T_CommandQueue)) return CL_INVALID_COMMAND_QUEUE; Coal::ReadBufferEvent *command = new Coal::ReadBufferEvent( (Coal::CommandQueue *)command_queue, (Coal::MemObject *)buffer, offset, cb, ptr, num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs ); if (rs != CL_SUCCESS) { delete command; return rs; } return queueEvent(command_queue, command, event, blocking_read); }
cl_int clEnqueueCopyBufferToImage(cl_command_queue command_queue, cl_mem src_buffer, cl_mem dst_image, size_t src_offset, const size_t * dst_origin, const size_t * region, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) { cl_int rs = CL_SUCCESS; if (!command_queue->isA(Coal::Object::T_CommandQueue)) return CL_INVALID_COMMAND_QUEUE; Coal::CopyBufferToImageEvent *command = new Coal::CopyBufferToImageEvent( (Coal::CommandQueue *)command_queue, (Coal::MemObject *)src_buffer, (Coal::Image2D *)dst_image, src_offset, dst_origin, region, num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs ); if (rs != CL_SUCCESS) { delete command; return rs; } return queueEvent(command_queue, command, event, false); }
cl_int clEnqueueWriteImage(cl_command_queue command_queue, cl_mem image, cl_bool blocking_write, const size_t * origin, const size_t * region, size_t row_pitch, size_t slice_pitch, const void * ptr, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) { cl_int rs = CL_SUCCESS; if (!command_queue->isA(Coal::Object::T_CommandQueue)) return CL_INVALID_COMMAND_QUEUE; Coal::WriteImageEvent *command = new Coal::WriteImageEvent( (Coal::CommandQueue *)command_queue, (Coal::Image2D *)image, origin, region, row_pitch, slice_pitch, (void *)ptr, num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs ); if (rs != CL_SUCCESS) { delete command; return rs; } return queueEvent(command_queue, command, event, blocking_write); }
err_t LwipNetTcpSocket::acceptCb(struct tcp_pcb *newpcb, err_t err) { if(err) { DBG("Error %d in LwipNetTcpSocket::acceptCb.\n", err); return err; } //FIXME: MEM Errs //m_lpInPcb.push(newpcb); //Add connection to the queue LwipNetTcpSocket* pNewNetTcpSocket = new LwipNetTcpSocket(newpcb); if(pNewNetTcpSocket == NULL) { DBG("Not enough mem, socket dropped in LwipNetTcpSocket::acceptCb.\n"); tcp_abort(newpcb); return ERR_ABRT; } pNewNetTcpSocket->m_refs++; m_lpInNetTcpSocket.push( pNewNetTcpSocket ); // tcp_accepted(newpcb); // tcp_accepted( m_pPcb ); //Should fire proper events //WARN: m_pPcb is the GOOD param here (and not pInPcb) queueEvent(NETTCPSOCKET_ACCEPT); return ERR_OK; }
void AnimationManager::update() { std::vector<Animation::Ptr>::iterator i; i = animations.begin(); while( i != animations.end() ) { (*i)->addTime( timeSinceLastFrame ); if( (*i)->isFinished() ) { RefCountedObjectPtr<AnimationEventData> data( new AnimationEventData ); EventPtr event = newEvent( finishEvent ); data->animation = *i; event->data = data; queueEvent( event ); if( (*i)->shouldRemoveWhenFinished() ) { i = animations.erase( i ); continue; } } i++; } }
static void pe_tracevar(pe_watcher *wa, SV *sv, int got) { /* Adapted from tkGlue.c We are a "magic" set processor. So we are (I think) supposed to look at "private" flags and set the public ones if appropriate. e.g. "chop" sets SvPOKp as a hint but not SvPOK presumably other operators set other private bits. Question are successive "magics" called in correct order? i.e. if we are tracing a tied variable should we call some magic list or be careful how we insert ourselves in the list? */ pe_ioevent *ev; if (SvPOKp(sv)) SvPOK_on(sv); if (SvNOKp(sv)) SvNOK_on(sv); if (SvIOKp(sv)) SvIOK_on(sv); ev = (pe_ioevent*) (*wa->vtbl->new_event)(wa); ++ev->base.hits; ev->got |= got; queueEvent((pe_event*) ev); }
cl_int clEnqueueNativeKernel(cl_command_queue command_queue, void (*user_func)(void *), void * args, size_t cb_args, cl_uint num_mem_objects, const cl_mem * mem_list, const void ** args_mem_loc, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event) { cl_int rs = CL_SUCCESS; if (!command_queue->isA(Coal::Object::T_CommandQueue)) return CL_INVALID_COMMAND_QUEUE; Coal::NativeKernelEvent *command = new Coal::NativeKernelEvent( (Coal::CommandQueue *)command_queue, user_func, args, cb_args, num_mem_objects, (const Coal::MemObject **)mem_list, args_mem_loc, num_events_in_wait_list, (const Coal::Event **)event_wait_list, &rs ); if (rs != CL_SUCCESS) { delete command; return rs; } return queueEvent(command_queue, command, event, false); }
PUBLIC void mprQueueEvent(MprDispatcher *dispatcher, MprEvent *event) { MprEventService *es; MprEvent *prior, *q; assert(dispatcher); assert(event); assert(event->timestamp); es = dispatcher->service; lock(es); q = dispatcher->eventQ; for (prior = q->prev; prior != q; prior = prior->prev) { if (event->due > prior->due) { break; } else if (event->due == prior->due) { break; } } assert(prior->next); assert(prior->prev); queueEvent(prior, event); event->dispatcher = dispatcher; es->eventCount++; mprScheduleDispatcher(dispatcher); unlock(es); }
bool MidiJackDevice::processEvent(const MidiPlayEvent& event) { int chn = event.channel(); unsigned t = event.time(); int a = event.dataA(); int b = event.dataB(); // Perhaps we can find use for this value later, together with the Jack midi LOS port(s). // No big deal if not. Not used for now. int port = event.port(); // TODO: No sub-tick playback resolution yet, with external sync. // Just do this 'standard midi 64T timing thing' for now until we figure out more precise external timings. // Does require relatively short audio buffers, in order to catch the resolution, but buffer <= 256 should be OK... // Tested OK so far with 128. if (t == 0 /*|| extSyncFlag.value()*/) t = audio->getFrameOffset() + audio->pos().frame(); #ifdef JACK_MIDI_DEBUG //printf("MidiJackDevice::processEvent time:%d type:%d ch:%d A:%d B:%d\n", event.time(), event.type(), event.channel(), event.dataA(), event.dataB()); #endif //Send to monitor thread for processing monitorOutputEvent(event); if (event.type() == ME_PROGRAM) { // don't output program changes for GM drum channel int hb = (a >> 16) & 0xff; int lb = (a >> 8) & 0xff; int pr = a & 0x7f; //TODO: NOTE this is where program changes are sent we can later debug this to diagnose the dropped events if (hb != 0xff) { if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HBANK, hb))) return false; } if (lb != 0xff) { if(!queueEvent(MidiPlayEvent(t + 1, port, chn, ME_CONTROLLER, CTRL_LBANK, lb))) return false; } //sleep(1); if(!queueEvent(MidiPlayEvent(t + 2, port, chn, ME_PROGRAM, pr, 0))) return false; }
void setErrorMessageFormat(EQNet* net, const char* fmt, ...) { va_list args; va_start(args, fmt); setErrFmt(net, fmt, args); va_end(args); queueEvent(net, EQNET_EVENT_Error); }
static void * deviceThread(void * context) { unsigned int gamepadIndex; struct Gamepad_device * device; struct Gamepad_devicePrivate * devicePrivate; struct input_event event; device = context; devicePrivate = device->privateData; while (read(devicePrivate->fd, &event, sizeof(struct input_event)) > 0) { if (event.type == EV_ABS) { float value; if (event.code > ABS_MAX || devicePrivate->axisMap[event.code] == -1) { continue; } value = (event.value - devicePrivate->axisInfo[event.code].minimum) / (float) (devicePrivate->axisInfo[event.code].maximum - devicePrivate->axisInfo[event.code].minimum) * 2.0f - 1.0f; queueAxisEvent(device, event.time.tv_sec + event.time.tv_usec * 0.000001, devicePrivate->axisMap[event.code], value, device->axisStates[devicePrivate->axisMap[event.code]]); device->axisStates[devicePrivate->axisMap[event.code]] = value; } else if (event.type == EV_KEY) { if (event.code < BTN_MISC || event.code > KEY_MAX || devicePrivate->buttonMap[event.code - BTN_MISC] == -1) { continue; } queueButtonEvent(device, event.time.tv_sec + event.time.tv_usec * 0.000001, devicePrivate->buttonMap[event.code - BTN_MISC], !!event.value); device->buttonStates[devicePrivate->buttonMap[event.code - BTN_MISC]] = !!event.value; } } queueEvent(device->deviceID, GAMEPAD_EVENT_DEVICE_REMOVED, device); pthread_mutex_lock(&devicesMutex); for (gamepadIndex = 0; gamepadIndex < numDevices; gamepadIndex++) { if (devices[gamepadIndex] == device) { unsigned int gamepadIndex2; numDevices--; for (gamepadIndex2 = gamepadIndex; gamepadIndex2 < numDevices; gamepadIndex2++) { devices[gamepadIndex2] = devices[gamepadIndex2 + 1]; } gamepadIndex--; } } pthread_mutex_unlock(&devicesMutex); return NULL; }
void * clEnqueueMapBuffer(cl_command_queue command_queue, cl_mem buffer, cl_bool blocking_map, cl_map_flags map_flags, size_t offset, size_t cb, cl_uint num_events_in_wait_list, const cl_event * event_wait_list, cl_event * event, cl_int * errcode_ret) { cl_int dummy_errcode; if (!errcode_ret) errcode_ret = &dummy_errcode; *errcode_ret = CL_SUCCESS; if (!command_queue->isA(Coal::Object::T_CommandQueue)) { *errcode_ret = CL_INVALID_COMMAND_QUEUE; return 0; } Coal::MapBufferEvent *command = new Coal::MapBufferEvent( (Coal::CommandQueue *)command_queue, (Coal::MemObject *)buffer, offset, cb, map_flags, num_events_in_wait_list, (const Coal::Event **)event_wait_list, errcode_ret ); if (*errcode_ret != CL_SUCCESS) { delete command; return 0; } // We need command to be valid after queueEvent, so don't let the command // queue handle it like a fire-and-forget event. Fixes a crash when event // is NULL : the event gets deleted by clReleaseEvent called from // CPUDevice's worker() and we then try to read it in command->ptr(); command->reference(); *errcode_ret = queueEvent(command_queue, command, event, blocking_map); if (*errcode_ret != CL_SUCCESS) return 0; else { void *rs = command->ptr(); clReleaseEvent((cl_event)command); return rs; } }
void EmulatorWindow::keyReleaseEvent(QKeyEvent *event) { handleKeyEvent(kEventKeyUp, event); if (event->text().length() > 0) { SkinEvent *skin_event = createSkinEvent(kEventTextInput); skin_event->u.text.down = false; strncpy((char*)skin_event->u.text.text, (const char*)event->text().constData(), 32); queueEvent(skin_event); } }
void EmulatorWindow::handleEvent(SkinEventType type, QMouseEvent *event) { SkinEvent *skin_event = createSkinEvent(type); skin_event->u.mouse.button = event->button() == Qt::RightButton ? kMouseButtonRight : kMouseButtonLeft; skin_event->u.mouse.x = event->x(); skin_event->u.mouse.y = event->y(); skin_event->u.mouse.xrel = 0; skin_event->u.mouse.yrel = 0; queueEvent(skin_event); }
void EmulatorWindow::handleKeyEvent(SkinEventType type, QKeyEvent *pEvent) { SkinEvent *skin_event = createSkinEvent(type); SkinEventKeyData *keyData = &skin_event->u.key; keyData->keycode = convertKeyCode(pEvent->key()); Qt::KeyboardModifiers modifiers = pEvent->modifiers(); if (modifiers & Qt::ShiftModifier) keyData->mod |= kKeyModLShift; if (modifiers & Qt::ControlModifier) keyData->mod |= kKeyModLCtrl; if (modifiers & Qt::AltModifier) keyData->mod |= kKeyModLAlt; queueEvent(skin_event); }
void EmulatorWindow::wheelEvent(QWheelEvent *event) { int delta = event->delta(); SkinEvent *skin_event = createSkinEvent(kEventMouseButtonDown); skin_event->u.mouse.button = delta >= 0 ? kMouseButtonScrollUp : kMouseButtonScrollDown; skin_event->u.mouse.x = event->globalX(); skin_event->u.mouse.y = event->globalY(); skin_event->u.mouse.xrel = event->x(); skin_event->u.mouse.yrel = event->y(); queueEvent(skin_event); }
static void queueButtonEvent(struct Gamepad_device * device, double timestamp, unsigned int buttonID, bool down) { struct Gamepad_buttonEvent * buttonEvent; buttonEvent = (Gamepad_buttonEvent*)malloc(sizeof(struct Gamepad_buttonEvent)); buttonEvent->device = device; buttonEvent->timestamp = timestamp; buttonEvent->buttonID = buttonID; buttonEvent->down = down; queueEvent(device->eventDispatcher, down ? GAMEPAD_EVENT_BUTTON_DOWN : GAMEPAD_EVENT_BUTTON_UP, buttonEvent); }
static void queueAxisEvent(struct Gamepad_device * device, double timestamp, unsigned int axisID, float value) { struct Gamepad_axisEvent * axisEvent; axisEvent = (Gamepad_axisEvent*)malloc(sizeof(struct Gamepad_axisEvent)); axisEvent->device = device; axisEvent->timestamp = timestamp; axisEvent->axisID = axisID; axisEvent->value = value; queueEvent(device->eventDispatcher, GAMEPAD_EVENT_AXIS_MOVED, axisEvent); }
err_t LwipNetTcpSocket::recvCb(tcp_pcb* tpcb, pbuf *p, err_t err) { //Store pbuf ptr // DBG("Receive CB with err = %d & len = %d.\n", err, p->tot_len); // tcp_recved( (tcp_pcb*) m_pPcb, p->tot_len); //Acknowledge the reception if(err) { queueEvent(NETTCPSOCKET_ERROR); return ERR_OK; //FIXME: More robust error handling there } else if(!p) { DBG("NetTcpSocket %p - Connection closed by remote host (LwipNetTcpSocket::recvCb).\n", (void*)this); //Buf is NULL, that means that the connection has been closed by remote host //FIX: 27/05/2010: We do not want to deallocate the socket while some data might still be readable //REMOVED: close(); //However we do not want to close the socket yet queueEvent(NETTCPSOCKET_DISCONNECTED); return ERR_OK; } //We asserted that p is a valid pointer //New data processing tcp_recved( tpcb, p->tot_len); //Acknowledge the reception if(!m_pReadPbuf) { m_pReadPbuf = p; queueEvent(NETTCPSOCKET_READABLE); } else { pbuf_cat((pbuf*)m_pReadPbuf, p); //m_pReadPbuf is not empty, tail p to it and drop our ref //No need to queue an event in that case since the read buf has not been processed yet } return ERR_OK; }
N8_Status_t n8_handleEvent(N8_Event_t *e_p, void *hReq_p, N8_Unit_t unit, N8_QueueStatusCodes_t requestStatus) { N8_Status_t ret = N8_STATUS_OK; QMgrRequest_t *req_p; req_p = (QMgrRequest_t *)hReq_p; if (e_p != NULL) { /* This is an asynchronous request */ e_p->state = (void *) req_p; e_p->status = requestStatus; e_p->unit = unit; #ifdef SUPPORT_CALLBACK_THREAD if ((e_p->usrCallback != NULL) || (e_p->usrData != NULL)) { ret = queueEvent(e_p); } #endif } else { /* This is an synchronous request. Therefore we don't need an */ /* event, we know that the request has completed. */ #ifdef SUPPORT_DEVICE_POLL N8_QMgrDequeue(); #endif if ( req_p->requestError != N8_QUEUE_REQUEST_ERROR ) { /* Do the callback if needed. */ if ( req_p->callback != NULL ) { req_p->callback( req_p ); } /* Free the request if the event has completed successfully. */ /* If not the error handling should free the request. */ if (((API_Request_t *)req_p)->userRequest != N8_TRUE) { /* Don't delete "user allocated/ pooled" requests */ freeRequest( (API_Request_t *)req_p ); } } else { ret = N8_HARDWARE_ERROR; } } return ret; } /* n8_handleEvent */
bool InputSystem::keyReleased( const OIS::KeyEvent &arg ) { EventPtr event = newEvent( event_keyup ); RefCountedObjectPtr<InputEventData> data( new InputEventData ); data->key = arg.key; event->data = data; queueEvent( event ); return true; }
bool InputSystem::keyPressed( const OIS::KeyEvent &arg ) { EventPtr event = newEvent( event_keydown ); RefCountedObjectPtr<InputEventData> data( new InputEventData ); data->key = arg.key; data->parm = arg.text; event->data = data; queueEvent( event ); return true; }
bool InputSystem::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) { EventPtr event = newEvent( event_mouseup ); RefCountedObjectPtr<InputEventData> data( new InputEventData ); data->x = arg.state.X.abs; data->y = arg.state.Y.abs; data->parm = arg.state.buttons; event->data = data; queueEvent( event ); return true; }
cl_int clEnqueueBarrier(cl_command_queue command_queue) { cl_int rs = CL_SUCCESS; if (!command_queue->isA(Coal::Object::T_CommandQueue)) return CL_INVALID_COMMAND_QUEUE; Coal::BarrierEvent *command = new Coal::BarrierEvent( (Coal::CommandQueue *)command_queue, &rs); if (rs != CL_SUCCESS) { delete command; return rs; } return queueEvent(command_queue, command, 0, false); }
/* Get the next due event from the front of the event queue. */ PUBLIC MprEvent *mprGetNextEvent(MprDispatcher *dispatcher) { MprEventService *es; MprEvent *event, *next; es = dispatcher->service; event = 0; lock(es); next = dispatcher->eventQ->next; if (next != dispatcher->eventQ) { if (next->due <= es->now) { /* Hold event while executing in the current queue */ event = next; queueEvent(dispatcher->currentQ, event); } } unlock(es); return event; }