Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion src/video/windows/SDL_windowsevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL
return;
}

SDL_Mouse *mouse = SDL_GetMouse();
if (!mouse) {
return;
}

if (GetMouseMessageSource(rawmouse->ulExtraInformation) != SDL_MOUSE_EVENT_SOURCE_MOUSE) {
return;
}
Expand Down Expand Up @@ -647,14 +652,22 @@ static void WIN_HandleRawMouseInput(Uint64 timestamp, SDL_VideoData *data, HANDL
}
}
}
} else {
} else if (mouse->pen_mouse_events) {
const int MAXIMUM_TABLET_RELATIVE_MOTION = 32;
if (SDL_abs(relX) > MAXIMUM_TABLET_RELATIVE_MOTION ||
SDL_abs(relY) > MAXIMUM_TABLET_RELATIVE_MOTION) {
/* Ignore this motion, probably a pen lift and drop */
} else {
SDL_SendMouseMotion(timestamp, window, mouseID, true, (float)relX, (float)relY);
}
} else {
int screen_x = virtual_desktop ? GetSystemMetrics(SM_XVIRTUALSCREEN) : 0;
int screen_y = virtual_desktop ? GetSystemMetrics(SM_YVIRTUALSCREEN) : 0;

if (!data->raw_input_fake_pen_id) {
data->raw_input_fake_pen_id = SDL_AddPenDevice(timestamp, "raw mouse input", NULL, SDL_malloc(1));
}
SDL_SendPenMotion(timestamp, data->raw_input_fake_pen_id, window, (float)(x + screen_x - window->x), (float)(y + screen_y - window->y));
}

data->last_raw_mouse_position.x = x;
Expand Down
5 changes: 5 additions & 0 deletions src/video/windows/SDL_windowsrawinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ static DWORD WINAPI WIN_RawInputThread(LPVOID param)
WIN_PollRawInput(_this, poll_start);
}

if (_this->internal->raw_input_fake_pen_id) {
SDL_RemovePenDevice(0, _this->internal->raw_input_fake_pen_id);
_this->internal->raw_input_fake_pen_id = 0;
}

devices[0].dwFlags |= RIDEV_REMOVE;
devices[1].dwFlags |= RIDEV_REMOVE;
RegisterRawInputDevices(devices, count, sizeof(devices[0]));
Expand Down
1 change: 1 addition & 0 deletions src/video/windows/SDL_windowsvideo.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ struct SDL_VideoData
bool raw_keyboard_enabled;
bool pending_E1_key_sequence;
Uint32 raw_input_enabled;
SDL_PenID raw_input_fake_pen_id;

WIN_GameInputData *gameinput_context;

Expand Down
Loading