Ejemplo n.º 1
0
/******************************************************************************
 *
 *	XTestStealJumpData
 *
 *	Create one or more input actions and put them in the input action
 *	event.  The input actions will be an (maybe) XTestDELAY_ACTION
 *	and an XTestJUMP_ACTION.
 */
void
XTestStealJumpData(int jx, int jy, int dev_type)
{	
	XTestJumpInfo 	*jmp_ptr;
	/*
	 * time delta (in ms) from previous event
	 */
	CARD16			tchar;

	/*
	 * Get the time delta from the previous event.  If needed,
	 * the check_time_event routine will put an XTestDELAY_ACTION
	 * type action in the input action event.
	 */
	tchar = check_time_event();
	if (!there_is_room(sizeof(XTestJumpInfo)))
	{
		/*
		 * If there isn't room in the input action event for
		 * an XTestJUMP_ACTION, then send that event to the
		 * client and start filling an empty one.
		 */
		flush_input_actions();
	}
	/*
	 * update the logical mouse position
	 */
	xtest_mousex = jx;
	xtest_mousey = jy;
	/*
	 * point jmp_ptr to the correct place in the input action event
	 */
	jmp_ptr = (XTestJumpInfo *)
		  &(input_action_packet.actions[packet_index]);
	/*
	 * compute the input action header
	 */
	jmp_ptr->header = (XTestPackDeviceID(dev_type) | XTestJUMP_ACTION);	
	/*
	 * set the x and y coordinates to jump to in the input action
	 */
	jmp_ptr->jumpx = jx;
	jmp_ptr->jumpy = jy;
	/*
	 * set the delay time in the input action
	 */
	jmp_ptr->delay_time = tchar;
	/*
	 * increment the packet index by the size of the input action
	 */
	packet_index = packet_index + sizeof(XTestJumpInfo);
	if (packed_mode == 0)
	{
		/*
		 * if input actions are not packed, send the input
		 * action event to the client
		 */
		flush_input_actions();
	}
}	
Ejemplo n.º 2
0
/******************************************************************************
 *
 * 	stop_stealing_input
 *
 *	Stop stealing input actions.
 */
void
stop_stealing_input()
{
    /*
     * put any code that you might need to stop stealing input actions here
     */
    if (packet_index != 0)
    {
        /*
         * if there is a partially full input action event waiting
         * when this function is called, send it to the client
         */
        flush_input_actions();
    }
}
Ejemplo n.º 3
0
/*
 * mode: what input action packing mode to use.  one of 0, XTestPACKED_MOTION,
 * or XTestPACKED_ACTIONS; optionally 'or'ed with XTestEXCLUSIVE,
 */
void
steal_input(ClientPtr client, CARD32 mode)
{
	if (packet_index != 0) 
	{
		/*
		 * if there is a partially full input action event waiting
		 * when this function is called, send it to the client
		 */
		flush_input_actions();
	}
	else
	{	
		/*
		 * otherwise, set up a new input action event
		 */
		input_action_packet.type = XTestInputActionType;
		packet_index = 0;
	}
	/*
	 * set up the new input action packing mode
	 */
	packed_mode = mode & ~(XTestEXCLUSIVE);
	/*
	 * keep track of where the mouse is
	 */
	XTestGetPointerPos(&xtest_mousex, &xtest_mousey);
	/*
	 * keep track of which client is getting input actions
	 */
	current_xtest_client = client;
	/*
	 * find out what time it is
	 */
	X_GETTIMEOFDAY(&current_time);
	/*
	 * jump to the initial position of the mouse, using a device type of 0.
	 */
	XTestStealJumpData(xtest_mousex, xtest_mousey, 0);
}
Ejemplo n.º 4
0
/******************************************************************************
 *
 *	XTestStealKeyData
 *
 * 	Place this key data in the input_action_packet.
 *
 */
Bool
XTestStealKeyData(unsigned keycode, int keystate, int dev_type,
		  int locx, int locy)
{
	/*
	 * pointer to key/button motion input action
	 */
	XTestKeyInfo	*kp;
	/*
	 * time delta from previous event
	 */
	CARD16			tchar;
	char		keytrans = 0;

	/*
	 * update the logical position of the locator if the physical position
	 * of the locator is not the same as the logical position.
	 */
	if ((locx != xtest_mousex) || (locy != xtest_mousey))
	{
		XTestStealJumpData(locx, locy, dev_type);
	}
	/*
	 * Get the time delta from the previous event.  If needed,
	 * the check_time_event routine will put an XTestDELAY_ACTION
	 * type action in the input action event.
	 */
	tchar = check_time_event();
	if (!there_is_room(sizeof(XTestKeyInfo)))
	{
		/*
		 * If there isn't room in the input action event for
		 * an XTestDELAY_ACTION, then send that event to the
		 * client and start filling an empty one.
		 */
		flush_input_actions();
	}
	/*
	 * point kp to the correct place in the input action event
	 */
	kp = (XTestKeyInfo *)
	     (&(input_action_packet.actions[packet_index]));
	/*
	 * compute the input action header
	 */
	kp->header = XTestPackDeviceID(dev_type);
	if ((keystate == KeyRelease) || (keystate == ButtonRelease))
	{
		keytrans = XTestKEY_UP;
	}
	else if ((keystate == KeyPress) || (keystate == ButtonPress))
	{
		keytrans = XTestKEY_DOWN;
	}
	else
	{
		printf("%s: invalid key/button state %d.\n",
		       XTestEXTENSION_NAME,
		       keystate);
	}
	kp->header = kp->header | keytrans | XTestKEY_ACTION;
	/*
	 * set the keycode in the input action
	 */
	kp->keycode = keycode;
	/*
	 * set the delay time in the input action
	 */
	kp->delay_time = tchar;
	/*
	 * increment the packet index by the size of the input action
	 */
	packet_index = packet_index + sizeof(XTestKeyInfo);
	/*
	 * if the command key has been released or input actions are not
	 * packed, send the input action event to the client
	 */
 	if(((keycode == xtest_command_key) && (keystate == KeyRelease)) ||
	   (packed_mode != XTestPACKED_ACTIONS))
	{	
		flush_input_actions();
	}
	/* return TRUE if the event should be passed on to DIX */
	if (exclusive_steal)
		return ((keystate == KeyRelease) &&
			(keycode == xtest_command_key));
	else
		return ((keystate != KeyRelease) ||
			(keycode != xtest_command_key));
}
Ejemplo n.º 5
0
/******************************************************************************
 *
 *	XTestStealMotionData
 *
 *	Put motion information from the locator into an input action.
 *
 *	called from x_hil.c
 */
