CodeDoctorJL
CodeDoctorJL

Reputation: 1264

How do I use my own coordinates instead of wParam? (using winapi)

This is the overall code bellow:

LRESULT WmPointerAPI::WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HRESULT hr;
POINTER_INFO pointerInfo = {};

UNREFERENCED_PARAMETER(hr);

switch (message)
{
case WM_POINTERDOWN:
    // Get frame id from current message
    if (GetPointerInfo(GET_POINTERID_WPARAM(wParam), &pointerInfo))
    {

I'm focusing on:

if (GetPointerInfo(GET_POINTERID_WPARAM(wParam), &pointerInfo))

I'm currently using Leap Motion technology, which is a 3D sensor to plug coordinates into my application. The problem is, I don't know how to plug my own "coordinates" into the wParam, so that it takes in my coordinates, rather then from cursor/touch screen.

How would I inject or simulate touch through wParam, using my own on screen coordinates?

Upvotes: 2

Views: 496

Answers (1)

kol
kol

Reputation: 28708

lParam

The coordinates are in the lParam, see here:

Use the following macros to retrieve the physical screen coordinates of the point: 
* GET_X_LPARAM(lParam): the x (horizontal point) coordinate. 
* GET_Y_LPARAM(lParam): the y (vertical point) coordinate.

You can create a new lParam value using the MAKELPARAM macro. Example:

WORD screenX = 345; 
WORD screenY = 234;
LPARAM testLParam = MAKELPARAM(screenX, screenY);

wParam

If you also want to create a wParam, then you should reverse-engineer which bits of wParam are read by the macros listed in its description, and create your own wParam value using bit operations. For example, GET_POINTERID_WPARAM reads the low-order WORD of wParam. The macro MAKEWPARAM can come in handy, too.

Upvotes: 2

Related Questions