1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Clean up MSVC warnings in CIrrDeviceSDL.{h,cpp} (#14872)

The only changes are to add a number of `static_cast`s to make implicit
type conversions explicit.
This commit is contained in:
JosiahWI 2024-07-27 11:28:54 -05:00 committed by GitHub
parent 7625f88a0c
commit ac284e61b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 16 deletions

View file

@ -647,8 +647,9 @@ bool CIrrDeviceSDL::createWindowWithContext()
if (ScaleX != 1.0f || ScaleY != 1.0f) {
// The given window size is in pixels, not in screen coordinates.
// We can only do the conversion now since we didn't know the scale before.
SDL_SetWindowSize(Window, CreationParams.WindowSize.Width / ScaleX,
CreationParams.WindowSize.Height / ScaleY);
SDL_SetWindowSize(Window,
static_cast<int>(CreationParams.WindowSize.Width / ScaleX),
static_cast<int>(CreationParams.WindowSize.Height / ScaleY));
// Re-center, otherwise large, non-maximized windows go offscreen.
SDL_SetWindowPosition(Window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED);
updateSizeAndScale();
@ -717,10 +718,12 @@ bool CIrrDeviceSDL::run()
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.Event = irr::EMIE_MOUSE_MOVED;
MouseX = irrevent.MouseInput.X = SDL_event.motion.x * ScaleX;
MouseY = irrevent.MouseInput.Y = SDL_event.motion.y * ScaleY;
MouseXRel = SDL_event.motion.xrel * ScaleX;
MouseYRel = SDL_event.motion.yrel * ScaleY;
MouseX = irrevent.MouseInput.X =
static_cast<s32>(SDL_event.motion.x * ScaleX);
MouseY = irrevent.MouseInput.Y =
static_cast<s32>(SDL_event.motion.y * ScaleY);
MouseXRel = static_cast<s32>(SDL_event.motion.xrel * ScaleX);
MouseYRel = static_cast<s32>(SDL_event.motion.yrel * ScaleY);
irrevent.MouseInput.ButtonStates = MouseButtonStates;
irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
@ -752,8 +755,8 @@ bool CIrrDeviceSDL::run()
SDL_Keymod keymod = SDL_GetModState();
irrevent.EventType = irr::EET_MOUSE_INPUT_EVENT;
irrevent.MouseInput.X = SDL_event.button.x * ScaleX;
irrevent.MouseInput.Y = SDL_event.button.y * ScaleY;
irrevent.MouseInput.X = static_cast<s32>(SDL_event.button.x * ScaleX);
irrevent.MouseInput.Y = static_cast<s32>(SDL_event.button.y * ScaleY);
irrevent.MouseInput.Shift = (keymod & KMOD_SHIFT) != 0;
irrevent.MouseInput.Control = (keymod & KMOD_CTRL) != 0;
@ -918,8 +921,8 @@ bool CIrrDeviceSDL::run()
irrevent.EventType = EET_TOUCH_INPUT_EVENT;
irrevent.TouchInput.Event = ETIE_PRESSED_DOWN;
irrevent.TouchInput.ID = SDL_event.tfinger.fingerId;
irrevent.TouchInput.X = SDL_event.tfinger.x * Width;
irrevent.TouchInput.Y = SDL_event.tfinger.y * Height;
irrevent.TouchInput.X = static_cast<s32>(SDL_event.tfinger.x * Width);
irrevent.TouchInput.Y = static_cast<s32>(SDL_event.tfinger.y * Height);
CurrentTouchCount++;
irrevent.TouchInput.touchedCount = CurrentTouchCount;
@ -930,8 +933,8 @@ bool CIrrDeviceSDL::run()
irrevent.EventType = EET_TOUCH_INPUT_EVENT;
irrevent.TouchInput.Event = ETIE_MOVED;
irrevent.TouchInput.ID = SDL_event.tfinger.fingerId;
irrevent.TouchInput.X = SDL_event.tfinger.x * Width;
irrevent.TouchInput.Y = SDL_event.tfinger.y * Height;
irrevent.TouchInput.X = static_cast<s32>(SDL_event.tfinger.x * Width);
irrevent.TouchInput.Y = static_cast<s32>(SDL_event.tfinger.y * Height);
irrevent.TouchInput.touchedCount = CurrentTouchCount;
postEventFromUser(irrevent);
@ -941,8 +944,8 @@ bool CIrrDeviceSDL::run()
irrevent.EventType = EET_TOUCH_INPUT_EVENT;
irrevent.TouchInput.Event = ETIE_LEFT_UP;
irrevent.TouchInput.ID = SDL_event.tfinger.fingerId;
irrevent.TouchInput.X = SDL_event.tfinger.x * Width;
irrevent.TouchInput.Y = SDL_event.tfinger.y * Height;
irrevent.TouchInput.X = static_cast<s32>(SDL_event.tfinger.x * Width);
irrevent.TouchInput.Y = static_cast<s32>(SDL_event.tfinger.y * Height);
// To match Android behavior, still count the pointer that was
// just released.
irrevent.TouchInput.touchedCount = CurrentTouchCount;