-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
Window created with SDL_CreateWindow("name", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, WIDTH, HEIGHT, SDL_WINDOW_RESIZABLE)
.
Polled events checked for SDL_MOUSEBUTTONDOWN
.
Many attempts at workarounding did not succeed, eg. neither SDL_WINDOW_MOUSE_FOCUS
nor SDL_RaiseWindow
.
printf
to attached console does let the first mouse click register.
Current solution:
int x, y;
SDL_GetWindowPosition(window, &x, &y);
SDL_WarpMouseGlobal(x + centerX, y + centerY);
INPUT fakeFirstClick[2];
fakeFirstClick[0].type = INPUT_MOUSE;
fakeFirstClick[0].mi.dx = 0;
fakeFirstClick[0].mi.dy = 0;
fakeFirstClick[0].mi.mouseData = 0;
fakeFirstClick[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
fakeFirstClick[0].mi.time = 0;
fakeFirstClick[0].mi.dwExtraInfo = (ULONG_PTR)NULL;
fakeFirstClick[1].type = INPUT_MOUSE;
fakeFirstClick[1].mi.dx = 0;
fakeFirstClick[1].mi.dy = 0;
fakeFirstClick[1].mi.mouseData = 0;
fakeFirstClick[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
fakeFirstClick[1].mi.time = 0;
fakeFirstClick[1].mi.dwExtraInfo = (ULONG_PTR)NULL;
SendInput(2, fakeFirstClick, sizeof(INPUT));
Metadata
Metadata
Assignees
Labels
No labels