void Camera::onMotionDelta(int x, int y) { mouseMove(x, y); }
void CSTimeInterface::mouseUp(Common::Point pos) { if (_options->getState()) { // TODO: options->mouseUp(pos); return; } if (!cursorGetState()) return; if (_state == kCSTimeInterfaceStateDragging) { stopDragging(); return; } if (_state == kCSTimeInterfaceStateDragStart) _state = kCSTimeInterfaceStateNormal; switch (cursorGetShape()) { case 4: cursorChangeShape(1); break; case 5: cursorChangeShape(2); break; case 14: cursorChangeShape(13); break; } if (_vm->getCase()->getCurrScene()->eventIsActive()) { if (_vm->getCurrentEventType() == kCSTimeEventWaitForClick) _vm->mouseClicked(); return; } if (_book->getState() == 2) { // TODO: _book->mouseUp(pos); return; } if (_note->getState() == 2) { _note->closeNote(); mouseMove(pos); return; } // TODO: if in sailing puzzle, sailing puzzle mouse up, return // TODO: case 20 ui craziness is handled seperately.. if (_sceneRect.contains(pos)) { _vm->getCase()->getCurrScene()->mouseUp(pos); return; } if (_vm->getCase()->getCurrConversation()->getState() != (uint)~0) { _vm->getCase()->getCurrConversation()->mouseUp(pos); return; } if (_help->getState() != (uint)~0) { _help->mouseUp(pos); return; } // TODO: handle symbols if (_bookRect.contains(pos)) { // TODO: handle flashing cuffs // TODO: _book->open(); return; } if (_noteRect.contains(pos)) { // TODO: special-casing for case 19 if (_note->havePiece(0xffff)) _note->drawBigNote(); } if (_inventoryDisplay->_invRect.contains(pos)) { // TODO: special-casing for case 6 _inventoryDisplay->mouseUp(pos); } }
void myHistRect::mouseMoveEvent( QGraphicsSceneMouseEvent * event ) { emit mouseMove(event); }
int SDLApp::run() { Uint32 msec=0, last_msec=0, buffer_msec=0, total_msec = 0; frame_count = 0; fps_updater = 0; if(!appFinished) init(); msec = SDL_GetTicks(); last_msec = msec; while(!appFinished) { last_msec = msec; msec = SDL_GetTicks(); Uint32 delta_msec = msec - last_msec; // cant have delta ticks be 0 buffer_msec += delta_msec; if(buffer_msec < 1) { SDL_Delay(1); continue; } delta_msec = buffer_msec; buffer_msec =0; //determine time elapsed since last time we were here total_msec += delta_msec; float t = total_msec / 1000.0f; float dt = delta_msec / 1000.0f; fps_updater += delta_msec; //update framerate if a second has passed if (fps_updater >= 1000) { updateFramerate(); } //process new events SDL_Event event; while ( SDL_PollEvent(&event) ) { switch(event.type) { case SDL_QUIT: appFinished=true; break; case SDL_MOUSEMOTION: mouseMove(&event.motion); break; case SDL_MOUSEBUTTONDOWN: mouseClick(&event.button); break; case SDL_MOUSEBUTTONUP: mouseClick(&event.button); break; case SDL_KEYDOWN: keyPress(&event.key); break; case SDL_KEYUP: keyPress(&event.key); break; default: break; } } update(t, dt); #ifndef TEXT_ONLY //update display display.update(); #endif frame_count++; } return return_code; }
void CustomPaintWidget::mouseMoveEvent(QMouseEvent *e) { emit mouseMove(e); }
void MediaPluginGStreamer010::receiveMessage(const char *message_string) { //std::cerr << "MediaPluginGStreamer010::receiveMessage: received message: \"" << message_string << "\"" << std::endl; LLPluginMessage message_in; if(message_in.parse(message_string) >= 0) { std::string message_class = message_in.getClass(); std::string message_name = message_in.getName(); if(message_class == LLPLUGIN_MESSAGE_CLASS_BASE) { if(message_name == "init") { LLPluginMessage message("base", "init_response"); LLSD versions = LLSD::emptyMap(); versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME] = LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME_VERSION; message.setValueLLSD("versions", versions); if ( load() ) { DEBUGMSG("GStreamer010 media instance set up"); } else { WARNMSG("GStreamer010 media instance failed to set up"); } message.setValue("plugin_version", getVersion()); sendMessage(message); } else if(message_name == "idle") { // no response is necessary here. double time = message_in.getValueReal("time"); // Convert time to milliseconds for update() update((int)(time * 1000.0f)); if(GST_STATE(mPlaybin) == GST_STATE_PLAYING) { // update the current playback time if(update_counter == 10) { updateTime(); update_counter = 0; } update_counter++; } } else if(message_name == "cleanup") { unload(); closedown(); } else if(message_name == "shm_added") { SharedSegmentInfo info; info.mAddress = message_in.getValuePointer("address"); info.mSize = (size_t)message_in.getValueS32("size"); std::string name = message_in.getValue("name"); std::ostringstream str; INFOMSG("MediaPluginGStreamer010::receiveMessage: shared memory added, name: %s, size: %d, address: %p", name.c_str(), int(info.mSize), info.mAddress); mSharedSegments.insert(SharedSegmentMap::value_type(name, info)); } else if(message_name == "shm_remove") { std::string name = message_in.getValue("name"); DEBUGMSG("MediaPluginGStreamer010::receiveMessage: shared memory remove, name = %s", name.c_str()); SharedSegmentMap::iterator iter = mSharedSegments.find(name); if(iter != mSharedSegments.end()) { if(mPixels == iter->second.mAddress) { // This is the currently active pixel buffer. Make sure we stop drawing to it. mPixels = NULL; mTextureSegmentName.clear(); // Make sure the movie decoder is no longer pointed at the shared segment. sizeChanged(); } mSharedSegments.erase(iter); } else { WARNMSG("MediaPluginGStreamer010::receiveMessage: unknown shared memory region!"); } // Send the response so it can be cleaned up. LLPluginMessage message("base", "shm_remove_response"); message.setValue("name", name); sendMessage(message); } else { std::ostringstream str; INFOMSG("MediaPluginGStreamer010::receiveMessage: unknown base message: %s", message_name.c_str()); } } else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA) { if(message_name == "init") { // Plugin gets to decide the texture parameters to use. LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params"); // lame to have to decide this now, it depends on the movie. Oh well. mDepth = 4; mCurrentWidth = 1; mCurrentHeight = 1; mPreviousWidth = 1; mPreviousHeight = 1; mNaturalWidth = 1; mNaturalHeight = 1; mWidth = 1; mHeight = 1; mTextureWidth = 1; mTextureHeight = 1; message.setValueU32("format", GL_RGBA); message.setValueU32("type", GL_UNSIGNED_INT_8_8_8_8_REV); message.setValueS32("depth", mDepth); message.setValueS32("default_width", mWidth); message.setValueS32("default_height", mHeight); message.setValueU32("internalformat", GL_RGBA8); message.setValueBoolean("coords_opengl", true); // true == use OpenGL-style coordinates, false == (0,0) is upper left. message.setValueBoolean("allow_downsample", true); // we respond with grace and performance if asked to downscale sendMessage(message); } else if(message_name == "size_change") { std::string name = message_in.getValue("name"); S32 width = message_in.getValueS32("width"); S32 height = message_in.getValueS32("height"); S32 texture_width = message_in.getValueS32("texture_width"); S32 texture_height = message_in.getValueS32("texture_height"); std::ostringstream str; INFOMSG("---->Got size change instruction from application with shm name: %s - size is %d x %d", name.c_str(), width, height); LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response"); message.setValue("name", name); message.setValueS32("width", width); message.setValueS32("height", height); message.setValueS32("texture_width", texture_width); message.setValueS32("texture_height", texture_height); sendMessage(message); if(!name.empty()) { // Find the shared memory region with this name SharedSegmentMap::iterator iter = mSharedSegments.find(name); if(iter != mSharedSegments.end()) { INFOMSG("*** Got size change with matching shm, new size is %d x %d", width, height); INFOMSG("*** Got size change with matching shm, texture size size is %d x %d", texture_width, texture_height); mPixels = (unsigned char*)iter->second.mAddress; mTextureSegmentName = name; mWidth = width; mHeight = height; if (texture_width > 1 || texture_height > 1) // not a dummy size from the app, a real explicit forced size { INFOMSG("**** = REAL RESIZE REQUEST FROM APP"); GST_OBJECT_LOCK(mVideoSink); mVideoSink->resize_forced_always = true; mVideoSink->resize_try_width = texture_width; mVideoSink->resize_try_height = texture_height; GST_OBJECT_UNLOCK(mVideoSink); } mTextureWidth = texture_width; mTextureHeight = texture_height; } } } else if(message_name == "load_uri") { std::string uri = message_in.getValue("uri"); navigateTo( uri ); sendStatus(); } else if(message_name == "mouse_event") { std::string event = message_in.getValue("event"); S32 x = message_in.getValueS32("x"); S32 y = message_in.getValueS32("y"); if(event == "down") { mouseDown(x, y); } else if(event == "up") { mouseUp(x, y); } else if(event == "move") { mouseMove(x, y); }; }; } else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME) { if(message_name == "stop") { stop(); } else if(message_name == "start") { double rate = 0.0; if(message_in.hasValue("rate")) { rate = message_in.getValueReal("rate"); } // NOTE: we don't actually support rate. play(rate); } else if(message_name == "pause") { pause(); } else if(message_name == "seek") { double time = message_in.getValueReal("time"); // defer the actual seek in case we haven't // really truly started yet in which case there // is nothing to seek upon mSeekWanted = true; mSeekDestination = time; } else if(message_name == "set_loop") { bool loop = message_in.getValueBoolean("loop"); mIsLooping = loop; } else if(message_name == "set_volume") { double volume = message_in.getValueReal("volume"); setVolume(volume); } } else { INFOMSG("MediaPluginGStreamer010::receiveMessage: unknown message class: %s", message_class.c_str()); } } }
void DemoMediaPlugin::receiveMessage(const char *message_string) { // std::cerr << "DemoMediaPlugin::receiveMessage: received message: \"" << message_string << "\"" << std::endl; LLPluginMessage message_in; if(message_in.parse(message_string) >= 0) { std::string message_class = message_in.getClass(); std::string message_name = message_in.getName(); if(message_class == LLPLUGIN_MESSAGE_CLASS_BASE) { if(message_name == "init") { LLPluginMessage message("base", "init_response"); LLSD versions = LLSD::emptyMap(); versions[LLPLUGIN_MESSAGE_CLASS_BASE] = LLPLUGIN_MESSAGE_CLASS_BASE_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA] = LLPLUGIN_MESSAGE_CLASS_MEDIA_VERSION; // Normally a plugin would only specify one of these two subclasses, but this is a demo... versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER] = LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER_VERSION; versions[LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME] = LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME_VERSION; message.setValueLLSD("versions", versions); sendMessage(message); // Plugin gets to decide the texture parameters to use. mDepth = 3; message.setMessage(LLPLUGIN_MESSAGE_CLASS_MEDIA, "texture_params"); message.setValueS32("depth", mDepth); message.setValueU32("internalformat", GL_RGB); message.setValueU32("format", GL_RGB); message.setValueU32("type", GL_UNSIGNED_BYTE); message.setValueBoolean("coords_opengl", false); // true == use OpenGL-style coordinates, false == (0,0) is upper left. sendMessage(message); } else if(message_name == "idle") { // no response is necessary here. update(); } else if(message_name == "shutdown") { sendMessage(LLPluginMessage("base", "shutdown_response")); mDeleteMe = true; } else if(message_name == "shm_added") { SharedSegmentInfo info; info.mAddress = (void*)message_in.getValueU32("address"); info.mSize = (size_t)message_in.getValueS32("size"); std::string name = message_in.getValue("name"); std::cerr << "DemoMediaPlugin::receiveMessage: shared memory added, name: " << name << ", size: " << info.mSize << ", address: " << info.mAddress << std::endl; mSharedSegments.insert(SharedSegmentMap::value_type(name, info)); } else if(message_name == "shm_remove") { std::string name = message_in.getValue("name"); std::cerr << "DemoMediaPlugin::receiveMessage: shared memory remove, name = " << name << std::endl; SharedSegmentMap::iterator iter = mSharedSegments.find(name); if(iter != mSharedSegments.end()) { if(mPixels == iter->second.mAddress) { // This is the currently active pixel buffer. Make sure we stop drawing to it. mPixels = NULL; } mSharedSegments.erase(iter); } else { std::cerr << "DemoMediaPlugin::receiveMessage: unknown shared memory region!" << std::endl; } // Send the response so it can be cleaned up. LLPluginMessage message("base", "shm_remove_response"); message.setValue("name", name); sendMessage(message); } else { std::cerr << "DemoMediaPlugin::receiveMessage: unknown base message: " << message_name << std::endl; } } else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA) { if(message_name == "size_change") { std::string name = message_in.getValue("name"); S32 width = message_in.getValueS32("width"); S32 height = message_in.getValueS32("height"); S32 texture_width = message_in.getValueS32("texture_width"); S32 texture_height = message_in.getValueS32("texture_height"); LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA, "size_change_response"); message.setValue("name", name); message.setValueS32("width", width); message.setValueS32("height", height); message.setValueS32("texture_width", texture_width); message.setValueS32("texture_height", texture_height); sendMessage(message); if(!name.empty()) { // Find the shared memory region with this name SharedSegmentMap::iterator iter = mSharedSegments.find(name); if(iter != mSharedSegments.end()) { std::cerr << "Got size change, new size is " << width << " by " << height << std::endl; std::cerr << " texture size is " << texture_width << " by " << texture_height << std::endl; mPixels = (unsigned char*)iter->second.mAddress; mWidth = width; mHeight = height; mTextureWidth = texture_width; mTextureHeight = texture_height; clear(); } } } else if(message_name == "mouse_event") { std::string event = message_in.getValue("event"); S32 x = message_in.getValueS32("x"); S32 y = message_in.getValueS32("y"); // std::string modifiers = message.getValue("modifiers"); // std::cerr << "DemoMediaPlugin::receiveMessage: mouse event \"" << event // << "\", coords " << x << ", " << y // << std::endl; if(event == "down") { mouseDown(x, y); } else if(event == "up") { mouseUp(x, y); } else if(event == "move") { mouseMove(x, y); } } else { std::cerr << "DemoMediaPlugin::receiveMessage: unknown media message: " << message_string << std::endl; } } else if(message_class == LLPLUGIN_MESSAGE_CLASS_MEDIA_BROWSER) { if(message_name == "focus") { // foo = message_in.getValueBoolean("focused"); } else if(message_name == "clear_cache") { } else if(message_name == "clear_cookies") { } else if(message_name == "enable_cookies") { // foo = message_in.getValueBoolean("enable"); } else if(message_name == "proxy_setup") { // foo = message_in.getValueBoolean("enable"); // bar = message_in.getValue("host"); // baz = message_in.getValueS32("port"); } else if(message_name == "browse_stop") { } else if(message_name == "browse_reload") { // foo = message_in.getValueBoolean("ignore_cache"); } else if(message_name == "browse_forward") { } else if(message_name == "browse_back") { } else if(message_name == "set_status_redirect") { // foo = message_in.getValueS32("code"); // bar = message_in.getValue("url"); } else { std::cerr << "DemoMediaPlugin::receiveMessage: unknown media_browser message: " << message_string << std::endl; } } else { std::cerr << "DemoMediaPlugin::receiveMessage: unknown message class: " << message_class << std::endl; } } }