View Single Post
Old 02-01-2018, 10:37 AM   #320
fundorin
Banned
 
Join Date: Feb 2014
Location: Moscow, Russia
Posts: 554
Default

Solution for mouse emulation. I'm using endless push encoder.

slSb - encoder button
slSd - sends 65++ on CCW encoder rotate and 1++ on CW.

Code:
        // Simulate mouse
        if (msg1 == 0xBF)
        {
            // Left click
            if (msg2 == slSb) (msg3 == 1) ? mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0) : mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);
            // Mouse wheel
            else if (msg2 == slSd) (msg3 > 64) ? mouse_event(MOUSEEVENTF_WHEEL, 0, 0, -120, 0) : mouse_event(MOUSEEVENTF_WHEEL, 0, 0, 120, 0);
        }
Button pushes and releases left mouse. Encoder simulates mouse wheel.

UPD. Multiplying delta (120 equals one wheel click) by msg3 gives mouse wheel acceleration:
Code:
mouse_event(MOUSEEVENTF_WHEEL, 0, 0, -120 * (msg3 - 64), 0)

Last edited by fundorin; 02-01-2018 at 11:07 AM.
fundorin is offline   Reply With Quote