SDL: Always set X, Y, Shift and Control in mouse input events

This commit is contained in:
DS 2022-10-16 17:42:15 +02:00 committed by GitHub
parent e9908ca545
commit 57705d57cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 5 deletions

View File

@ -463,7 +463,9 @@ bool CIrrDeviceSDL::run()
switch ( SDL_event.type )
{
case SDL_MOUSEMOTION:
case SDL_MOUSEMOTION: {
SDL_Keymod keymod = SDL_GetModState();
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
MouseX = irrevent.MouseInput.X = SDL_event.motion.x;
@ -471,20 +473,35 @@ bool CIrrDeviceSDL::run()
MouseXRel = SDL_event.motion.xrel;
MouseYRel = SDL_event.motion.yrel;
irrevent.MouseInput.ButtonStates = MouseButtonStates;
irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
postEventFromUser(irrevent);
break;
case SDL_MOUSEWHEEL:
}
case SDL_MOUSEWHEEL: {
SDL_Keymod keymod = SDL_GetModState();
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.Event = irr::EMIE_MOUSE_WHEEL;
irrevent.MouseInput.Wheel = static_cast<float>(SDL_event.wheel.y);
irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
irrevent.MouseInput.X = MouseX;
irrevent.MouseInput.Y = MouseY;
postEventFromUser(irrevent);
break;
}
case SDL_MOUSEBUTTONDOWN:
case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONUP: {
SDL_Keymod keymod = SDL_GetModState();
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.X = SDL_event.button.x;
irrevent.MouseInput.Y = SDL_event.button.y;
irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
@ -579,6 +596,7 @@ bool CIrrDeviceSDL::run()
}
}
break;
}
case SDL_TEXTINPUT:
{