static_cast refactor

This commit is contained in:
lag 2026-03-06 07:58:40 -06:00
parent f5fcf8c04b
commit 36a4bc22c1
7 changed files with 60 additions and 60 deletions

View file

@ -37,14 +37,14 @@ void ChatScreen::removed()
void ChatScreen::tick() void ChatScreen::tick()
{ {
frame++; frame++;
if (cursorIndex > (int)message.length()) if (cursorIndex > static_cast<int>(message.length()))
cursorIndex = (int)message.length(); cursorIndex = static_cast<int>(message.length());
} }
void ChatScreen::handlePasteRequest() void ChatScreen::handlePasteRequest()
{ {
wstring pasted = Screen::getClipboard(); wstring pasted = Screen::getClipboard();
for (size_t i = 0; i < pasted.length() && (int)message.length() < SharedConstants::maxChatLength; i++) for (size_t i = 0; i < pasted.length() && static_cast<int>(message.length()) < SharedConstants::maxChatLength; i++)
{ {
if (isAllowedChatChar(pasted[i])) if (isAllowedChatChar(pasted[i]))
{ {
@ -57,7 +57,7 @@ void ChatScreen::handlePasteRequest()
void ChatScreen::applyHistoryMessage() void ChatScreen::applyHistoryMessage()
{ {
message = s_historyIndex >= 0 ? s_chatHistory[s_historyIndex] : s_historyDraft; message = s_historyIndex >= 0 ? s_chatHistory[s_historyIndex] : s_historyDraft;
cursorIndex = (int)message.length(); cursorIndex = static_cast<int>(message.length());
} }
void ChatScreen::handleHistoryUp() void ChatScreen::handleHistoryUp()
@ -66,7 +66,7 @@ void ChatScreen::handleHistoryUp()
if (s_historyIndex == -1) if (s_historyIndex == -1)
{ {
s_historyDraft = message; s_historyDraft = message;
s_historyIndex = (int)s_chatHistory.size() - 1; s_historyIndex = static_cast<int>(s_chatHistory.size()) - 1;
} }
else if (s_historyIndex > 0) else if (s_historyIndex > 0)
s_historyIndex--; s_historyIndex--;
@ -76,7 +76,7 @@ void ChatScreen::handleHistoryUp()
void ChatScreen::handleHistoryDown() void ChatScreen::handleHistoryDown()
{ {
if (s_chatHistory.empty()) return; if (s_chatHistory.empty()) return;
if (s_historyIndex < (int)s_chatHistory.size() - 1) if (s_historyIndex < static_cast<int>(s_chatHistory.size()) - 1)
s_historyIndex++; s_historyIndex++;
else else
s_historyIndex = -1; s_historyIndex = -1;
@ -121,7 +121,7 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey)
} }
if (eventKey == Keyboard::KEY_RIGHT) if (eventKey == Keyboard::KEY_RIGHT)
{ {
if (cursorIndex < (int)message.length()) if (cursorIndex < static_cast<int>(message.length()))
cursorIndex++; cursorIndex++;
return; return;
} }
@ -131,7 +131,7 @@ void ChatScreen::keyPressed(wchar_t ch, int eventKey)
cursorIndex--; cursorIndex--;
return; return;
} }
if (isAllowedChatChar(ch) && (int)message.length() < SharedConstants::maxChatLength) if (isAllowedChatChar(ch) && static_cast<int>(message.length()) < SharedConstants::maxChatLength)
{ {
message.insert(cursorIndex, 1, ch); message.insert(cursorIndex, 1, ch);
cursorIndex++; cursorIndex++;
@ -172,7 +172,7 @@ void ChatScreen::mouseClicked(int x, int y, int buttonNum)
if (insertLen > 0) if (insertLen > 0)
{ {
message = message.substr(0, cursorIndex) + minecraft->gui->selectedName.substr(0, insertLen) + message.substr(cursorIndex); message = message.substr(0, cursorIndex) + minecraft->gui->selectedName.substr(0, insertLen) + message.substr(cursorIndex);
cursorIndex += (int)insertLen; cursorIndex += static_cast<int>(insertLen);
} }
} }
else else

View file

@ -189,15 +189,15 @@ void Font::renderCharacter(wchar_t c)
} }
if (m_underline) if (m_underline)
renderStyleLine(x0, y1 - 1.0f, xPos + (float)charWidths[c], y1); renderStyleLine(x0, y1 - 1.0f, xPos + static_cast<float>(charWidths[c]), y1);
if (m_strikethrough) if (m_strikethrough)
{ {
float mid = y0 + height * 0.5f; float mid = y0 + height * 0.5f;
renderStyleLine(x0, mid - 0.5f, xPos + (float)charWidths[c], mid + 0.5f); renderStyleLine(x0, mid - 0.5f, xPos + static_cast<float>(charWidths[c]), mid + 0.5f);
} }
xPos += (float) charWidths[c]; xPos += static_cast<float>(charWidths[c]);
} }
void Font::drawShadow(const wstring& str, int x, int y, int color) void Font::drawShadow(const wstring& str, int x, int y, int color)
@ -219,8 +219,8 @@ void Font::drawLiteral(const wstring& str, int x, int y, int color)
if ((color & 0xFC000000) == 0) color |= 0xFF000000; if ((color & 0xFC000000) == 0) color |= 0xFF000000;
textures->bindTexture(m_textureLocation); textures->bindTexture(m_textureLocation);
glColor4f((color >> 16 & 255) / 255.0F, (color >> 8 & 255) / 255.0F, (color & 255) / 255.0F, (color >> 24 & 255) / 255.0F); glColor4f((color >> 16 & 255) / 255.0F, (color >> 8 & 255) / 255.0F, (color & 255) / 255.0F, (color >> 24 & 255) / 255.0F);
xPos = (float)x; xPos = static_cast<float>(x);
yPos = (float)y; yPos = static_cast<float>(y);
wstring cleanStr = sanitize(str); wstring cleanStr = sanitize(str);
for (size_t i = 0; i < cleanStr.length(); ++i) for (size_t i = 0; i < cleanStr.length(); ++i)
renderCharacter(cleanStr.at(i)); renderCharacter(cleanStr.at(i));
@ -247,7 +247,7 @@ static bool isSectionFormatCode(wchar_t ca)
{ {
if ((ca >= L'0' && ca <= L'9') || (ca >= L'a' && ca <= L'f') || (ca >= L'A' && ca <= L'F')) if ((ca >= L'0' && ca <= L'9') || (ca >= L'a' && ca <= L'f') || (ca >= L'A' && ca <= L'F'))
return true; return true;
wchar_t l = (wchar_t)(ca | 32); wchar_t l = static_cast<wchar_t>(ca | 32);
return l == L'l' || l == L'o' || l == L'n' || l == L'm' || l == L'r' || l == L'k'; return l == L'l' || l == L'o' || l == L'n' || l == L'm' || l == L'r' || l == L'k';
} }
@ -260,7 +260,7 @@ void Font::draw(const wstring &str, bool dropShadow)
m_bold = m_italic = m_underline = m_strikethrough = false; m_bold = m_italic = m_underline = m_strikethrough = false;
wstring cleanStr = sanitize(str); wstring cleanStr = sanitize(str);
for (int i = 0; i < (int)cleanStr.length(); ++i) for (int i = 0; i < static_cast<int>(cleanStr.length()); ++i)
{ {
// Map character // Map character
wchar_t c = cleanStr.at(i); wchar_t c = cleanStr.at(i);
@ -282,7 +282,7 @@ void Font::draw(const wstring &str, bool dropShadow)
if (colorN == 16) if (colorN == 16)
{ {
wchar_t l = (wchar_t)(ca | 32); wchar_t l = static_cast<wchar_t>(ca | 32);
if (l == L'l') m_bold = true; if (l == L'l') m_bold = true;
else if (l == L'o') m_italic = true; else if (l == L'o') m_italic = true;
else if (l == L'n') m_underline = true; else if (l == L'n') m_underline = true;
@ -358,7 +358,7 @@ int Font::width(const wstring& str)
{ {
len += charWidths[167]; len += charWidths[167];
if (i + 1 < cleanStr.length()) if (i + 1 < cleanStr.length())
len += charWidths[(unsigned)cleanStr[++i]]; len += charWidths[static_cast<unsigned>(cleanStr[++i])];
} }
} }
else else
@ -374,7 +374,7 @@ int Font::widthLiteral(const wstring& str)
if (cleanStr == L"") return 0; if (cleanStr == L"") return 0;
int len = 0; int len = 0;
for (size_t i = 0; i < cleanStr.length(); ++i) for (size_t i = 0; i < cleanStr.length(); ++i)
len += charWidths[(unsigned)cleanStr.at(i)]; len += charWidths[static_cast<unsigned>(cleanStr.at(i))];
return len; return len;
} }
@ -551,7 +551,7 @@ void Font::setBidirectional(bool bidirectional)
bool Font::AllCharactersValid(const wstring &str) bool Font::AllCharactersValid(const wstring &str)
{ {
for (int i = 0; i < (int)str.length(); ++i) for (int i = 0; i < static_cast<int>(str.length()); ++i)
{ {
wchar_t c = str.at(i); wchar_t c = str.at(i);
@ -596,15 +596,15 @@ void Font::renderFakeCB(IntBuffer *ib)
float uo = (0.0f) / 128.0f; float uo = (0.0f) / 128.0f;
float vo = (0.0f) / 128.0f; float vo = (0.0f) / 128.0f;
t->vertexUV((float)(0), (float)( 0 + s), (float)( 0), (float)( ix / 128.0f + uo), (float)( (iy + s) / 128.0f + vo)); t->vertexUV(static_cast<float>(0), static_cast<float>(0 + s), static_cast<float>(0), static_cast<float>(ix / 128.0f + uo), static_cast<float>((iy + s) / 128.0f + vo));
t->vertexUV((float)(0 + s), (float)( 0 + s), (float)( 0), (float)( (ix + s) / 128.0f + uo), (float)( (iy + s) / 128.0f + vo)); t->vertexUV(static_cast<float>(0 + s), static_cast<float>(0 + s), static_cast<float>(0), static_cast<float>((ix + s) / 128.0f + uo), static_cast<float>((iy + s) / 128.0f + vo));
t->vertexUV((float)(0 + s), (float)( 0), (float)( 0), (float)( (ix + s) / 128.0f + uo), (float)( iy / 128.0f + vo)); t->vertexUV(static_cast<float>(0 + s), static_cast<float>(0), static_cast<float>(0), static_cast<float>((ix + s) / 128.0f + uo), static_cast<float>(iy / 128.0f + vo));
t->vertexUV((float)(0), (float)( 0), (float)( 0), (float)( ix / 128.0f + uo), (float)( iy / 128.0f + vo)); t->vertexUV(static_cast<float>(0), static_cast<float>(0), static_cast<float>(0), static_cast<float>(ix / 128.0f + uo), static_cast<float>(iy / 128.0f + vo));
// target.colorBlit(texture, x + xo, y, color, ix, iy, // target.colorBlit(texture, x + xo, y, color, ix, iy,
// charWidths[chars[i]], 8); // charWidths[chars[i]], 8);
t->end(); t->end();
glTranslatef((float)charWidths[i], 0, 0); glTranslatef(static_cast<float>(charWidths[i]), 0, 0);
} }
else else
{ {

View file

@ -973,7 +973,7 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
#if defined(_WINDOWS64) #if defined(_WINDOWS64)
glPushMatrix(); glPushMatrix();
glTranslatef(0.0f, (float)(screenHeight - iSafezoneYHalf - iTooltipsYOffset - 16 - 3 + 22) - 24.0f, 0.0f); glTranslatef(0.0f, static_cast<float>(screenHeight - iSafezoneYHalf - iTooltipsYOffset - 16 - 3 + 22) - 24.0f, 0.0f);
if(bDisplayGui) if(bDisplayGui)
{ {
@ -988,13 +988,13 @@ void Gui::render(float a, bool mouseFree, int xMouse, int yMouse)
if (t < 0) t = 0; if (t < 0) t = 0;
if (t > 1) t = 1; if (t > 1) t = 1;
t = t * t; t = t * t;
int alpha = (int) (255 * t); int alpha = static_cast<int>(255 * t);
if (isChatting) alpha = 255; if (isChatting) alpha = 255;
if (alpha > 0) if (alpha > 0)
{ {
int x = iSafezoneXHalf+2; int x = iSafezoneXHalf+2;
int y = -((int)i) * 9; int y = -(static_cast<int>(i)) * 9;
if(bTwoPlayerSplitscreen) if(bTwoPlayerSplitscreen)
{ {
y+= iHeightOffset; y+= iHeightOffset;

View file

@ -48,10 +48,10 @@ void GuiComponent::fill(int x0, int y0, int x1, int y1, int col)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(r, g, b, a); glColor4f(r, g, b, a);
t->begin(); t->begin();
t->vertex((float)(x0), (float)( y1), (float)( 0)); t->vertex(static_cast<float>(x0), static_cast<float>(y1), static_cast<float>(0));
t->vertex((float)(x1), (float)( y1), (float)( 0)); t->vertex(static_cast<float>(x1), static_cast<float>(y1), static_cast<float>(0));
t->vertex((float)(x1), (float)( y0), (float)( 0)); t->vertex(static_cast<float>(x1), static_cast<float>(y0), static_cast<float>(0));
t->vertex((float)(x0), (float)( y0), (float)( 0)); t->vertex(static_cast<float>(x0), static_cast<float>(y0), static_cast<float>(0));
t->end(); t->end();
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glDisable(GL_BLEND); glDisable(GL_BLEND);
@ -77,11 +77,11 @@ void GuiComponent::fillGradient(int x0, int y0, int x1, int y1, int col1, int co
Tesselator *t = Tesselator::getInstance(); Tesselator *t = Tesselator::getInstance();
t->begin(); t->begin();
t->color(r1, g1, b1, a1); t->color(r1, g1, b1, a1);
t->vertex((float)(x1), (float)( y0), blitOffset); t->vertex(static_cast<float>(x1), static_cast<float>(y0), blitOffset);
t->vertex((float)(x0), (float)( y0), blitOffset); t->vertex(static_cast<float>(x0), static_cast<float>(y0), blitOffset);
t->color(r2, g2, b2, a2); t->color(r2, g2, b2, a2);
t->vertex((float)(x0), (float)( y1), blitOffset); t->vertex(static_cast<float>(x0), static_cast<float>(y1), blitOffset);
t->vertex((float)(x1), (float)( y1), blitOffset); t->vertex(static_cast<float>(x1), static_cast<float>(y1), blitOffset);
t->end(); t->end();
glShadeModel(GL_FLAT); glShadeModel(GL_FLAT);
@ -122,20 +122,20 @@ void GuiComponent::blit(int x, int y, int sx, int sy, int w, int h)
const float extraShift = 0.75f; const float extraShift = 0.75f;
// 4J - subtracting extraShift (actual screen pixels, so need to compensate for physical & game width) from each x & y coordinate to compensate for centre of pixels in directx vs openGL // 4J - subtracting extraShift (actual screen pixels, so need to compensate for physical & game width) from each x & y coordinate to compensate for centre of pixels in directx vs openGL
float dx = ( extraShift * (float)Minecraft::GetInstance()->width ) / (float)Minecraft::GetInstance()->width_phys; float dx = ( extraShift * static_cast<float>(Minecraft::GetInstance()->width) ) / static_cast<float>(Minecraft::GetInstance()->width_phys);
// 4J - Also factor in the scaling from gui coordinate space to the screen. This varies based on user-selected gui scale, and whether we are in a viewport mode or not // 4J - Also factor in the scaling from gui coordinate space to the screen. This varies based on user-selected gui scale, and whether we are in a viewport mode or not
dx /= Gui::currentGuiScaleFactor; dx /= Gui::currentGuiScaleFactor;
float dy = extraShift / Gui::currentGuiScaleFactor; float dy = extraShift / Gui::currentGuiScaleFactor;
// Ensure that the x/y, width and height are actually pixel aligned at our current scale factor - in particular, for split screen mode with the default (3X) // Ensure that the x/y, width and height are actually pixel aligned at our current scale factor - in particular, for split screen mode with the default (3X)
// scale, we have an overall scale factor of 3 * 0.5 = 1.5, and so any odd pixels won't align // scale, we have an overall scale factor of 3 * 0.5 = 1.5, and so any odd pixels won't align
float fx = (floorf((float)x * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; float fx = (floorf(static_cast<float>(x) * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor;
float fy = (floorf((float)y * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; float fy = (floorf(static_cast<float>(y) * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor;
float fw = (floorf((float)w * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; float fw = (floorf(static_cast<float>(w) * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor;
float fh = (floorf((float)h * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor; float fh = (floorf(static_cast<float>(h) * Gui::currentGuiScaleFactor)) / Gui::currentGuiScaleFactor;
t->vertexUV(fx + 0 - dx, fy + fh - dy, (float)( blitOffset), (float)( (sx + 0) * us), (float)( (sy + h) * vs)); t->vertexUV(fx + 0 - dx, fy + fh - dy, static_cast<float>(blitOffset), static_cast<float>((sx + 0) * us), static_cast<float>((sy + h) * vs));
t->vertexUV(fx + fw - dx, fy + fh - dy, (float)( blitOffset), (float)( (sx + w) * us), (float)( (sy + h) * vs)); t->vertexUV(fx + fw - dx, fy + fh - dy, static_cast<float>(blitOffset), static_cast<float>((sx + w) * us), static_cast<float>((sy + h) * vs));
t->vertexUV(fx + fw - dx, fy + 0 - dy, (float)( blitOffset), (float)( (sx + w) * us), (float)( (sy + 0) * vs)); t->vertexUV(fx + fw - dx, fy + 0 - dy, static_cast<float>(blitOffset), static_cast<float>((sx + w) * us), static_cast<float>((sy + 0) * vs));
t->vertexUV(fx + 0 - dx, fy + 0 - dy, (float)( blitOffset), (float)( (sx + 0) * us), (float)( (sy + 0) * vs)); t->vertexUV(fx + 0 - dx, fy + 0 - dy, static_cast<float>(blitOffset), static_cast<float>((sx + 0) * us), static_cast<float>((sy + 0) * vs));
t->end(); t->end();
} }

View file

@ -49,7 +49,7 @@ wstring Screen::getClipboard()
wstring out; wstring out;
if (h) if (h)
{ {
const wchar_t *p = (const wchar_t *)GlobalLock(h); const wchar_t *p = reinterpret_cast<const wchar_t*>(GlobalLock(h));
if (p) { out = p; GlobalUnlock(h); } if (p) { out = p; GlobalUnlock(h); }
} }
CloseClipboard(); CloseClipboard();
@ -215,10 +215,10 @@ void Screen::updateEvents()
else if (vk == VK_TAB) mappedKey = Keyboard::KEY_TAB; else if (vk == VK_TAB) mappedKey = Keyboard::KEY_TAB;
else if (vk >= 'A' && vk <= 'Z') else if (vk >= 'A' && vk <= 'Z')
{ {
ch = (wchar_t)(vk - 'A' + L'a'); ch = static_cast<wchar_t>(vk - 'A' + L'a');
if (g_KBMInput.IsKeyDown(VK_LSHIFT) || g_KBMInput.IsKeyDown(VK_RSHIFT)) ch = (wchar_t)vk; if (g_KBMInput.IsKeyDown(VK_LSHIFT) || g_KBMInput.IsKeyDown(VK_RSHIFT)) ch = static_cast<wchar_t>(vk);
} }
else if (vk >= '0' && vk <= '9') ch = (wchar_t)vk; else if (vk >= '0' && vk <= '9') ch = static_cast<wchar_t>(vk);
else if (vk == VK_SPACE) ch = L' '; else if (vk == VK_SPACE) ch = L' ';
if (mappedKey != -1) keyPressed(ch, mappedKey); if (mappedKey != -1) keyPressed(ch, mappedKey);
@ -306,10 +306,10 @@ void Screen::renderDirtBackground(int vo)
float s = 32; float s = 32;
t->begin(); t->begin();
t->color(0x404040); t->color(0x404040);
t->vertexUV((float)(0), (float)( height), (float)( 0), (float)( 0), (float)( height / s + vo)); t->vertexUV(static_cast<float>(0), static_cast<float>(height), static_cast<float>(0), static_cast<float>(0), static_cast<float>(height / s + vo));
t->vertexUV((float)(width), (float)( height), (float)( 0), (float)( width / s), (float)( height / s + vo)); t->vertexUV(static_cast<float>(width), static_cast<float>(height), static_cast<float>(0), static_cast<float>(width / s), static_cast<float>(height / s + vo));
t->vertexUV((float)(width), (float)( 0), (float)( 0), (float)( width / s), (float)( 0 + vo)); t->vertexUV(static_cast<float>(width), static_cast<float>(0), static_cast<float>(0), static_cast<float>(width / s), static_cast<float>(0 + vo));
t->vertexUV((float)(0), (float)( 0), (float)( 0), (float)( 0), (float)( 0 + vo)); t->vertexUV(static_cast<float>(0), static_cast<float>(0), static_cast<float>(0), static_cast<float>(0), static_cast<float>(0 + vo));
t->end(); t->end();
#endif #endif
} }

View file

@ -257,8 +257,8 @@ bool KeyboardMouseInput::IsMouseButtonReleased(int button) const
void KeyboardMouseInput::ConsumeMouseDelta(float &dx, float &dy) void KeyboardMouseInput::ConsumeMouseDelta(float &dx, float &dy)
{ {
dx = (float)m_mouseDeltaAccumX; dx = static_cast<float>(m_mouseDeltaAccumX);
dy = (float)m_mouseDeltaAccumY; dy = static_cast<float>(m_mouseDeltaAccumY);
m_mouseDeltaAccumX = 0; m_mouseDeltaAccumX = 0;
m_mouseDeltaAccumY = 0; m_mouseDeltaAccumY = 0;
} }
@ -375,12 +375,12 @@ float KeyboardMouseInput::GetMoveY() const
float KeyboardMouseInput::GetLookX(float sensitivity) const float KeyboardMouseInput::GetLookX(float sensitivity) const
{ {
return (float)m_mouseDeltaX * sensitivity; return static_cast<float>(m_mouseDeltaX) * sensitivity;
} }
float KeyboardMouseInput::GetLookY(float sensitivity) const float KeyboardMouseInput::GetLookY(float sensitivity) const
{ {
return (float)(-m_mouseDeltaY) * sensitivity; return static_cast<float>(-m_mouseDeltaY) * sensitivity;
} }
void KeyboardMouseInput::OnChar(wchar_t c) void KeyboardMouseInput::OnChar(wchar_t c)

View file

@ -575,13 +575,13 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_CHAR: case WM_CHAR:
// Buffer typed characters so UIScene_Keyboard can dispatch them to the Iggy Flash player // Buffer typed characters so UIScene_Keyboard can dispatch them to the Iggy Flash player
if (wParam >= 0x20 || wParam == 0x08 || wParam == 0x0D) // printable chars + backspace + enter if (wParam >= 0x20 || wParam == 0x08 || wParam == 0x0D) // printable chars + backspace + enter
g_KBMInput.OnChar((wchar_t)wParam); g_KBMInput.OnChar(static_cast<wchar_t>(wParam));
break; break;
case WM_KEYDOWN: case WM_KEYDOWN:
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
{ {
int vk = (int)wParam; int vk = static_cast<int>(wParam);
if ((lParam & 0x40000000) && vk != VK_LEFT && vk != VK_RIGHT && vk != VK_BACK) if ((lParam & 0x40000000) && vk != VK_LEFT && vk != VK_RIGHT && vk != VK_BACK)
break; break;
#ifdef _WINDOWS64 #ifdef _WINDOWS64
@ -609,7 +609,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
case WM_KEYUP: case WM_KEYUP:
case WM_SYSKEYUP: case WM_SYSKEYUP:
{ {
int vk = (int)wParam; int vk = static_cast<int>(wParam);
if (vk == VK_SHIFT) if (vk == VK_SHIFT)
vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT; vk = (MapVirtualKey((lParam >> 16) & 0xFF, MAPVK_VSC_TO_VK_EX) == VK_RSHIFT) ? VK_RSHIFT : VK_LSHIFT;
else if (vk == VK_CONTROL) else if (vk == VK_CONTROL)