Click here to Skip to main content
15,886,840 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a USB HID touchpad that collects input. By default, when I press on the touchpad it generates carriage return (Enter) and when I try to use it as a mouse it actually enters a dragging state.

What I want to do is to convert the carriage return into a mouse click event and the dragging state into a cursor move without the initial clicking part.

I found the raw input alternative. However, I don't know how to convert it into mouse click and cursor move.

Here is the code responsible with the mouse 'reading':

C++
LRESULT CALLBACK mouseProc (int nCode, WPARAM wParam, LPARAM lParam)
    {
        MOUSEHOOKSTRUCT * pMouseStruct = (MOUSEHOOKSTRUCT *)lParam;
        if (pMouseStruct != NULL)
        {
            if(wParam == WM_LBUTTONDOWN)
            {
                cout<<"clicked"<<endl;
            }
            printf("Mouse position X = %d  Mouse Position Y = %d\n", pMouseStruct->pt.x,pMouseStruct->pt.y);
    
            stringstream sx, sy;
            sx << (int) pMouseStruct->pt.x << endl;
            sy << (int) pMouseStruct->pt.y << endl;
        }
        return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
    }


then the keyboard part:

C++
LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
    {
        if (nCode < 0)
            return CallNextHookEx(NULL, nCode, wParam, lParam);
    
        tagKBDLLHOOKSTRUCT *str = (tagKBDLLHOOKSTRUCT *)lParam;
    
        cout<<str->vkCode<<endl;
    
        return CallNextHookEx(NULL, nCode, wParam, lParam);
    }


then the logging part:

C++
DWORD WINAPI MyLogger(LPVOID lpParm)
    {
    
        HINSTANCE hInstance = GetModuleHandle(NULL);
        hMouseHook = SetWindowsHookEx( WH_MOUSE_LL, mouseProc, hInstance, NULL );
        hKeyHook = SetWindowsHookEx( WH_KEYBOARD_LL, LowLevelKhttps://msdn.microsoft.com/en-us/library/windows/desktop/ms645546%28v=vs.85%29.aspxeyboardProc, hInstance, NULL );
    
        MSG message;
        while (GetMessage(&message,NULL,0,0))
        {
            TranslateMessage( &message );
            DispatchMessage( &message );
        }
    
        UnhookWindowsHookEx(hMouseHook);
        return 0;
    }


Note: I don't know if this is relevant, but I want to use the HID to play in a Chromium instance on a windows system.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900