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

@ -270,7 +270,7 @@ bool CIrrDeviceSDL::createWindow()
{
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
}
}
SDL_CreateWindowAndRenderer(0, 0, SDL_Flags, &Window, &Renderer); // 0,0 will use the canvas size
@ -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:
{
@ -926,7 +944,7 @@ void CIrrDeviceSDL::setResizable(bool resize)
os::Printer::log("Resizable not available on the web." , ELL_WARNING);
return;
#else // !_IRR_EMSCRIPTEN_PLATFORM_
if (resize != Resizable) {
if (resize != Resizable) {
if (resize)
SDL_Flags |= SDL_WINDOW_RESIZABLE;
else