void Allegro5Touch::poll(){ if (queue == NULL){ return; } events.clear(); std::map<Key, bool> new_buttons; ALLEGRO_EVENT event; while (al_get_next_event(queue, &event)){ switch (event.type){ case ALLEGRO_EVENT_TOUCH_BEGIN: { // Global::debug(0) << "Touch begin id (" << event.touch.id << ") x (" << (double) event.touch.x << ") y (" << (double) event.touch.y << ")" << std::endl; int id = event.touch.id; double x = event.touch.x; double y = event.touch.y; touches[id] = Util::ReferenceCount<TouchTrack>(new TouchTrack(id, x, y)); handleTouch(touches[id], new_buttons, true); break; } case ALLEGRO_EVENT_TOUCH_END: { int id = event.touch.id; double x = event.touch.x; double y = event.touch.y; handleTouch(touches[id], new_buttons, false); touches[id] = NULL; // Global::debug(0) << "Touch end id (" << event.touch.id << ") x (" << (double) event.touch.x << ") y (" << (double) event.touch.y << ")" << std::endl; break; } case ALLEGRO_EVENT_TOUCH_MOVE: { int id = event.touch.id; double x = event.touch.x; double y = event.touch.y; if (touches[id] != NULL){ touches[id]->update(x, y); } else { touches[id] = Util::ReferenceCount<TouchTrack>(new TouchTrack(id, x, y)); } handleTouch(touches[id], new_buttons, true); // Global::debug(0) << "Touch move id (" << event.touch.id << ") x (" << (double) event.touch.x << ") y (" << (double) event.touch.y << ")" << std::endl; break; } case ALLEGRO_EVENT_TOUCH_CANCEL: { // Global::debug(0) << "Touch cancel id (" << event.touch.id << ") x (" << (double) event.touch.x << ") y (" << (double) event.touch.y << ")" << std::endl; int id = event.touch.id; handleTouch(touches[id], new_buttons, false); touches[id] = NULL; break; } } } generateEvents(new_buttons); }
void TouchingOrder::run(Bottle args/*=Bottle()*/) { yInfo() << "TouchingOrder::run"; string type = sensation_port_in.read()->get(0).asString(); string target = sensation_port_in.read()->get(1).asString(); yInfo() << target; if (target != "none"){ handleSearch(type, target); handleTouch(type, target); } }
int16_t AudioPlugin::handleEvent(const ANPEvent* evt) { //NPP instance = this->inst(); gLogI.log(kError_ANPLogType, "AudioPlugin::handleEvent:%d, action:%d", evt->eventType, evt->data.touch.action); switch (evt->eventType) { case kDraw_ANPEventType: switch (evt->data.draw.model) { case kBitmap_ANPDrawingModel: drawPlugin(evt->data.draw.data.bitmap, evt->data.draw.clip); return 1; default: break; // unknown drawing model } case kTouch_ANPEventType: case kMultiTouch_ANPEventType: { int x = evt->data.touch.x; int y = evt->data.touch.y; gLogI.log(kError_ANPLogType, "kTouch_ANPEventType:x:%d, y%d", x, y); if (kDown_ANPTouchAction == evt->data.touch.action) { m_activeTouchRect = validTouch(x,y); if(m_activeTouchRect) { m_activeTouch = true; return 1; } } else if (kUp_ANPTouchAction == evt->data.touch.action && m_activeTouch) { handleTouch(x, y); m_activeTouch = false; return 1; } else if (kCancel_ANPTouchAction == evt->data.touch.action) { m_activeTouch = false; } break; } default: break; } return 0; // unknown or unhandled event }