void State::handle(Event::Event* event) { if (event->handled()) return; // TODO: maybe make handle() a template function to get rid of dynamic_casts? if (auto keyboardEvent = dynamic_cast<Event::Keyboard*>(event)) { switch (keyboardEvent->originalType()) { case Event::Keyboard::Type::KEY_UP: { emitEvent(std::make_unique<Event::Keyboard>(*keyboardEvent), keyUpHandler()); break; } case Event::Keyboard::Type::KEY_DOWN: { emitEvent(std::make_unique<Event::Keyboard>(*keyboardEvent), keyDownHandler()); break; } } } for (auto it = _ui.rbegin(); it != _ui.rend(); ++it) { if (event->handled()) return; (*it)->handle(event); } }
bool M4SCpWindow::loadFromFile(const QString &fileName) { // read data from file QFile fileIn(fileName); if (!fileIn.open(QIODevice::ReadOnly | QIODevice::Text)) { QMessageBox::warning(0, tr("Error"), tr("Can't open file %1:\n%2.") .arg(fileName) .arg(fileIn.errorString())); return false; } QTextStream in(&fileIn); mEditor->document()->setPlainText(in.readAll()); fileIn.close(); mFileName = fileName; setWindowTitle(mFileName + "[*]"); mIsSaved = true; emitEvent(EditorObserverInterface::ContentLoaded); return true; }
void EventFrame::onEnter(Frame *nextFrame, int currentFrameIndex) { if (static_cast<int>(_frameIndex) < _action->getStartFrame() || static_cast<int>(_frameIndex) > _action->getEndFrame()) return; if (currentFrameIndex >= static_cast<int>(_frameIndex)) emitEvent(); }
void EventFrame::onEnter(Frame *nextFrame, int currentFrameIndex) { if(_frameIndex < _action->getStartFrame() || _frameIndex > _action->getEndFrame()) return; if(currentFrameIndex >= _frameIndex) emitEvent(); }
void CursorDropdown::handle(Event::Event* event) { if (auto mouseEvent = dynamic_cast<Event::Mouse*>(event)) { // TODO: probably need to make invisible panel to catch all mouse events.. // let state catch all mouse events emitEvent(make_unique<Event::Mouse>(*mouseEvent)); event->setHandled(true); } }
void STM::setState(State* st) { std::cout << "[STM]Transition: "; if(m_state != nullptr) { std::cout << m_state->getName() << " => "; } std::cout << st->getName() << std::endl; emitEvent("STExit"); m_state = st; st->setup(); }
void ItemsList::onMouseDragStop(Event::Mouse* event) { _draggedItem->setOffset(0, 0); _draggedItem->setType(_type); auto itemevent = new Event::Mouse("itemdragstop"); itemevent->setPosition(event->position()); itemevent->setEmitter(this); emitEvent(itemevent); delete itemevent; _draggedItem = 0; Logger::critical() << "mousedragstop" << std::endl; }
void DigitalOutput::step() { uint i, n = m_inputs.size(); m_data = 0.0; for (i=0; i<n; i++) m_data += m_inputs[i]; m_output.write(m_data); if (m_data - m_previous > 0) { switch (m_eventToSend) { case DIGITAL_RISE: emitEvent(new DigitalRiseEvent(this)); break; case STOPRUN: emitEvent(new StopRunEvent(this)); Logger(Important, "Simulation terminated by DigitalOutput(%d).\n", id()); break; case RESET: emitEvent(new ResetEvent(this)); break; case TOGGLE: emitEvent(new ToggleEvent(this)); break; case TRIGGER: emitEvent(new TriggerEvent(this)); break; case SPIKE: emitEvent(new SpikeEvent(this)); break; default: Logger(Important, "DigitalOutput(%d): Can't send event.\n", id()); break; } } m_previous = m_data; }
void DigitalInput::step() { m_data = m_input.read(); //Rising crossing if (m_data - m_previous > 0) { switch (m_eventToSend) { case DIGITAL_RISE: emitEvent(new DigitalRiseEvent(this)); break; case STOPRUN: emitEvent(new StopRunEvent(this)); Logger(Important, "Simulation terminated by DigitalInput(%d).\n", id()); break; case RESET: emitEvent(new ResetEvent(this)); break; case TOGGLE: emitEvent(new ToggleEvent(this)); break; case TRIGGER: emitEvent(new TriggerEvent(this)); break; case SPIKE: emitEvent(new SpikeEvent(this)); break; default: Logger(Important, "DigitalInput(%d): Can't send event.\n", id()); break; } } m_previous = m_data; }
bool SCgWindow::loadFromFile(const QString &fileName) { GWFFileLoader loader; if (loader.load(fileName, mView->scene())) { mFileName = fileName; setWindowTitle(mFileName); emitEvent(EditorObserverInterface::ContentLoaded); return true; }else return false; }
bool SCgWindow::loadFromFile(const QString &fileName) { QFileInfo * fileExt = new QFileInfo(fileName); if(fileExt->suffix()=="gwf") { GWFFileLoader loader; if (loader.load(fileName, mView->scene())) { mFileName = fileName; setWindowTitle(mFileName); emitEvent(EditorObserverInterface::ContentLoaded); return true; } else return false; } if(fileExt->suffix()=="scsi") { ScsFileLoader loader; if (loader.load(fileName, mView->scene())) { mFileName = fileName; setWindowTitle(mFileName); emitEvent(EditorObserverInterface::ContentLoaded); return true; } else return false; } return false; }
void InputEventSystem::parse(struct input_event* events, u32 num) { currentState = ST_TOUCH_UPDATE; for(u32 i=0; i<num; ++i) { struct input_event* ev = &(events[i]); // DOUT("time: "<<(s64)ev->time.tv_sec<<" "<<(s64)ev->time.tv_usec); switch(ev->type) { case EV_ABS: { switch(ev->code) { case ABS_X:currentX = floorf((ev->value/dx)*displayWidth);break; case ABS_Y:currentY = floorf(displayHeight - (ev->value/dy)*displayHeight);break; default: //DOUT("tf"); // DOUT(code2string(ev->type, ev->code, "?")); break; } } case EV_KEY: { switch(ev->code) { case BTN_TOUCH: { switch(ev->value) { case 0:currentState=ST_TOUCH_UP;break; case 1:currentState=ST_TOUCH_DOWN;break; } } } } case EV_SYN: { switch(ev->code) { case SYN_REPORT: { emitEvent(ev); break; } } } } } }
bool SCgWindow::saveToFile(const QString &fileName) { GWFFileWriter writer; if (writer.save(fileName, mView->scene())) { mFileName = fileName; setWindowTitle(mFileName); mUndoStack->setClean(); emitEvent(EditorObserverInterface::ContentSaved); return true; }else return false; }
void PeriodicPulse::step() { double now = GetGlobalTime(); if (now >= (m_tNextPulse - 0.5*GetGlobalDt())) { if (m_output == 0.0) { Logger(Debug, "Turning output ON @ t = %f s.\n", now); m_output = PP_AMPLITUDE; emitEvent(new TriggerEvent(this)); } else if (now >= m_tNextPulse+PP_DURATION) { Logger(Debug, "Turning output OFF @ t = %f s.\n", now); m_tNextPulse += PP_PERIOD; m_output = 0.0; } } }
void SliderView::onMouseDrag(const MouseMotionEvent* evt){ glm::vec2 pos = toLocalCoords(evt->mX, evt->mY); if(mMode == eMODE_HORIZONTAL){ setValue( (pos.x/getSize().x)*100.0f ); } else{ setValue( (pos.y/getSize().y)*100.0f ); } SliderValueChangedEvent* e = new SliderValueChangedEvent; e->value = mValue; e->view = this; emitEvent(e); }
void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* self, LLPluginClassMediaOwner::EMediaEvent event) { switch(event) { case MEDIA_EVENT_PLUGIN_FAILED: { LLSD args; args["PLUGIN"] = LLMIMETypes::implType(mMimeType); LLNotifications::instance().add("MediaPluginFailed", args); } break; default: break; } // Just chain the event to observers. emitEvent(self, event); }
bool M4SCpWindow::saveToFile(const QString &fileName) { QFile fileOut(fileName); if (!fileOut.open(QFile::WriteOnly | QFile::Text)) { QMessageBox::warning(0, tr("error"), tr("Can't save file %1:\n%2.") .arg(fileName) .arg(fileOut.errorString())); return false; } QTextStream out(&fileOut); out << mEditor->document()->toPlainText(); fileOut.close(); mFileName = fileName; setWindowTitle(mFileName + "[*]"); mIsSaved = true; emitEvent(EditorObserverInterface::ContentSaved); return true; }
void DevicePluginLircd::buttonPressed(const QString &remoteName, const QString &buttonName, int repeat) { Device *remote = nullptr; QList<Device*> configuredRemotes = deviceManager()->findConfiguredDevices(lircdDeviceClassId); foreach (Device *device, configuredRemotes) { if (device->paramValue("remoteName").toString() == remoteName) { remote = device; break; } } if (!remote) { qCWarning(dcLircd) << "Unhandled remote" << remoteName << buttonName; return; } qCDebug(dcLircd) << "found remote" << remoteName << supportedDevices().first().eventTypes().count(); ParamList params; Param buttonParam("button", buttonName); params.append(buttonParam); Param repeatParam("repeat", repeat); params.append(repeatParam); Event event(LircKeypressEventTypeId, remote->id(), params); emitEvent(event); }
void M4SCpWindow::textChanged() { mIsSaved = false; emitEvent(EditorObserverInterface::ContentChanged); }
void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginClassMediaOwner::EMediaEvent event) { bool pass_through = true; switch(event) { case MEDIA_EVENT_CLICK_LINK_NOFOLLOW: { LL_DEBUGS("Media") << "MEDIA_EVENT_CLICK_LINK_NOFOLLOW, uri is: " << plugin->getClickURL() << LL_ENDL; std::string url = plugin->getClickURL(); LLURLDispatcher::dispatch(url, NULL, mTrustedBrowser); } break; case MEDIA_EVENT_CLICK_LINK_HREF: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CLICK_LINK_HREF, target is \"" << plugin->getClickTarget() << "\", uri is " << plugin->getClickURL() << LL_ENDL; }; break; case MEDIA_EVENT_PLUGIN_FAILED_LAUNCH: { // The plugin failed to load properly. Make sure the timer doesn't retry. // TODO: maybe mark this plugin as not loadable somehow? mMediaSourceFailed = true; // Reset the last known state of the media to defaults. resetPreviousMediaState(); // TODO: may want a different message for this case? LLSD args; args["PLUGIN"] = LLMIMETypes::implType(mCurrentMimeType); LLNotifications::instance().add("MediaPluginFailed", args); } break; case MEDIA_EVENT_PLUGIN_FAILED: { // The plugin crashed. mMediaSourceFailed = true; // Reset the last known state of the media to defaults. resetPreviousMediaState(); LLSD args; args["PLUGIN"] = LLMIMETypes::implType(mCurrentMimeType); // SJB: This is getting called every frame if the plugin fails to load, continuously respawining the alert! //LLNotificationsUtil::add("MediaPluginFailed", args); } break; case MEDIA_EVENT_CURSOR_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CURSOR_CHANGED, new cursor is " << plugin->getCursorName() << LL_ENDL; std::string cursor = plugin->getCursorName(); if(cursor == "arrow") mLastSetCursor = UI_CURSOR_ARROW; else if(cursor == "ibeam") mLastSetCursor = UI_CURSOR_IBEAM; else if(cursor == "splith") mLastSetCursor = UI_CURSOR_SIZEWE; else if(cursor == "splitv") mLastSetCursor = UI_CURSOR_SIZENS; else if(cursor == "hand") mLastSetCursor = UI_CURSOR_HAND; else // for anything else, default to the arrow mLastSetCursor = UI_CURSOR_ARROW; } break; case LLViewerMediaObserver::MEDIA_EVENT_NAVIGATE_BEGIN: { LL_DEBUGS("Media") << "MEDIA_EVENT_NAVIGATE_BEGIN, uri is: " << plugin->getNavigateURI() << LL_ENDL; if(getNavState() == MEDIANAVSTATE_SERVER_SENT) { setNavState(MEDIANAVSTATE_SERVER_BEGUN); } else { setNavState(MEDIANAVSTATE_BEGUN); } } break; case LLViewerMediaObserver::MEDIA_EVENT_NAVIGATE_COMPLETE: { LL_DEBUGS("Media") << "MEDIA_EVENT_NAVIGATE_COMPLETE, uri is: " << plugin->getNavigateURI() << LL_ENDL; std::string url = plugin->getNavigateURI(); if(getNavState() == MEDIANAVSTATE_BEGUN) { if(mCurrentMediaURL == url) { // This is a navigate that takes us to the same url as the previous navigate. setNavState(MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED_SPURIOUS); } else { mCurrentMediaURL = url; setNavState(MEDIANAVSTATE_COMPLETE_BEFORE_LOCATION_CHANGED); } } else if(getNavState() == MEDIANAVSTATE_SERVER_BEGUN) { mCurrentMediaURL = url; setNavState(MEDIANAVSTATE_SERVER_COMPLETE_BEFORE_LOCATION_CHANGED); } else { // all other cases need to leave the state alone. } } break; case LLViewerMediaObserver::MEDIA_EVENT_LOCATION_CHANGED: { LL_DEBUGS("Media") << "MEDIA_EVENT_LOCATION_CHANGED, uri is: " << plugin->getLocation() << LL_ENDL; std::string url = plugin->getLocation(); if(getNavState() == MEDIANAVSTATE_BEGUN) { if(mCurrentMediaURL == url) { // This is a navigate that takes us to the same url as the previous navigate. setNavState(MEDIANAVSTATE_FIRST_LOCATION_CHANGED_SPURIOUS); } else { mCurrentMediaURL = url; setNavState(MEDIANAVSTATE_FIRST_LOCATION_CHANGED); } } else if(getNavState() == MEDIANAVSTATE_SERVER_BEGUN) { mCurrentMediaURL = url; setNavState(MEDIANAVSTATE_SERVER_FIRST_LOCATION_CHANGED); } else { // Don't track redirects. setNavState(MEDIANAVSTATE_NONE); } } break; case LLViewerMediaObserver::MEDIA_EVENT_PICK_FILE_REQUEST: { // Display a file picker std::string response; LLFilePicker& picker = LLFilePicker::instance(); if (!picker.getOpenFile(LLFilePicker::FFLOAD_ALL)) { // The user didn't pick a file -- the empty response string will indicate this. } response = picker.getFirstFile(); plugin->sendPickFileResponse(response); } break; case LLViewerMediaObserver::MEDIA_EVENT_CLOSE_REQUEST: { std::string uuid = plugin->getClickUUID(); llinfos << "MEDIA_EVENT_CLOSE_REQUEST for uuid " << uuid << llendl; if(uuid.empty()) { // This close request is directed at this instance, let it fall through. } else { // This close request is directed at another instance pass_through = false; //TODO: LLFloaterMediaBrowser::closeRequest(uuid); } } break; case LLViewerMediaObserver::MEDIA_EVENT_GEOMETRY_CHANGE: { std::string uuid = plugin->getClickUUID(); llinfos << "MEDIA_EVENT_GEOMETRY_CHANGE for uuid " << uuid << llendl; if(uuid.empty()) { // This geometry change request is directed at this instance, let it fall through. } else { // This request is directed at another instance pass_through = false; //TODO: LLFloaterMediaBrowser::geometryChanged(uuid, plugin->getGeometryX(), plugin->getGeometryY(), plugin->getGeometryWidth(), plugin->getGeometryHeight()); } } break; default: break; } if(pass_through) { // Just chain the event to observers. emitEvent(plugin, event); } }
void Unit::update( const int& dt ) { DT = dt; if( isDeleted() ) return; // FIXME: move to prototypes if( Char.state.hp < 0 ){ extern LuaScript* luaScript; luaScript->push( std::string("die") ); emitEvent( luaScript->getState() ); if(isDeleted()) return; } if( dist( UnitManager::GetPlayer( ) ) > 2000 ){ return setDeleted(); } Actions.updateTimers( dt ); if( physBody ) Image.setPosition( (float)physBody->p.x, (float)physBody->p.y ); if( !Actions.loaded ) return; while( !Actions.nextFrame( ) ){ const Frame& frame = Actions.action->frames[Actions.frame]; if( frame.func != LUA_NOREF ){ extern LuaScript* luaScript; this->pushUData( luaScript->getState() ); int ret_val = luaScript->ExecChunkFromReg( frame.func, 1 ); if( ret_val == -1 ) { Debug::debug( Debug::PROTO, "An error occurred while executing a local function. Id: %d, proto_name '%s', action '%s', frame %d: %s.\n", UnitId, Actions.proto->name.c_str(), Action::getName(Actions.action->id).c_str(), Actions.frame, luaScript->getChar(-1) ); } for(int i = 0; i > ret_val; ++i ){ switch( luaScript->getType( 1 ) ){ case LUA_TNUMBER: Actions.params.Push( (int)luaScript->getNumber( 1 ) ); break; case LUA_TSTRING: Actions.params.Push( luaScript->getChar( 1 ) ); break; } } } // Make a pause on false result; if( !update( frame ) ) break; } }
bool Unit::update( const Frame& frame ) { const StackData& param = frame.params[0]; switch(frame.command){ case acNone: break; // Functions case acSuper: Actions.saveState( true ); Actions.setParentAction( param.intData ); break; case acRestoreState: // This is return for acSuper command. It does nothing if no saved state . Actions.restoreState(); break; case acSetAction: // If param is not null, it will be action call, not replacing if( Actions.checkFrameParams( frame, 1, stIntOrNone ) ){ Actions.setAction( param.intData ); return false; } break; case acSetTimer: if( Actions.checkFrameParams( frame, 3, stFunction, stInt, stIntOrNone ) ){ ActionTimer* timer = actionTimers; const Frame* pframe = &frame; while( timer != NULL ){ if( timer->frame == pframe ) break; timer = timer->next; } if( !timer || !Timer::UpdateEventById( timer->timerId, frame.params[1].intData) ){ if( timer ){ ActionTimer* oldtimer = actionTimers; while( timer != NULL ){ // ActionTimer is deleted from manager. Delete it from holder. if( oldtimer->next == timer ){ oldtimer->next = oldtimer->next->next; delete timer, timer = NULL; break; } timer = timer->next; } } int period = frame.params[1].intData; int calls = 1; if( Actions.checkFrameParams( frame, 2, stFunction, stInt ) ) calls = frame.params[2].intData; IActionTimer* t = new IActionTimer( this, param.intData ); actionTimers = new ActionTimer( pframe, t, actionTimers ); actionTimers->timerId = Timer::AddInternalTimerEvent( t, period, period, calls, (calls == 1) ? false : true, false ); } } break; case acBindEvent: if( Actions.checkFrameParams( frame, 2, stFunction, stTableOrNone ) ){ this->events.function = param.intData; this->events.self = frame.params[1].intData; } break; case acEmitEvent: extern LuaScript* luaScript; if( Actions.checkFrameParams( frame, 1, stString ) && this->events.function != LUA_NOREF ){ luaScript->push( param.stringData ); int ret_val = emitEvent( luaScript->getState() ); for(int i = 0; i < ret_val; ++i ){ switch( luaScript->getType( 1 ) ){ case LUA_TNUMBER: Actions.params.Push( (int)luaScript->getNumber( 1 ) ); break; case LUA_TSTRING: Actions.params.Push( luaScript->getChar( 1 ) ); break; } } } break; // Action parameters stack case acPushInt: Actions.params.Push( param.intData ); break; case acPushFloat: //TODO: float Actions.params.Push( param.intData ); Debug::debug( Debug::PROTO, "acPushFloat not implemented.\n" ); break; case acPushString: Actions.params.Push( param.stringData ); break; case acPush: for( int i = 0; i < FRAME_PARAMS_COUNT; ++i ){ switch( frame.param_types[i] ){ case stInt: Actions.params.Push( frame.params[i].intData ); break; case stString: Actions.params.Push( frame.params[i].stringData ); break; default: break; } } break; // Conditions case acCondition: // acCondition always false Actions.frame = frame.condition_end; break; case acEnd: // Do nothing break; case acIfParamEqual: PARAMCOND( != ) break; case acIfParamLess: PARAMCOND( > ) break; case acIfParamMore: PARAMCOND( < ) break; case acIfParametersEqual: PARAMSCOND( != ) break; case acIfParametersLess: PARAMSCOND( > ) break; case acIfParametersMore: PARAMSCOND( < ) break; case acIfParametersLessBy: PARAMSCOND( + param.intData > ) break; // Unit flags case acIfFlag: CHECKFLAG if( !( flags & param.intData ) ) Actions.frame = frame.condition_end; break; case acIfNotFlag: CHECKFLAG if( flags & param.intData ) Actions.frame = frame.condition_end; break; case acSetFlag: CHECKFLAG flags |= param.intData; break; case acRemoveFlag: CHECKFLAG flags &= ~param.intData; break; // Unit Parameters case acSetParam: if( Actions.checkFrameParams( frame, 2, stInt, stInt ) ) Char.set( param.intData, (float)frame.params[1].intData ); else Debug::debug( Debug::PROTO, "acSetParam bad parameter name.\n" ); break; case acCopyParam: if( !Actions.checkFrameParams( frame, 2, stInt, stInt ) ) Debug::debug( Debug::PROTO, "acCopyParam bad original parameter name.\n" ); else if( !param.intData ) Debug::debug( Debug::PROTO, "acCopyParam bad parameter name.\n" ); else Char.set( param.intData, Char.get( frame.params[1].intData ) ); break; case acLoadParam: { if( !Actions.checkFrameParams( frame, 2, stInt, stString ) ) break; LuaConfig* cfg = new LuaConfig; if( param.intData < uCharIntLast ) cfg->getValue( frame.params[1].stringData, UnitName.c_str(), TypeName.c_str(), Char.getRef( (enum character)param.intData ) ); else cfg->getValue( frame.params[1].stringData, UnitName.c_str(), TypeName.c_str(), Char.getRef( (enum character_float)param.intData ) ); delete cfg; break; } case acLoadParamBunch: { if( param.intData <= 0 ) break; LuaConfig* cfg = new LuaConfig; for( int i = 0; i < param.intData; i++ ){ if( !Actions.params.CheckParamTypes( 2, stInt, stString ) ){ Debug::debug( Debug::PROTO, "acLoadPraramBunch wrong %d parameter set.\n", i+1 ); continue; } int psparam = Actions.params.PopInt(); if( psparam < uCharIntLast ) cfg->getValue( Actions.params.PopString().c_str(), UnitName.c_str(), TypeName.c_str(), Char.getRef( (enum character)psparam ) ); else cfg->getValue( Actions.params.PopString().c_str(), UnitName.c_str(), TypeName.c_str(), Char.getRef( (enum character_float)psparam ) ); } delete cfg; break; } // Physics case acSetUnitPhysics: if( Actions.checkFrameParams( frame, 3, stInt, stInt, stIntOrNone ) ){ int firstparam = frame.params[1].intData; switch(param.intData){ case pptMat: break; case pptRadius: phys.radius = firstparam; break; case pptSides: phys.sides.x = firstparam; phys.sides.y = frame.params[2].intData; break; } phys.calc_mass(); updatePhysics( ); } break; case acSetPhysicsLayer: if( Actions.checkFrameParams( frame, 1, stInt ) && physShape != NULL ) cpShapeSetGroup( physShape, param.intData ); break; // Misc case acSetUnitSize: if( Actions.checkFrameParams( frame, 1, stInt ) ) setUnitSize( static_cast<float>(param.intData) / 100 ); break; case acSetColor: if( Actions.checkFrameParams( frame, 4, stInt, stInt, stInt, stInt ) ){ s4ub color( frame.params[0].intData, frame.params[1].intData, frame.params[2].intData, frame.params[3].intData); Image.getSprite()->brush.set_color( color ); } break; default: return false; } return true; }
//////////////////////////////////////////////////////////////////////////////// // inherited from LLViewerMediaObserver //virtual void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) { switch(event) { case MEDIA_EVENT_CONTENT_UPDATED: { // LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CONTENT_UPDATED " << LL_ENDL; }; break; case MEDIA_EVENT_TIME_DURATION_UPDATED: { // LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_TIME_DURATION_UPDATED, time is " << self->getCurrentTime() << " of " << self->getDuration() << LL_ENDL; }; break; case MEDIA_EVENT_SIZE_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_SIZE_CHANGED " << LL_ENDL; LLRect r = getRect(); reshape( r.getWidth(), r.getHeight(), FALSE ); }; break; case MEDIA_EVENT_CURSOR_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CURSOR_CHANGED, new cursor is " << self->getCursorName() << LL_ENDL; } break; case MEDIA_EVENT_NAVIGATE_BEGIN: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAVIGATE_BEGIN, url is " << self->getNavigateURI() << LL_ENDL; hideNotification(); }; break; case MEDIA_EVENT_NAVIGATE_COMPLETE: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAVIGATE_COMPLETE, result string is: " << self->getNavigateResultString() << LL_ENDL; if(mHidingInitialLoad) { mHidingInitialLoad = false; } }; break; case MEDIA_EVENT_PROGRESS_UPDATED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PROGRESS_UPDATED, loading at " << self->getProgressPercent() << "%" << LL_ENDL; }; break; case MEDIA_EVENT_STATUS_TEXT_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_STATUS_TEXT_CHANGED, new status text is: " << self->getStatusText() << LL_ENDL; }; break; case MEDIA_EVENT_LOCATION_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_LOCATION_CHANGED, new uri is: " << self->getLocation() << LL_ENDL; mCurrentNavUrl = self->getLocation(); }; break; case MEDIA_EVENT_NAVIGATE_ERROR_PAGE: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAVIGATE_ERROR_PAGE" << LL_ENDL; if ( mErrorPageURL.length() > 0 ) { navigateTo(mErrorPageURL, "text/html"); }; }; break; case MEDIA_EVENT_CLICK_LINK_HREF: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CLICK_LINK_HREF, target is \"" << self->getClickTarget() << "\", uri is " << self->getClickURL() << LL_ENDL; // retrieve the event parameters std::string url = self->getClickURL(); std::string target = self->getClickTarget(); std::string uuid = self->getClickUUID(); LLNotification::Params notify_params("PopupAttempt"); notify_params.payload = LLSD().with("target", target).with("url", url).with("uuid", uuid).with("media_id", mMediaTextureID); notify_params.functor(boost::bind(&LLMediaCtrl::onPopup, this, _1, _2)); if (mTrusted) { LLNotifications::instance().forceResponse(notify_params, 0); } else { LLNotifications::instance().add(notify_params); } break; }; case MEDIA_EVENT_CLICK_LINK_NOFOLLOW: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CLICK_LINK_NOFOLLOW, uri is " << self->getClickURL() << LL_ENDL; }; break; case MEDIA_EVENT_PLUGIN_FAILED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PLUGIN_FAILED" << LL_ENDL; }; break; case MEDIA_EVENT_PLUGIN_FAILED_LAUNCH: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PLUGIN_FAILED_LAUNCH" << LL_ENDL; }; break; case MEDIA_EVENT_NAME_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAME_CHANGED" << LL_ENDL; }; break; case MEDIA_EVENT_CLOSE_REQUEST: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CLOSE_REQUEST" << LL_ENDL; } break; case MEDIA_EVENT_PICK_FILE_REQUEST: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PICK_FILE_REQUEST" << LL_ENDL; } break; case MEDIA_EVENT_GEOMETRY_CHANGE: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_GEOMETRY_CHANGE, uuid is " << self->getClickUUID() << LL_ENDL; } break; case MEDIA_EVENT_AUTH_REQUEST: { LLNotification::Params auth_request_params("AuthRequest"); // pass in host name and realm for site (may be zero length but will always exist) LLSD args; LLURL raw_url( self->getAuthURL().c_str() ); args["HOST_NAME"] = raw_url.getAuthority(); args["REALM"] = self->getAuthRealm(); auth_request_params.substitutions = args; auth_request_params.payload = LLSD().with("media_id", mMediaTextureID); auth_request_params.functor(boost::bind(&LLViewerMedia::onAuthSubmit, _1, _2)); LLNotifications::instance().add(auth_request_params); }; break; case MEDIA_EVENT_LINK_HOVERED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_LINK_HOVERED, hover text is: " << self->getHoverText() << LL_ENDL; mHoverTextChanged = true; }; break; case MEDIA_EVENT_DEBUG_MESSAGE: { LL_INFOS("media") << self->getDebugMessageText() << LL_ENDL; }; break; default: { LL_WARNS("Media") << "Media event: unknown event type" << LL_ENDL; }; }; // chain all events to any potential observers of this object. emitEvent(self, event); }
void DevicePluginIntertechno::radioData(const QList<int> &rawData) { // filter right here a wrong signal length if(rawData.length() != 49){ return; } QList<Device*> deviceList = deviceManager()->findConfiguredDevices(intertechnoRemote); if(deviceList.isEmpty()){ return; } int delay = rawData.first()/31; QByteArray binCode; // ======================================= // average 314 if(delay > 300 && delay < 400){ // go trough all 48 timings (without sync signal) for(int i = 1; i <= 48; i+=2 ){ int div; int divNext; // if short if(rawData.at(i) <= 700){ div = 1; }else{ div = 3; } // if long if(rawData.at(i+1) < 700){ divNext = 1; }else{ divNext = 3; } // _ // if we have | |___ = 0 -> in 4 delays => 1000 // _ // if we have ___| | = 1 -> in 4 delays => 0001 if(div == 1 && divNext == 3){ binCode.append('0'); }else if(div == 3 && divNext == 1){ binCode.append('1'); }else{ return; } } }else{ return; } // ======================================= // Check nibble 16-19, must be 0001 if(binCode.mid(16,4) != "0001"){ return; } // ======================================= // Get family code QString familyCode; bool ok; QByteArray familyCodeBin = binCode.left(8); int famiyCodeInt = familyCodeBin.toInt(&ok,2); if(!ok){ return; } switch (famiyCodeInt) { case 0b00000000: familyCode = "A"; break; case 0b01000000: familyCode = "B"; break; case 0b00010000: familyCode = "C"; break; case 0b01010000: familyCode = "D"; break; case 0b00000100: familyCode = "E"; break; case 0b01000100: familyCode = "F"; break; case 0b00010100: familyCode = "G"; break; case 0b01010100: familyCode = "H"; break; case 0b00000001: familyCode = "I"; break; case 0b01000001: familyCode = "J"; break; case 0b00010001: familyCode = "K"; break; case 0b01010001: familyCode = "L"; break; case 0b00000101: familyCode = "M"; break; case 0b01000101: familyCode = "N"; break; case 0b00010101: familyCode = "O"; break; case 0b01010101: familyCode = "P"; break; default: return; } // ======================================= // Get button code QString buttonCode; QByteArray buttonCodeBin = binCode.mid(8,8); int buttonCodeInt = buttonCodeBin.toInt(&ok,2); if(!ok){ return; } switch (buttonCodeInt) { case 0b00000000: buttonCode = "1"; break; case 0b01000000: buttonCode = "2"; break; case 0b00010000: buttonCode = "3"; break; case 0b01010000: buttonCode = "4"; break; case 0b00000100: buttonCode = "5"; break; case 0b01000100: buttonCode = "6"; break; case 0b00010100: buttonCode = "7"; break; case 0b01010100: buttonCode = "8"; break; case 0b00000001: buttonCode = "9"; break; case 0b01000001: buttonCode = "10"; break; case 0b00010001: buttonCode = "11"; break; case 0b01010001: buttonCode = "12"; break; case 0b00000101: buttonCode = "13"; break; case 0b01000101: buttonCode = "14"; break; case 0b00010101: buttonCode = "15"; break; case 0b01010101: buttonCode = "16"; break; default: return; } // ======================================= // get power status -> On = 0100, Off = 0001 bool power; if(binCode.right(4).toInt(0,2) == 5){ power = true; }else if(binCode.right(4).toInt(0,2) == 4){ power = false; }else{ return; } qDebug() << "family code = " << familyCode << "button code =" << buttonCode << power; // =================================================== Device *device = 0; foreach (Device *dev, deviceList) { if (dev->paramValue("familyCode").toString() == familyCode) { // Yippie! We found the device. device = dev; break; } } if (!device) { qWarning() << "couldn't find any configured device for intertech familyCode:" << familyCode; return; } ParamList params; Param powerParam("power", power); params.append(powerParam); // FIXME: find a better way to get to the remote DeviceClass DeviceClass deviceClass = supportedDevices().first(); foreach (const EventType &eventType, deviceClass.eventTypes()) { if (eventType.name() == buttonCode) { qDebug() << "emit event " << pluginName() << familyCode << eventType.name() << power; Event event = Event(eventType.id(), device->id(), params); emit emitEvent(event); return; } } }
//////////////////////////////////////////////////////////////////////////////// // inherited from LLViewerMediaObserver //virtual void LLMediaCtrl::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent event) { switch(event) { case MEDIA_EVENT_CONTENT_UPDATED: { // LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CONTENT_UPDATED " << LL_ENDL; }; break; case MEDIA_EVENT_TIME_DURATION_UPDATED: { // LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_TIME_DURATION_UPDATED, time is " << self->getCurrentTime() << " of " << self->getDuration() << LL_ENDL; }; break; case MEDIA_EVENT_SIZE_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_SIZE_CHANGED " << LL_ENDL; LLRect r = getRect(); reshape( r.getWidth(), r.getHeight(), FALSE ); }; break; case MEDIA_EVENT_CURSOR_CHANGED: { LL_INFOS("Media") << "Media event: MEDIA_EVENT_CURSOR_CHANGED, new cursor is " << self->getCursorName() << LL_ENDL; std::string cursor = self->getCursorName(); if(cursor == "arrow") mLastSetCursor = UI_CURSOR_ARROW; else if(cursor == "ibeam") mLastSetCursor = UI_CURSOR_IBEAM; else if(cursor == "splith") mLastSetCursor = UI_CURSOR_SIZEWE; else if(cursor == "splitv") mLastSetCursor = UI_CURSOR_SIZENS; else if(cursor == "hand") mLastSetCursor = UI_CURSOR_HAND; else // for anything else, default to the arrow mLastSetCursor = UI_CURSOR_ARROW; }; break; case MEDIA_EVENT_NAVIGATE_BEGIN: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAVIGATE_BEGIN, url is " << self->getNavigateURI() << LL_ENDL; }; break; case MEDIA_EVENT_NAVIGATE_COMPLETE: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAVIGATE_COMPLETE, result string is: " << self->getNavigateResultString() << LL_ENDL; if(mHidingInitialLoad) { mHidingInitialLoad = false; } }; break; case MEDIA_EVENT_PROGRESS_UPDATED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PROGRESS_UPDATED, loading at " << self->getProgressPercent() << "%" << LL_ENDL; }; break; case MEDIA_EVENT_STATUS_TEXT_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_STATUS_TEXT_CHANGED, new status text is: " << self->getStatusText() << LL_ENDL; }; break; case MEDIA_EVENT_LOCATION_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_LOCATION_CHANGED, new uri is: " << self->getLocation() << LL_ENDL; }; break; case MEDIA_EVENT_NAVIGATE_ERROR_PAGE: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAVIGATE_ERROR_PAGE" << LL_ENDL; }; break; case MEDIA_EVENT_CLICK_LINK_HREF: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CLICK_LINK_HREF, target is \"" << self->getClickTarget() << "\", uri is " << self->getClickURL() << LL_ENDL; onClickLinkHref(self); }; break; case MEDIA_EVENT_CLICK_LINK_NOFOLLOW: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CLICK_LINK_NOFOLLOW, uri is " << self->getClickURL() << LL_ENDL; onClickLinkNoFollow(self); }; break; case MEDIA_EVENT_PLUGIN_FAILED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PLUGIN_FAILED" << LL_ENDL; }; break; case MEDIA_EVENT_PLUGIN_FAILED_LAUNCH: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PLUGIN_FAILED_LAUNCH" << LL_ENDL; }; break; case MEDIA_EVENT_NAME_CHANGED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_NAME_CHANGED" << LL_ENDL; }; break; case MEDIA_EVENT_CLOSE_REQUEST: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_CLOSE_REQUEST" << LL_ENDL; }; break; case MEDIA_EVENT_PICK_FILE_REQUEST: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_PICK_FILE_REQUEST" << LL_ENDL; }; break; case MEDIA_EVENT_GEOMETRY_CHANGE: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_GEOMETRY_CHANGE" << LL_ENDL; }; break; case MEDIA_EVENT_AUTH_REQUEST: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_AUTH_REQUEST" << LL_ENDL; }; break; case MEDIA_EVENT_LINK_HOVERED: { LL_DEBUGS("Media") << "Media event: MEDIA_EVENT_LINK_HOVERED" << LL_ENDL; }; break; case MEDIA_EVENT_DEBUG_MESSAGE: { LL_INFOS("media") << self->getDebugMessageText() << LL_ENDL; }; break; default: { LL_WARNS("Media") << "Media event: unknown event type" << LL_ENDL; }; }; // chain all events to any potential observers of this object. emitEvent(self, event); }
void EventFrame::onEnter(Frame *nextFrame) { emitEvent(); }
void FrequencyEstimator::emitTrigger() const { emitEvent(new TriggerEvent(this)); }
void Neuron::emitSpike() const { emitEvent(new SpikeEvent(this)); }
void ProbabilityEstimator::emitTrigger() const { emitEvent(new TriggerEvent(this)); }