Why is using Touch Injection API with WIN8 only one click introduced?

I am trying to test the Touch Injection API for injecting multiple strokes when using Windows 8. To do this, I create 5 contacts and then simulate a hang, and then drag and drop.

This is great for one-touch contact. However, nothing changes when I add 4 more contacts, that is, it produces the same thing as if there was only one contact. (I test by opening Paint on the right side of the screen and a visual studio on the left. Then, when the program starts the line, it is drawn diagonally in the paint window). When I run GetLastError () after InitializeTouchInjection, it gives me 5, which is an invalid access error.

Is there a flag I should use? Should my computer install a specific driver? What is wrong here?

Here is the code:

#include <windows.h>

void Drag(int x, int y){
    POINTER_TOUCH_INFO contact_[5];
    BOOL bRet = TRUE;

    InitializeTouchInjection(5, TOUCH_FEEDBACK_DEFAULT);

    for (int c=0;c<5;c++)
    {
        POINTER_TOUCH_INFO &contact=contact_[c];
        memset(&contact, 0, sizeof(POINTER_TOUCH_INFO));
        contact.pointerInfo.pointerType = PT_TOUCH;
        contact.pointerInfo.pointerId = c;          //contact 0
        contact.pointerInfo.ptPixelLocation.y = y; // Y co-ordinate of touch on screen
        contact.pointerInfo.ptPixelLocation.x = x+50*c; // X co-ordinate of touch on screen

        contact.touchFlags = TOUCH_FLAG_NONE;
        contact.touchMask = TOUCH_MASK_CONTACTAREA | TOUCH_MASK_ORIENTATION | TOUCH_MASK_PRESSURE;
        contact.orientation = 90; // Orientation of 90 means touching perpendicular to screen.
        contact.pressure = 32000; 

        // defining contact area (I have taken area of 4 x 4 pixel)
        contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
        contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
        contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x  - 2;
        contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x  + 2;

        //contact.pointerInfo.pointerFlags = POINTER_FLAG_DOWN | POINTER_FLAG_INRANGE | POINTER_FLAG_INCONTACT;
        contact.pointerInfo.pointerFlags = POINTER_FLAG_UPDATE | POINTER_FLAG_INRANGE ;//| POINTER_FLAG_INCONTACT;
    }
    InjectTouchInput(5, contact_); // Injecting the touch down on screen
    Sleep(20);

    for(int i=0;i<200;i++)
    {
        for (int c=0;c<5;c++)
        {
            POINTER_TOUCH_INFO &contact=contact_[c];
            contact.pointerInfo.ptPixelLocation.x--; // updating the X Co-ordinate to x-100 pixels
            contact.pointerInfo.ptPixelLocation.y++;

            contact.rcContact.top = contact.pointerInfo.ptPixelLocation.y - 2;
            contact.rcContact.bottom = contact.pointerInfo.ptPixelLocation.y + 2;
            contact.rcContact.left = contact.pointerInfo.ptPixelLocation.x  - 2;
            contact.rcContact.right = contact.pointerInfo.ptPixelLocation.x  + 2;
            if (i==100)
                contact.pointerInfo.pointerFlags = POINTER_FLAG_INCONTACT | POINTER_FLAG_INRANGE | POINTER_FLAG_DOWN;
            if (i>100)
                contact.pointerInfo.pointerFlags = POINTER_FLAG_INCONTACT | POINTER_FLAG_INRANGE | POINTER_FLAG_UPDATE;
        }
        InjectTouchInput(5, contact_); // Injecting the touch down on screen
        Sleep(20);
    }
    // Lifts the touch input UP
    for (int c=0;c<5;c++)
    {
        POINTER_TOUCH_INFO &contact=contact_[c];
        contact.pointerInfo.pointerFlags = POINTER_FLAG_INRANGE | POINTER_FLAG_UP;
    }
    InjectTouchInput(5, contact_); // Injecting the touch down on screen
    Sleep(10);
}

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
     Drag(1300,500);
}
+4
source share
1 answer

A few points:

Be sure to come InitializeTouchInjectionback TRUE.

Please note that the TOUCH_FEEDBACK_DEFAULTsettings on the Pen and Touch control panels affect it , so use TOUCH_FEEDBACK_INDIRECTit because it overrides these settings.

+1
source

All Articles