Example #1
0
CServerProxy::EResult
CServerProxy::parseMessage(const UInt8* code)
{
	if (memcmp(code, kMsgDMouseMove, 4) == 0) {
		mouseMove();
	}

	else if (memcmp(code, kMsgDMouseRelMove, 4) == 0) {
		mouseRelativeMove();
	}

	else if (memcmp(code, kMsgDMouseWheel, 4) == 0) {
		mouseWheel();
	}

	else if (memcmp(code, kMsgDKeyDown, 4) == 0) {
		keyDown();
	}

	else if (memcmp(code, kMsgDKeyUp, 4) == 0) {
		keyUp();
	}

	else if (memcmp(code, kMsgDMouseDown, 4) == 0) {
		mouseDown();
	}

	else if (memcmp(code, kMsgDMouseUp, 4) == 0) {
		mouseUp();
	}

	else if (memcmp(code, kMsgDKeyRepeat, 4) == 0) {
		keyRepeat();
	}

	else if (memcmp(code, kMsgCKeepAlive, 4) == 0) {
		// echo keep alives and reset alarm
		CProtocolUtil::writef(m_stream, kMsgCKeepAlive);
		resetKeepAliveAlarm();
	}

	else if (memcmp(code, kMsgCNoop, 4) == 0) {
		// accept and discard no-op
	}

	else if (memcmp(code, kMsgCEnter, 4) == 0) {
		enter();
	}

	else if (memcmp(code, kMsgCLeave, 4) == 0) {
		leave();
	}

	else if (memcmp(code, kMsgCClipboard, 4) == 0) {
		grabClipboard();
	}

	else if (memcmp(code, kMsgCScreenSaver, 4) == 0) {
		screensaver();
	}

	else if (memcmp(code, kMsgQInfo, 4) == 0) {
		queryInfo();
	}

	else if (memcmp(code, kMsgCInfoAck, 4) == 0) {
		infoAcknowledgment();
	}

	else if (memcmp(code, kMsgDClipboard, 4) == 0) {
		setClipboard();
	}

	else if (memcmp(code, kMsgCResetOptions, 4) == 0) {
		resetOptions();
	}

	else if (memcmp(code, kMsgDSetOptions, 4) == 0) {
		setOptions();
	}

	else if (memcmp(code, kMsgDGameButtons, 4) == 0) {
		gameDeviceButtons();
	}

	else if (memcmp(code, kMsgDGameSticks, 4) == 0) {
		gameDeviceSticks();
	}

	else if (memcmp(code, kMsgDGameTriggers, 4) == 0) {
		gameDeviceTriggers();
	}

	else if (memcmp(code, kMsgCGameTimingReq, 4) == 0) {
		gameDeviceTimingReq();
	}

	else if (memcmp(code, kMsgCClose, 4) == 0) {
		// server wants us to hangup
		LOG((CLOG_DEBUG1 "recv close"));
		m_client->disconnect(NULL);
		return kDisconnect;
	}
	else if (memcmp(code, kMsgEBad, 4) == 0) {
		LOG((CLOG_ERR "server disconnected due to a protocol error"));
		m_client->disconnect("server reported a protocol error");
		return kDisconnect;
	}
	else {
		return kUnknown;
	}

	// send a reply.  this is intended to work around a delay when
	// running a linux server and an OS X (any BSD?) client.  the
	// client waits to send an ACK (if the system control flag
	// net.inet.tcp.delayed_ack is 1) in hopes of piggybacking it
	// on a data packet.  we provide that packet here.  i don't
	// know why a delayed ACK should cause the server to wait since
	// TCP_NODELAY is enabled.
	CProtocolUtil::writef(m_stream, kMsgCNoop);

	return kOkay;
}
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));
			}
			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());
		}
	}
}
Example #3
0
int main(int argc, char **argv) {

    //////////////////////////////////////////////////////////////////////
    // check joystick
    //////////////////////////////////////////////////////////////////////

    std::string commandNoJoystick = std::string(argv[0]) +  " --no-joystick ";
    Herve::utilInfo("to disable joystick, use : ", commandNoJoystick.c_str() , __FILE__, __LINE__);
    if (argc == 2 and std::string(argv[1]) == "--no-joystick")
        gEnableJoystick = false;

    //////////////////////////////////////////////////////////////////////
    // init
    //////////////////////////////////////////////////////////////////////

    // display device
    gUptrDisplayDevice.reset(new HerveOvr::DisplayDeviceStereoOvr(1024, 1024));
    if (not gUptrDisplayDevice->initDevice()) {
        gUptrDisplayDevice.reset(new Herve::DisplayDeviceMono());
        //gUptrDisplayDevice.reset(new Herve::DisplayDeviceStereoFake(1024, 1024));
        gUptrDisplayDevice->initDevice();
    }

    // SDL
    if( SDL_Init( SDL_INIT_EVERYTHING ) < 0 )
        Herve::utilError("SDL_Init", "", __FILE__, __LINE__);
    const SDL_VideoInfo* info = SDL_GetVideoInfo();
    int maxWidth = info->current_w;
    int maxHeight = info->current_h;
    SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
    gPtrSurface = SDL_SetVideoMode( gUptrDisplayDevice->getWidth(), gUptrDisplayDevice->getHeight(), 24, SDL_OPENGL|SDL_RESIZABLE );
    if( gPtrSurface == NULL )
        Herve::utilError("SDL_SetVideoMode", "", __FILE__, __LINE__);
    atexit(SDL_Quit);
    SDL_EnableUNICODE( SDL_TRUE );
    SDL_WM_SetCaption( "DemoSdl1", NULL );

    // joysticks
    int nbJoysticks = SDL_NumJoysticks();
    for(int i=0; i<nbJoysticks; i++) {
        SDL_Joystick * stick = SDL_JoystickOpen( i );
        if( stick ) {
            Herve::utilInfo("joystick = ", SDL_JoystickName(i), __FILE__, __LINE__);
        }
    }

    // scene data
    gUptrDisplayDevice->initDisplay(maxWidth, maxHeight);
    gScene.init(gUptrDisplayDevice.get());
    gFpsCounter.start();

    Herve::utilInfo("width = ", std::to_string(gUptrDisplayDevice->getWidth()).c_str(), __FILE__, __LINE__);
    Herve::utilInfo("height = ", std::to_string(gUptrDisplayDevice->getHeight()).c_str(), __FILE__, __LINE__);
    Herve::utilInfo("maxWidth = ", std::to_string(gUptrDisplayDevice->getMaxWidth()).c_str(), __FILE__, __LINE__);
    Herve::utilInfo("maxHeight = ", std::to_string(gUptrDisplayDevice->getMaxHeight()).c_str(), __FILE__, __LINE__);


    //////////////////////////////////////////////////////////////////////
    // main loop
    //////////////////////////////////////////////////////////////////////

    SDL_Event event;
    while (true)	{
        // handle events
        while( SDL_PollEvent( &event ) ) {
            switch(event.type) {
            case SDL_QUIT:
                exit(0);
                break;
            case SDL_KEYDOWN:
                keyDown(event.key);
                break;
            case SDL_KEYUP:
                keyUp(event.key);
                break;
            case SDL_MOUSEBUTTONUP :
                mouseUp(event.button);
                break;
            case SDL_MOUSEBUTTONDOWN :
                mouseDown(event.button);
                break;
            case SDL_MOUSEMOTION :
                mouseMotion(event.motion);
                break;
            case SDL_VIDEORESIZE :
                resize(event.resize);
                break;
            case SDL_JOYAXISMOTION :
                joyMotion(event.jaxis);
                break;
            }
        }

        updateCamera();
        render();
    }

    return 0;
}
Example #4
0
static int onLBUTTONDOWN(HWND win, BOOL dbl, int x, int y, UINT flacv) {
        return mouseDown(win, CVK_MOUSELEFT);
}
Example #5
0
/**
* The 'delta' version of the click and drag command. This function moves an xy
* distance from a startpoint. This distance is 'wrapping', so if it is outside 
* of the window, we mouseup, return to the start position, mousedown, and then
* move again. We give a one pixel border at each side of the window and clamp 
* using that value to avoid accidental resizing.
*/
bool clickAndDragDelta(std::string window_name, nlohmann::json action){
  //get the values of the student's window.
  int x_start, x_end, y_start, y_end, mouse_button; 
  bool no_clamp = false; 
  bool success = populateClickAndDragValues(action, window_name, x_start, 
                      x_end, y_start, y_end, mouse_button, no_clamp);
  
  //if we can't populate the click and drag values, do nothing.
  if(!success){ 
    std::cout << "Could not populate the click and drag values."<< std::endl;
    return false;
  }
  
  //Define the corners of our window. (We use vectors as 2d points.)
  std::vector<int> upper_left, upper_right, lower_left, lower_right; 
  upper_left.push_back(x_start); upper_left.push_back(y_start);
  upper_right.push_back(x_end); upper_right.push_back(y_start);
  lower_left.push_back(x_start); lower_left.push_back(y_end);
  lower_right.push_back(x_end); lower_right.push_back(y_end);

  
  //delta version, 2 values movement x and movement y.
  int amt_x_movement_remaining = action.value("x_distance", 0);
  int amt_y_movement_remaining = action.value("y_distance", 0);
  std::string start_location   = action.value("start_location", "center");

  //This shouldn't fail unless there isn't a mouse.
  std::string mouse_location_string = output_of_system_command("xdotool getmouselocation"); 
  std::vector<int> xy = extractIntsFromString(mouse_location_string);                      
  
  //if the mouse isn't detected, fail.
  if(xy.size() < 2){ 
    std::cout << "Mouse coordinates couldn't be found. Mouse undetected." 
                << std::endl;
    return false;
  }
  //get the current mouse location
  int start_mouse_x = xy[0];
  int start_mouse_y = xy[1];
  //clamp the mouse within the screen (and move in by a pixel).
  clamp(start_mouse_x, x_start+1, x_end-1); 
  clamp(start_mouse_y, y_start+1, y_end-1);

  //get the center of the window
  int width  = x_end - x_start;
  int height = y_end - y_start;
  int x_middle = x_start + (width/2);
  int y_middle = y_start+(height/2);

  //NOTE: check my arithmetic. 
  /**
  * The process that this algorithm goes through is as follows:
  * 1) Determine the slope of the dragged line and its distance.
  * 2) while we have not traversed the necessary distance
  * 3) project a line from the current mouse position towards the end 
  *      position with length equal to the remaining distance. 
  * 4) Now that we have a line segment defined, find where/if it intersects
  *      any of the window's edges
  * 5) if it does intersect, cut it off at the point of intersection, and only
  *      drag that far. Else, if it doesn't intersect, we can assume we are 
  *      inside of the window, due to the clamp, and can drag.
  * 6) update remaining distance and continue to loop.
  */

  //rise / run
  float slope=(float)amt_y_movement_remaining/(float)amt_x_movement_remaining;
  float total_distance_needed = sqrt(pow(amt_x_movement_remaining, 2) 
                                    + pow (amt_y_movement_remaining, 2)); 

  //remaining distance needed.
  float remaining_distance_needed = total_distance_needed; 

  int action_start_x = (start_location == "current") ? start_mouse_x : x_middle;
  int action_start_y = (start_location == "current") ? start_mouse_y : y_middle;

  std::cout << "start x " << start_mouse_x << " our x " << action_start_x;
  std::cout << "start y " << start_mouse_y << " our y " << action_start_y;

  //The functions called within this loop will not fire if the window doesn't 
  // exist. This check just short circuits to avoid additional printing.
  while(remaining_distance_needed >= 1 && windowExists(window_name)){ 
    int curr_x = action_start_x;                                             
    int curr_y = action_start_y;                                              
    int moved_mouse_x, moved_mouse_y;
    //reset the mouse to the start location.
    mouse_move(window_name, action_start_x, action_start_y, x_start, x_end, y_start, y_end,
                                                                        false); 
    //determine how far we've come.
    float fraction_of_distance_remaining = remaining_distance_needed 
                                            / total_distance_needed; 
    //project in the direction of the move to find the end of our line segment.
    float projected_x = action_start_x + (amt_x_movement_remaining * fraction_of_distance_remaining); 
    float projected_y = action_start_y + (amt_y_movement_remaining * fraction_of_distance_remaining);  

    //we are using vectors as 2d points.
    std::vector<int> current_point, projected_point;  
    current_point.push_back(curr_x); current_point.push_back(curr_y);
    projected_point.push_back(projected_x); 
    projected_point.push_back(projected_y);

    std::vector<float> intersection_point; 
    intersection_point=getLineIntersectionPoint(current_point,projected_point,
                                                      upper_left, upper_right);
    

    /**
    * TODO make this block smaller. 
    * These if statements just test all edges of the window against our 
    * projected line.
    */

    //found is just a quick short-circuit to keep the code from ballooning.
    bool found = false; 
    if(intersection_point.size() != 0){ //TOP
      std::cout << "intersected top" << std::endl;
      moved_mouse_x = (int)intersection_point[0]; 
      moved_mouse_y = (int)intersection_point[1];
      found = true;
    }

    if(!found) //RIGHT
    {
      intersection_point = getLineIntersectionPoint(current_point, 
                            projected_point, upper_right, lower_right);
      if(intersection_point.size() != 0){ 
        std::cout << "intersected right" << std::endl;
        moved_mouse_x = (int)intersection_point[0]; 
        moved_mouse_y = (int)intersection_point[1];
        found = true;
      }
    }

    if(!found) //BOTTOM
    {
      intersection_point = getLineIntersectionPoint(current_point, 
                              projected_point, lower_right, lower_left);
      if(intersection_point.size() != 0){
        std::cout << "intersected bottom" << std::endl;
        moved_mouse_x = (int)intersection_point[0]; 
        moved_mouse_y = (int)intersection_point[1];
        found = true;
      }
    }

    if(!found) //LEFT
    {
      intersection_point = getLineIntersectionPoint(current_point,
                             projected_point, lower_left, upper_left);
      if(intersection_point.size() != 0){
        std::cout << "intersected left" << std::endl;
        moved_mouse_x = (int)intersection_point[0]; 
        moved_mouse_y = (int)intersection_point[1];
        found = true;
      }
    }

    //if we didn't intersect, we are inside of the box (guaranteed by clamp)
    // so we can move freely.
    if(!found) 
    {
      std::cout << "No intersection at all"<< std::endl;
      moved_mouse_x = projected_x;
      moved_mouse_y = projected_y;
    }

    //the distance we can move
    float distance_of_move = sqrt(pow(moved_mouse_x - action_start_x, 2) 
                                    + pow (moved_mouse_y - action_start_y, 2)); 
    //we are moving distance_of_move
    remaining_distance_needed -= distance_of_move; 
    std::cout << "after the move, we had " << remaining_distance_needed 
                                          << " distance left " << std::endl;
    mouseDown(window_name,mouse_button); //click
    mouse_move(window_name, moved_mouse_x, moved_mouse_y,x_start, x_end, //drag
                                                        y_start, y_end, false); 
    mouseUp(window_name,mouse_button); //release
  } //end loop.

  //to preserve backwards compatibility.
  if(start_location != "current"){
    //put the mouse back where we found it.
    mouse_move(window_name, start_mouse_x, start_mouse_y, x_start, x_end, y_start, y_end,false);
  }

  return true;
}
Example #6
0
File: win.c Project: jacereda/glcv
static int onRBUTTONDOWN(HWND win, BOOL dbl, int x, int y, UINT flacv) {
        return mouseDown(CVK_MOUSERIGHT);
}
void FboMaskManager::mousePressed(ofMouseEventArgs &e){
	mouseDown(e.x, e.y);
}	
Example #8
0
/*********************************************
		per-frame logic goes here
**********************************************/
void App::updateMain(){

	//Get the mouse pointer pos in screen space
	SDL_GetMouseState(&iMouseX, &iMouseY); 
	
	//Throw away any bad frames
	if(fTimeScale == infinity || fTimeScale == 0.0f){
		return;
	}
	
	float fCamSpeed = fTimeScale * 10.0f;
	float fDragScale = 0.05f;

	if (!this->bGlobalDisableKeyMovement) {

		//Right button means we reset rotation and such
		//NOTE: I did have this as 'both left and right at once', which seemed
		//to make more sense, but it doesn't work great on systems that map this
		//to middle-mouse		
		if(mouseDown(3)){
			resetCam();
		}

		//Rotation for the wall
		/*
		float camTime = fUptime * 0.1f;

		float fRotateSpeed = fCamSpeed;
		fRot[1] += fRotateSpeed;
		fRot[0] = (sinf(camTime) * 5);
		fCameraY = cosf(camTime) * 5;
		
		fZoom = (sinf(camTime) * 15) + 27;
		*/
			
		//LOG("%f, %f\n", fRot[1], fZoom);
		
		//fZoom = -10;
		
		//Keyboard rotation
		if(keyDown(SDLK_RSHIFT) || keyDown(SDLK_LSHIFT)){
			fCamSpeed *= 10;
		}
		
		if(keyDown(SDLK_LEFT))	fRot[1] -= fCamSpeed;
		if(keyDown(SDLK_RIGHT))	fRot[1] += fCamSpeed;
		if(keyDown(SDLK_UP))	fRot[0] -= fCamSpeed;
		if(keyDown(SDLK_DOWN))	fRot[0] += fCamSpeed;

		if(keyDown(SDLK_w)) {
			fCameraZ -= fCamSpeed; 
			//fRot[0] = 0.0; fRot[1] = 0.0; fRot[2] = 0.0;
			fLookZ -= fCamSpeed;
		}
		
		if(keyDown(SDLK_s)) {
			fCameraZ += fCamSpeed; 
			//fRot[0] = 0.0; fRot[1] = 0.0; fRot[2] = 0.0;
			fLookZ += fCamSpeed;
		}
		if(keyDown(SDLK_a)) {
			fCameraX -= fCamSpeed;
			fLookX -= fCamSpeed;
		}
		if(keyDown(SDLK_d)) {
			fCameraX += fCamSpeed;
			fLookX += fCamSpeed;
		}
		
		if(keyDown(SDLK_SPACE))	resetCam();
		
		//If we're actively dragging with the mouse
		if(bDrag){
			
			//Figure out the drag vectors and stuff
			Vector2 drag = getMouse();
			Vector2 diff = (dragStart - drag) * fDragScale;
					
			//Left mouse button means we modify the rotation
			if(mouseDown(1)){
				fRot[1] -= diff.x;
				fRot[0] -= diff.y;			
			}
			
			//Middle mouse means we modify the zoom
			else if(mouseDown(2)){
				fZoom += diff.y;
			}
			
			dragVel = diff;
			dragStart = getMouse();
			
			
			
		}else{
			//fRot[1] -= dragVel.x;
			//fRot[0] -= dragVel.y;
		}
	}	

	updateSocket();
	
	//Hack! The shader system doesn't really play nice with the banner, so
	//we disable it here.
	if(!isConnected()){
		if(ps()->getType() <= PARTICLE_SYSTEM_POINTSPRITES)
			generateTestData();
		else
			fGUITimeout = 1.0f;
	}
	
	mParticleSystem->update();	
}
Example #9
0
/* Run a slider widget */
void W_SLIDER::run(W_CONTEXT *psContext)
{
    if ((state & SLD_DRAG) && !mouseDown(MOUSE_LMB))
    {
        state &= ~SLD_DRAG;
        screenPointer->setReturn(this);
        dirty = true;
    }
    else if (!(state & SLD_DRAG) && mouseDown(MOUSE_LMB))
    {
        clicked(psContext, WKEY_NONE);
    }
    if (state & SLD_DRAG)
    {
        /* Figure out where the drag box should be */
        int mx = psContext->mx - x();
        int my = psContext->my - y();
        int stopSize;
        switch (orientation)
        {
        case WSLD_LEFT:
            if (mx <= barSize / 2)
            {
                pos = 0;
            }
            else if (mx >= width() - barSize / 2)
            {
                pos = numStops;
            }
            else
            {
                /* Mouse is in the middle of the slider, calculate which stop */
                stopSize = (width() - barSize) / numStops;
                pos = (mx + stopSize / 2 - barSize / 2)
                      * numStops
                      / (width() - barSize);
            }
            break;
        case WSLD_RIGHT:
            if (mx <= barSize / 2)
            {
                pos = numStops;
            }
            else if (mx >= width() - barSize / 2)
            {
                pos = 0;
            }
            else
            {
                /* Mouse is in the middle of the slider, calculate which stop */
                stopSize = (width() - barSize) / numStops;
                pos = numStops
                      - (mx + stopSize / 2 - barSize / 2)
                      * numStops
                      / (width() - barSize);
            }
            break;
        case WSLD_TOP:
            if (my <= barSize / 2)
            {
                pos = 0;
            }
            else if (my >= height() - barSize / 2)
            {
                pos = numStops;
            }
            else
            {
                /* Mouse is in the middle of the slider, calculate which stop */
                stopSize = (height() - barSize) / numStops;
                pos = (my + stopSize / 2 - barSize / 2)
                      * numStops
                      / (height() - barSize);
            }
            break;
        case WSLD_BOTTOM:
            if (my <= barSize / 2)
            {
                pos = numStops;
            }
            else if (my >= height() - barSize / 2)
            {
                pos = 0;
            }
            else
            {
                /* Mouse is in the middle of the slider, calculate which stop */
                stopSize = (height() - barSize) / numStops;
                pos = numStops
                      - (my + stopSize / 2 - barSize / 2)
                      * numStops
                      / (height() - barSize);
            }
            break;
        }
    }
}
Example #10
0
// ////////////////////////////////////////////////////////////////////////////
// process clicks made by user.
void intProcessMultiMenu(UDWORD id)
{
	UBYTE	i;

	//close
	if (id == MULTIMENU_CLOSE)
	{
		intCloseMultiMenu();
	}

	//alliance button
	if(id >=MULTIMENU_ALLIANCE_BASE  &&  id<MULTIMENU_ALLIANCE_BASE+MAX_PLAYERS)
	{
		i =(UBYTE)( id - MULTIMENU_ALLIANCE_BASE);

		switch(alliances[selectedPlayer][i])
		{
		case ALLIANCE_BROKEN:
			requestAlliance((UBYTE)selectedPlayer,i,true,true);			// request an alliance
			break;
		case ALLIANCE_INVITATION:
			formAlliance((UBYTE)selectedPlayer,i,true,true,true);			// form an alliance
			break;
		case ALLIANCE_REQUESTED:
			breakAlliance((UBYTE)selectedPlayer,i,true,true);		// break an alliance
			break;

		case ALLIANCE_FORMED:
			breakAlliance((UBYTE)selectedPlayer,i,true,true);		// break an alliance
			break;
		default:
			break;
		}
	}


	//channel opens.
	if(id >=MULTIMENU_CHANNEL &&  id<MULTIMENU_CHANNEL+MAX_PLAYERS)
	{
		i = id - MULTIMENU_CHANNEL;
		openchannels[i] = !openchannels[i];

		if(mouseDown(MOUSE_RMB) && NetPlay.isHost) // both buttons....
			{
				char buf[250];

				// Allow the host to kick the AI only in a MP game, or if they activated cheats in a skirmish game
				if ((NetPlay.bComms || Cheated) && (NetPlay.players[i].allocated || (NetPlay.players[i].allocated == false && NetPlay.players[i].ai != AI_OPEN)))
				{
					inputLoseFocus();
					ssprintf(buf, _("The host has kicked %s from the game!"), getPlayerName((unsigned int) i));
					sendTextMessage(buf, true);
					ssprintf(buf, _("kicked %s : %s from the game, and added them to the banned list!"), getPlayerName((unsigned int) i), NetPlay.players[i].IPtextAddress);
					NETlogEntry(buf, SYNC_FLAG, (unsigned int) i);
					kickPlayer((unsigned int) i, "you are unwanted by the host.", ERROR_KICKED);
					return;
				}
			}
	}

	//radar gifts
	if(id >=  MULTIMENU_GIFT_RAD && id< MULTIMENU_GIFT_RAD +MAX_PLAYERS)
	{
		sendGift(RADAR_GIFT, id - MULTIMENU_GIFT_RAD);
	}

	// research gift
	if(id >= MULTIMENU_GIFT_RES && id<MULTIMENU_GIFT_RES  +MAX_PLAYERS)
	{
		sendGift(RESEARCH_GIFT, id - MULTIMENU_GIFT_RES);
	}

	//droid gift
	if(id >=  MULTIMENU_GIFT_DRO && id<  MULTIMENU_GIFT_DRO +MAX_PLAYERS)
	{
		sendGift(DROID_GIFT, id - MULTIMENU_GIFT_DRO);
	}

	//power gift
	if(id >=  MULTIMENU_GIFT_POW && id<  MULTIMENU_GIFT_POW +MAX_PLAYERS)
	{
		sendGift(POWER_GIFT, id - MULTIMENU_GIFT_POW);
	}
}
Example #11
0
void wdgSlider::mouseDragged(int x, int y, int dx, int dy, int button)
{
    mouseDown(x, y);
}
Example #12
0
void CameraUi::mouseDown( app::MouseEvent &event )
{
	mouseDown( event.getPos() );
	event.setHandled();
}
Example #13
0
void wdgSlider::mouseDragged(float x, float y, float dx, float dy, int button) {
    mouseDown(x, y);
}
Example #14
0
void wdgSlider::mousePressed(float x, float y, int button) {	
	
	mouseMoved(x, y);
    mouseDown(x, y);
    wdgBase::mousePressed(x, y, button);
}
Example #15
0
/* Run a slider widget */
void sliderRun(W_SLIDER *psWidget, W_CONTEXT *psContext)
{
	SDWORD  mx,my;
	UDWORD	stopSize;

	if ((psWidget->state & SLD_DRAG) && !mouseDown(MOUSE_LMB))
	{
		psWidget->state &= ~SLD_DRAG;
		widgSetReturn(psContext->psScreen, (WIDGET *)psWidget);
	}
	else if (!(psWidget->state & SLD_DRAG) && mouseDown(MOUSE_LMB))
	{
		sliderClicked(psWidget, psContext);
	}
	if (psWidget->state & SLD_DRAG)
	{
		/* Figure out where the drag box should be */
		mx = psContext->mx - psWidget->x;
		my = psContext->my - psWidget->y;
		switch (psWidget->orientation)
		{
		case WSLD_LEFT:
			if (mx <= psWidget->barSize/2)
			{
				psWidget->pos = 0;
			}
			else if (mx >= psWidget->width - psWidget->barSize/2)
			{
				psWidget->pos = psWidget->numStops;
			}
			else
			{
				/* Mouse is in the middle of the slider, calculate which stop */
				stopSize = (psWidget->width - psWidget->barSize) / psWidget->numStops;
				psWidget->pos = (UWORD)((mx + stopSize/2 - psWidget->barSize/2)
											* psWidget->numStops
											/ (psWidget->width - psWidget->barSize));
			}
			break;
		case WSLD_RIGHT:
			if (mx <= psWidget->barSize/2)
			{
				psWidget->pos = psWidget->numStops;
			}
			else if (mx >= psWidget->width - psWidget->barSize/2)
			{
				psWidget->pos = 0;
			}
			else
			{
				/* Mouse is in the middle of the slider, calculate which stop */
				stopSize = (psWidget->width - psWidget->barSize) / psWidget->numStops;
				psWidget->pos = (UWORD)(psWidget->numStops
											- (mx + stopSize/2 - psWidget->barSize/2)
												* psWidget->numStops
												/ (psWidget->width - psWidget->barSize));
			}
			break;
		case WSLD_TOP:
			if (my <= psWidget->barSize/2)
			{
				psWidget->pos = 0;
			}
			else if (my >= psWidget->height - psWidget->barSize/2)
			{
				psWidget->pos = psWidget->numStops;
			}
			else
			{
				/* Mouse is in the middle of the slider, calculate which stop */
				stopSize = (psWidget->height - psWidget->barSize) / psWidget->numStops;
				psWidget->pos = (UWORD)((my + stopSize/2 - psWidget->barSize/2)
											* psWidget->numStops
											/ (psWidget->height - psWidget->barSize));
			}
			break;
		case WSLD_BOTTOM:
			if (my <= psWidget->barSize/2)
			{
				psWidget->pos = psWidget->numStops;
			}
			else if (my >= psWidget->height - psWidget->barSize/2)
			{
				psWidget->pos = 0;
			}
			else
			{
				/* Mouse is in the middle of the slider, calculate which stop */
				stopSize = (psWidget->height - psWidget->barSize) / psWidget->numStops;
				psWidget->pos = (UWORD)(psWidget->numStops
											- (my + stopSize/2 - psWidget->barSize/2)
												* psWidget->numStops
												/ (psWidget->height - psWidget->barSize));
			}
			break;
		}
	}
}
Example #16
0
//
//  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  PURPOSE:  Processes messages for the main window.
//
//  WM_COMMAND	- process the application menu
//  WM_PAINT	- Paint the main window
//  WM_DESTROY	- post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;

	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// Parse the menu selections:
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_CREATE:
		break;
	case WM_PAINT:

		hdc = BeginPaint(hWnd, &ps);

		{
			RECT cr;
			GetClientRect(hWnd, &cr);

			int width = cr.right - cr.left;
			int height = cr.bottom - cr.top;

			HDC bufDC;
			HBITMAP bufBMP;

			bufDC = CreateCompatibleDC(hdc);
			bufBMP = CreateCompatibleBitmap(hdc, width, height);
			SelectObject(bufDC, bufBMP);

			setPaintDC(bufDC);

			RECT r = {0};
			r.right = width;
			r.bottom = height;

			FillRect(bufDC, &r, GetStockBrush(WHITE_BRUSH));

			paint();

			setPaintDC(NULL);

			BitBlt(hdc, 0, 0, width, height, bufDC, 0, 0, SRCCOPY);

			DeleteObject(bufBMP);
			DeleteDC(bufDC);
		}

		EndPaint(hWnd, &ps);
		break;
	
	case WM_MOUSEMOVE:
		{
			int x = GET_X_LPARAM(lParam); 
			int y = GET_Y_LPARAM(lParam);

			mouseMove(x, y);
		}
	break;
	
	case WM_LBUTTONDOWN:
		SetCapture(hWnd);
		mouseDown();
	break;

	case WM_LBUTTONUP:
		ReleaseCapture();
		mouseUp();
	break;

	case WM_KEYDOWN:
		{
			int vk = wParam;
			char ch = MapVirtualKey(vk, MAPVK_VK_TO_CHAR);

			keyDown(ch, vk);
		}

		break;
	
	case WM_KEYUP:
		{
			int vk = wParam;
			char ch = MapVirtualKey(vk, MAPVK_VK_TO_CHAR);

			keyUp(ch, vk);
		}

		break;

	case WM_TIMER:
		switch(wParam)
		{
		case IDT_TIMER0:
			timerTick();
			break;
		}
		
		break;

	case WM_DESTROY:
		finalize();

		PostQuitMessage(0);
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Example #17
0
File: win.c Project: jacereda/glcv
static int onMBUTTONDOWN(HWND win, BOOL dbl, int x, int y, UINT flacv) {
        return mouseDown(CVK_MOUSEMIDDLE);
}
Example #18
0
StaticFrameGui::StaticFrameGui(QWidget* parent): FrameGui(parent)
{

    setTitle("Static Frame");

    group = new QButtonGroup (this);
    grid = new QGridLayout (this);

    dewellSwitch = new QRadioButton (this);
    dewellSwitch->setText("Dewell (ms)");
    dewellSwitch->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
    repeatSwitch = new QRadioButton (this);
    repeatSwitch->setText("Repeat (frames)");
    repeatSwitch->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);

    group->addButton(dewellSwitch,1);
    group->addButton(repeatSwitch,2);

    grid->addWidget(dewellSwitch,2,0,1,1);
    grid->addWidget(repeatSwitch,3,0,1,1);

    QLabel * pointsLabel = new QLabel ("Points",this);
    pointsLabel->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
    pointsDisplay = new QLabel ("0",this);
    pointsDisplay->setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Fixed);
    grid->addWidget(pointsLabel,1,0,1,1);
    grid->addWidget(pointsDisplay,1,1,1,1);

    dewellEntry = new QSpinBox (this);
    dewellEntry->setMinimum (40);
    dewellEntry->setMaximum (600000);

    repeatEntry = new QSpinBox (this);
    repeatEntry->setMinimum (1);
    repeatEntry->setMaximum (1000);

    grid->addWidget(dewellEntry,2,1,1,1);
    grid->addWidget(repeatEntry,3,1,1,1);
    QLabel *l = new QLabel (this);
    l->setText("ArcBall");
    l->setFrameShape(QFrame::Panel);
    l->setFrameShadow(QFrame::Raised);
    l->setAlignment(Qt::AlignHCenter);
    arcball = new ArcBall(this);
    connect (arcball,SIGNAL(angleChanged(QQuaternion)),this,SLOT(angleChangedData(QQuaternion)));
    connect (arcball,SIGNAL(mouseDown()),this,SLOT(arcballDown()));
    connect (arcball,SIGNAL(mouseUp()),this,SLOT(arcballUp()));
    grid->addWidget(l,4,0);
    grid->addWidget(arcball,5,0);
    l = new QLabel (this);
    l->setText ("Size");
    l->setFrameShape(QFrame::Panel);
    l->setFrameShadow(QFrame::Raised);
    l->setAlignment(Qt::AlignHCenter);
    grid->addWidget(l,4,1);
    size = new QSlider(Qt::Vertical,this);
    size->setRange(-200,100);
    size->setSliderPosition(0);
    grid->addWidget(size,5,1);
    setLayout(grid);
}
void Gdc2005Demo::handleUserInput(struct GdcStateInput& stateInput)
{
	const hkgKeyboard& keys = m_env->m_window->getKeyboard();

	// Show help on the keys if the user asks for it
	if ( keys.getKeyState('H') ||
		keys.getKeyState(HKG_VKEY_F1) ||
		( m_env->m_gamePad->isButtonPressed(HKG_PAD_BUTTON_L1)
		&& m_env->m_gamePad->isButtonPressed(HKG_PAD_BUTTON_R1)
		&& m_env->m_gamePad->isButtonPressed(HKG_PAD_BUTTON_0) )
		)
	{
		showKeys();
	}

	// For reference, on PC keyboard:
	//  HKG_VKEY_DELETE == HKG_PAD_BUTTON_L1
	//  HKG_VKEY_END == HKG_PAD_BUTTON_R1
	//  HKG_VKEY_INSERT == HKG_PAD_BUTTON_L2
	//  HKG_VKEY_HOME == HKG_PAD_BUTTON_R2

	// See if we want to chuck anything into the scene
	if ( m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_2) )
	{
		hkVector4 startPos;
		m_env->m_window->getCurrentViewport()->getCamera()->getFrom( (float*)&startPos );

		hkVector4 velocity;
		m_env->m_window->getCurrentViewport()->getCamera()->getDir( (float*)&velocity );
		velocity.mul4( m_options.m_Physics.m_launchVelocity );

		chuckSomething( startPos, velocity );
	}

	// See if we want to shot the guy (right click or L2)
	if ( m_env->m_gamePad->isButtonPressed(HKG_PAD_BUTTON_L2) ||
		(m_env->m_window->getMouse().getButtonState() & HKG_MOUSE_RIGHT_BUTTON) )
	{
		hkVector4 rayStart;
		hkVector4 rayEnd;

		// unproject current 'mouse' pos.
		hkgCamera* cam = m_env->m_window->getViewport(0)->getCamera();
		int xPos = m_env->m_window->getMouse().getPosX();
		int yPos = m_env->m_window->getMouse().getPosY();
		cam->unProject( xPos, yPos, 0, m_env->m_window->getWidth(), m_env->m_window->getHeight(), (float*)&rayStart);
		cam->unProject( xPos, yPos, 1, m_env->m_window->getWidth(), m_env->m_window->getHeight(), (float*)&rayEnd);

		fireShot( rayStart, rayEnd, m_options.m_Physics.m_shotStrength ); // num == strength
	}

	// See if we want to drag objects around
	if( !m_mouseActive && ( m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_R1) ||
		keys.getKeyState(HKG_VKEY_SPACE)) ) // Space == Button0 on PC == jump
	{
    	mouseDown(); // pick object under cursor
	}
	else if ( m_mouseActive )
	{
		if( !m_env->m_gamePad->isButtonPressed(HKG_PAD_BUTTON_R1) &&
			!m_env->m_window->getKeyboard().getKeyState(HKG_VKEY_SPACE) )
		{
			mouseUp(); // default physics game impl : delete mouse spring
		}
		else
		{
			mouseDrag(); // default physics game impl : unproject mouse and move spring.
		}
	}

	// Desired direction
	// If we are on a console we are using a stick and want that to dictate
	// the desired direction. Otherwise we will use the dpad ( keyboard dir keys )
	updateUserControl();

	// Die ? Get up? Jump?
	{
		const hkUint32 currentAnimationState = m_animationStateMachine->getCurrentState();
		const bool usingGamepad = m_env->m_window->hasGamePads() && !m_env->m_options->m_forceKeyboardGamepad;

		// DIE?
		if (m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_1) && currentAnimationState != GDC_DYING_STATE && currentAnimationState != GDC_DEAD_STATE && currentAnimationState != GDC_GETTING_UP_STATE)
		{
			stateInput.m_shouldDie = true;
		}
		else
		{
			stateInput.m_shouldDie = false;
		}

		// DIVE?
		if (m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_3) && currentAnimationState != GDC_DYING_STATE && currentAnimationState != GDC_DEAD_STATE && currentAnimationState != GDC_GETTING_UP_STATE)
		{
			stateInput.m_shouldDive = true;
		}
		else
		{
			stateInput.m_shouldDive = false;
		}

		// GET UP?
		if (m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_1) && currentAnimationState == GDC_DEAD_STATE)
		{
			stateInput.m_shouldGetUp = true;
		}
		else
		{
			stateInput.m_shouldGetUp = false;
		}

		// JUMP?
		bool jumpPressed;
		if (usingGamepad)
		{
			jumpPressed = m_env->m_gamePad->wasButtonPressed(HKG_PAD_BUTTON_0);
		}
		else
		{
			jumpPressed = keys.wasKeyPressed('4');
		}
		if (jumpPressed && currentAnimationState!=GDC_DYING_STATE && currentAnimationState!=GDC_IN_AIR_STATE && currentAnimationState!=GDC_DEAD_STATE && currentAnimationState!=GDC_JUMP_STATE)
		{
			stateInput.m_shouldJump = true;
		}
		else
		{
			stateInput.m_shouldJump = false;
		}

	}
}
Example #20
0
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;
		}

	}
}