Exemple #1
0
    void Mouse::releaseButton(MouseButton button)
    {
        INIT_INPUT(input);
        input.mi.dwFlags = translateMouseButton(button) << 1;

        SendInput(1, &input, sizeof(INPUT));
    }
Exemple #2
0
    void Mouse::wheelDown()
    {
        INIT_INPUT(input);
        input.mi.dwFlags = MOUSEEVENTF_WHEEL;
        input.mi.mouseData = -WHEEL_DELTA;

        SendInput(1, &input, sizeof(INPUT));
    }
Exemple #3
0
 void Mouse::move(int x, int y)
 {
     INIT_INPUT(input);
     input.mi.dx = x;
     input.mi.dy = y;
     input.mi.dwFlags = MOUSEEVENTF_MOVE;
     SendInput(1, &input, sizeof(INPUT));
 }
Exemple #4
0
    void Mouse::moveTo(int x, int y)
    {
        double screenWidth = GetSystemMetrics(SM_CXSCREEN) - 1; 
        double screenHeight = GetSystemMetrics(SM_CYSCREEN) - 1; 
        double fx = x * (65535.0f / screenWidth);
        double fy = y * (65535.0f / screenHeight);

        INIT_INPUT(input);
        input.mi.dx = (LONG) fx;
        input.mi.dy = (LONG) fy;
        input.mi.dwFlags = MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_MOVE;
        SendInput(1, &input, sizeof(INPUT));
    }
XnStatus XnPSCompressedDepthProcessor::UncompressDepthPS(const XnUInt8* pInput, const XnUInt32 nInputSize,
								   XnUInt16* pOutput, XnUInt32* pnOutputSize,
								   XnUInt32* pnActualRead, XnBool bLastPart)
{
	// Input is made of 4-bit elements.
	INIT_INPUT(pInput, nInputSize);

	XnUInt16* pOutputEnd = pOutput + (*pnOutputSize / sizeof(XnUInt16));
	XnUInt16 nLastValue = 0;

	const XnUInt8* pInputOrig = pInput;
	XnUInt16* pOutputOrig = pOutput;

	const XnUInt8* pInputLastPossibleStop = pInputOrig;
	XnUInt16* pOutputLastPossibleStop = pOutputOrig;

	// NOTE: we use variables of type uint32 instead of uint8 as an optimization (better CPU usage)
	XnUInt32 nInput;
	XnUInt32 nLargeValue;
	XnBool bCanStop;

	while (TRUE)
	{
		bCanStop = CAN_INPUT_STOP_HERE;
		GET_NEXT_INPUT(nInput);

		switch (nInput)
		{
		case 0xd: // Dummy.
			// Do nothing
			break;
		case 0xe: // RLE
			// read count
			GET_NEXT_INPUT(nInput);

			// should repeat last value (nInput + 1) times
			nInput++;
			while (nInput != 0)
			{
				XN_DEPTH_OUTPUT(pOutput, pOutputEnd, nLastValue);
				--nInput;
			}
			break;

		case 0xf: // Full (or large)
			// read next element
			GET_NEXT_INPUT(nInput);

			// First bit tells us if it's a large diff (turned on) or a full value (turned off)
			if (nInput & 0x8) // large diff (7-bit)
			{
				// turn off high bit, and shift left
				nLargeValue = (nInput - 0x8) << 4;

				// read low 4-bits
				GET_NEXT_INPUT(nInput);

				nLargeValue |= nInput;
				// diff values are from -64 to 63 (0x00 to 0x7f)
				nLastValue += nLargeValue - 64;
			}
			else // Full value (15-bit)
			{
				if (bCanStop)
				{
					// We can stop here. First input is a full value
					pInputLastPossibleStop = GET_PREV_INPUT(2);
					pOutputLastPossibleStop = pOutput;
				}

				nLargeValue = (nInput << 12);

				// read 3 more elements
				GET_NEXT_INPUT(nInput);
				nLargeValue |= nInput << 8;

				GET_NEXT_INPUT(nInput);
				nLargeValue |= nInput << 4;

				GET_NEXT_INPUT(nInput);
				nLastValue = (nLargeValue | nInput);
			}

			XN_DEPTH_OUTPUT(pOutput, pOutputEnd, nLastValue);

			break;
		default: // all rest (smaller than 0xd) are diffs
			// diff values are from -6 to 6 (0x0 to 0xc)
			nLastValue += nInput - 6;
			XN_DEPTH_OUTPUT(pOutput, pOutputEnd, nLastValue);
		}
	}

	if (bLastPart == TRUE)
	{
		*pnOutputSize = (pOutput - pOutputOrig) * sizeof(XnUInt16);
		*pnActualRead = GET_INPUT_READ_BYTES;
	}
	else
	{
		*pnOutputSize = (pOutputLastPossibleStop - pOutputOrig) * sizeof(XnUInt16);
		*pnActualRead = (pInputLastPossibleStop - pInputOrig) * sizeof(XnUInt8);
	}

	// All is good...
	return (XN_STATUS_OK);
}