Skip to content

Commit

Permalink
combine correction of pointer postion during drag and following bottu…
Browse files Browse the repository at this point in the history
…n down event
  • Loading branch information
U-i7\gimy committed Jul 23, 2009
1 parent 63e0551 commit b2cdeb2
Showing 1 changed file with 54 additions and 59 deletions.
113 changes: 54 additions & 59 deletions engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,108 +611,103 @@ unsigned int Engine::injectInput(const KEYBOARD_INPUT_DATA *i_kid, const KBDLLHO
{
if (i_kid->Flags & KEYBOARD_INPUT_DATA::E1) {
Acquire a(&m_cskidq);
INPUT kid[3];
int i = 0;
POINT pt;
GetCursorPos(&pt);

if (!(i_kid->Flags & KEYBOARD_INPUT_DATA::BREAK) &&
i_kid->MakeCode != 4 && i_kid->MakeCode != 5) {
HWND hwnd = WindowFromPoint(pt);
if (hwnd != NULL) {
_TCHAR className[GANA_MAX_ATOM_LENGTH];
if (GetClassName(hwnd, className, NUMBER_OF(className))) {
if (_tcsicmp(className, _T("ConsoleWindowClass")) == 0) {
SetForegroundWindow(hwnd);
}
}
}
if (m_dragging) {
kid[i].type = INPUT_MOUSE;
kid[i].mi.dx = 65535 * m_msllHookCurrent.pt.x / GetSystemMetrics(SM_CXVIRTUALSCREEN);
kid[i].mi.dy = 65535 * m_msllHookCurrent.pt.y / GetSystemMetrics(SM_CYVIRTUALSCREEN);
kid[i].mi.time = 0;
kid[i].mi.mouseData = 0;
kid[i].mi.dwExtraInfo = 0;
kid[i].mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK;
i++;
}
}
kid[i].type = INPUT_MOUSE;
kid[i].mi.dx = 0;
kid[i].mi.dy = 0;
kid[i].mi.time = 0;
kid[i].mi.mouseData = 0;
kid[i].mi.dwExtraInfo = 0;
INPUT kid[2];
int count = 1;

kid[0].type = INPUT_MOUSE;
kid[0].mi.dx = 0;
kid[0].mi.dy = 0;
kid[0].mi.time = 0;
kid[0].mi.mouseData = 0;
kid[0].mi.dwExtraInfo = 0;
switch (i_kid->MakeCode) {
case 1:
if (i_kid->Flags & KEYBOARD_INPUT_DATA::BREAK) {
kid[i].mi.dwFlags = MOUSEEVENTF_LEFTUP;
kid[0].mi.dwFlags = MOUSEEVENTF_LEFTUP;
} else {
kid[i].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
kid[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
}
break;
case 2:
if (i_kid->Flags & KEYBOARD_INPUT_DATA::BREAK) {
kid[i].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
kid[0].mi.dwFlags = MOUSEEVENTF_RIGHTUP;
} else {
kid[i].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
kid[0].mi.dwFlags = MOUSEEVENTF_RIGHTDOWN;
}
break;
case 3:
if (i_kid->Flags & KEYBOARD_INPUT_DATA::BREAK) {
kid[i].mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
kid[0].mi.dwFlags = MOUSEEVENTF_MIDDLEUP;
} else {
kid[i].mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
kid[0].mi.dwFlags = MOUSEEVENTF_MIDDLEDOWN;
}
break;
case 4:
if (i_kid->Flags & KEYBOARD_INPUT_DATA::BREAK) {
return 1;
} else {
kid[i].mi.mouseData = WHEEL_DELTA;
kid[i].mi.dwFlags = MOUSEEVENTF_WHEEL;
kid[0].mi.mouseData = WHEEL_DELTA;
kid[0].mi.dwFlags = MOUSEEVENTF_WHEEL;
}
break;
case 5:
if (i_kid->Flags & KEYBOARD_INPUT_DATA::BREAK) {
return 1;
} else {
kid[i].mi.mouseData = -WHEEL_DELTA;
kid[i].mi.dwFlags = MOUSEEVENTF_WHEEL;
kid[0].mi.mouseData = -WHEEL_DELTA;
kid[0].mi.dwFlags = MOUSEEVENTF_WHEEL;
}
break;
case 6:
kid[i].mi.mouseData = XBUTTON1;
kid[0].mi.mouseData = XBUTTON1;
if (i_kid->Flags & KEYBOARD_INPUT_DATA::BREAK) {
kid[i].mi.dwFlags = MOUSEEVENTF_XUP;
kid[0].mi.dwFlags = MOUSEEVENTF_XUP;
} else {
kid[i].mi.dwFlags = MOUSEEVENTF_XDOWN;
kid[0].mi.dwFlags = MOUSEEVENTF_XDOWN;
}
break;
case 7:
kid[i].mi.mouseData = XBUTTON2;
kid[0].mi.mouseData = XBUTTON2;
if (i_kid->Flags & KEYBOARD_INPUT_DATA::BREAK) {
kid[i].mi.dwFlags = MOUSEEVENTF_XUP;
kid[0].mi.dwFlags = MOUSEEVENTF_XUP;
} else {
kid[i].mi.dwFlags = MOUSEEVENTF_XDOWN;
kid[0].mi.dwFlags = MOUSEEVENTF_XDOWN;
}
break;
default:
return 1;
break;
}
if (i == 1) {
i++;
kid[i].type = INPUT_MOUSE;
kid[i].mi.dx = 65535 * pt.x / GetSystemMetrics(SM_CXVIRTUALSCREEN);
kid[i].mi.dy = 65535 * pt.y / GetSystemMetrics(SM_CYVIRTUALSCREEN);
kid[i].mi.time = 0;
kid[i].mi.mouseData = 0;
kid[i].mi.dwExtraInfo = 0;
kid[i].mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK;
if (!(i_kid->Flags & KEYBOARD_INPUT_DATA::BREAK) &&
i_kid->MakeCode != 4 && i_kid->MakeCode != 5) {
HWND hwnd;
POINT pt;

if (GetCursorPos(&pt) && (hwnd = WindowFromPoint(pt))) {
_TCHAR className[GANA_MAX_ATOM_LENGTH];
if (GetClassName(hwnd, className, NUMBER_OF(className))) {
if (_tcsicmp(className, _T("ConsoleWindowClass")) == 0) {
SetForegroundWindow(hwnd);
}
}
}
if (m_dragging) {
kid[0].mi.dx = 65535 * m_msllHookCurrent.pt.x / GetSystemMetrics(SM_CXVIRTUALSCREEN);
kid[0].mi.dy = 65535 * m_msllHookCurrent.pt.y / GetSystemMetrics(SM_CYVIRTUALSCREEN);
kid[0].mi.dwFlags |= MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK;

kid[1].type = INPUT_MOUSE;
kid[1].mi.dx = 65535 * pt.x / GetSystemMetrics(SM_CXVIRTUALSCREEN);
kid[1].mi.dy = 65535 * pt.y / GetSystemMetrics(SM_CYVIRTUALSCREEN);
kid[1].mi.time = 0;
kid[1].mi.mouseData = 0;
kid[1].mi.dwExtraInfo = 0;
kid[1].mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_ABSOLUTE | MOUSEEVENTF_VIRTUALDESK;

count = 2;
}
}
SendInput(i + 1, &kid[0], sizeof(kid[0]));
SendInput(count, &kid[0], sizeof(kid[0]));
} else {
INPUT kid;

Expand Down

0 comments on commit b2cdeb2

Please sign in to comment.