void
XTestStealMotionData(int dx, int dy, int dev_type, int mx, int my)
{
	/*
	 * pointer to a XTestMOTION_ACTION input action
	 */
	XTestMotionInfo	*fm;
	/*
	 * time delta from previous event
	 */
	CARD16			tchar;

	/*
	 * if the current position of the locator is not the same as
	 * the logical position, then update the logical position
	 */
	if ((mx != xtest_mousex) || (my != xtest_mousey))
	{
		XTestStealJumpData(mx, my, dev_type);
	}
	/*
	 * if the delta motion is outside the range that can
	 * be held in a motion input action, use a jump input action
	 */
	if ((dx > XTestMOTION_MAX) || (dx < XTestMOTION_MIN) ||
	    (dy > XTestMOTION_MAX) || (dy < XTestMOTION_MIN))
	{
		XTestStealJumpData((xtest_mousex + dx),
				   (xtest_mousey + dy), dev_type);
	}
	else
	{ 
		/*
		 * compute the new logical position of the mouse
		 */
		xtest_mousex += dx;
		xtest_mousey += dy;
		/*
		 * Get the time delta from the previous event.  If needed,
		 * the check_time_event routine will put an XTestDELAY_ACTION
		 * type action in the input action event.
		 */
		tchar = check_time_event();
		/*
		 * If there isn't room in the input action event for
		 * an XTestDELAY_ACTION, then send that event to the
		 * client and start filling an empty one.
		 */
		if (!there_is_room(sizeof(XTestMotionInfo)))
		{
			flush_input_actions();
		/*
		 * point fm to the correct place in the input action event
		 */
		}
		fm = (XTestMotionInfo *)
		     &(input_action_packet.actions[packet_index]);
		/*
		 * compute the input action header
		 */
		fm->header = XTestMOTION_ACTION;
		if (dx < 0)	
		{  
			fm->header |= XTestX_NEGATIVE;
			dx = abs(dx);
		}
		if (dy < 0)   
		{  
			fm->header |= XTestY_NEGATIVE;
			dy = abs(dy);
		}
		fm->header |= XTestPackDeviceID(dev_type);
		/*
		 * compute the motion data byte
		 */
		fm->motion_data = XTestPackYMotionValue(dy);
		fm->motion_data |= XTestPackXMotionValue(dx);
		/*
		 * set the delay time in the input action
		 */
		fm->delay_time = tchar;
		/*
		 * increment the packet index by the size of the input action
		 */
		packet_index = packet_index + sizeof(XTestMotionInfo);
		if (packed_mode == 0)
		{
			/*
			 * if input actions are not packed, send the input
			 * action event to the client
			 */
			flush_input_actions();
		}

	}   
}
Ejemplo n.º 6
0
/******************************************************************************
 *
 *	check_time_event
 *
 *	If time delta is > XTestSHORT_DELAY_TIME then insert a time event
 *	and return 0; else return the delay time.
 */
static CARD16
check_time_event()
{
	CARD32		tstamp;
	CARD16		tchar;
	XTestDelayInfo	*tptr;

	/*
	 * get the number of milliseconds between input actions
	 */
	tstamp = current_ms(&current_time);
	/*
	 * if the number of milliseconds is too large to fit in a CARD16,
	 * then add a XTestDELAY_ACTION to the input action event.
	 */
	if (tstamp > XTestSHORT_DELAY_TIME)
	{
		/*
		 * If there isn't room in the input action event for
		 * an XTestDELAY_ACTION, then send that event to the
		 * client and start filling an empty one.
		 */
		if (!there_is_room(sizeof(XTestDelayInfo)))
		{
			flush_input_actions();
		}
		/*
		 * point tptr to the correct place in the input action event
		 */
		tptr = (XTestDelayInfo *)
		       (&(input_action_packet.actions[packet_index]));
		/*
		 * compute the input action header
		 */
		tptr->header = XTestPackDeviceID(XTestDELAY_DEVICE_ID) |
			       XTestDELAY_ACTION;
		/*
		 * set the delay time in the input action
		 */
		tptr->delay_time = tstamp;
		/*
		 * increment the packet index by the size of the input action
		 */
		packet_index = packet_index + (sizeof(XTestDelayInfo));
		if (packed_mode != XTestPACKED_ACTIONS) 
		{
			/*
			 * if input actions are not packed, send the input
			 * action event to the client
			 */
			flush_input_actions();
		}
		/*
		 * set the returned delay time to 0
		 */
		tchar = 0;
	}
	else
	{
		/*
		 * set the returned delay time to the computed delay time
		 */
		tchar = tstamp;
	}
	return(tchar);
}