mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-30 19:22:14 +00:00
Remove irr
namespace (#16309)
This commit is contained in:
parent
7e22c72492
commit
61551cfc3a
381 changed files with 680 additions and 1632 deletions
|
@ -38,8 +38,6 @@
|
|||
#include "CWGLManager.h"
|
||||
#endif
|
||||
|
||||
namespace irr
|
||||
{
|
||||
struct SJoystickWin32Control
|
||||
{
|
||||
CIrrDeviceWin32 *Device;
|
||||
|
@ -74,7 +72,7 @@ struct SJoystickWin32Control
|
|||
|
||||
void pollJoysticks();
|
||||
bool activateJoysticks(core::array<SJoystickInfo> &joystickInfo);
|
||||
irr::core::stringc findJoystickName(int index, const JOYCAPS &caps) const;
|
||||
core::stringc findJoystickName(int index, const JOYCAPS &caps) const;
|
||||
};
|
||||
|
||||
SJoystickWin32Control::SJoystickWin32Control(CIrrDeviceWin32 *dev) :
|
||||
|
@ -196,7 +194,7 @@ void SJoystickWin32Control::pollJoysticks()
|
|||
if (!FAILED(ActiveJoysticks[joystick].lpdijoy->GetDeviceState(sizeof(info), &info))) {
|
||||
SEvent event;
|
||||
|
||||
event.EventType = irr::EET_JOYSTICK_INPUT_EVENT;
|
||||
event.EventType = EET_JOYSTICK_INPUT_EVENT;
|
||||
event.JoystickEvent.Joystick = (u8)joystick;
|
||||
|
||||
event.JoystickEvent.POV = (u16)info.rgdwPOV[0];
|
||||
|
@ -292,7 +290,7 @@ void SJoystickWin32Control::pollJoysticks()
|
|||
if (JOYERR_NOERROR == joyGetPosEx(ActiveJoysticks[joystick].Index, &info)) {
|
||||
SEvent event;
|
||||
|
||||
event.EventType = irr::EET_JOYSTICK_INPUT_EVENT;
|
||||
event.EventType = EET_JOYSTICK_INPUT_EVENT;
|
||||
event.JoystickEvent.Joystick = (u8)joystick;
|
||||
|
||||
event.JoystickEvent.POV = (u16)info.dwPOV;
|
||||
|
@ -342,13 +340,13 @@ void SJoystickWin32Control::pollJoysticks()
|
|||
|
||||
/** This function is ported from SDL and released under zlib-license:
|
||||
* Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> */
|
||||
irr::core::stringc SJoystickWin32Control::findJoystickName(int index, const JOYCAPS &caps) const
|
||||
core::stringc SJoystickWin32Control::findJoystickName(int index, const JOYCAPS &caps) const
|
||||
{
|
||||
#if defined _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
|
||||
// As a default use the name given in the joystick structure.
|
||||
// It is always the same name, independent of joystick.
|
||||
irr::core::stringc result(caps.szPname);
|
||||
core::stringc result(caps.szPname);
|
||||
|
||||
core::stringc key = core::stringc(REGSTR_PATH_JOYCONFIG) + "\\" + caps.szRegKey + "\\" + REGSTR_KEY_JOYCURR;
|
||||
HKEY hTopKey = HKEY_LOCAL_MACHINE;
|
||||
|
@ -469,25 +467,24 @@ bool SJoystickWin32Control::activateJoysticks(core::array<SJoystickInfo> &joysti
|
|||
return false;
|
||||
#endif // _IRR_COMPILE_WITH_JOYSTICK_EVENTS_
|
||||
}
|
||||
} // end namespace irr
|
||||
|
||||
namespace
|
||||
{
|
||||
struct SEnvMapper
|
||||
{
|
||||
HWND hWnd;
|
||||
irr::CIrrDeviceWin32 *irrDev;
|
||||
CIrrDeviceWin32 *irrDev;
|
||||
};
|
||||
// NOTE: This is global. We can have more than one Irrlicht Device at same time.
|
||||
irr::core::array<SEnvMapper> EnvMap;
|
||||
core::array<SEnvMapper> EnvMap;
|
||||
|
||||
HKL KEYBOARD_INPUT_HKL = 0;
|
||||
}
|
||||
|
||||
irr::CIrrDeviceWin32 *getDeviceFromHWnd(HWND hWnd)
|
||||
CIrrDeviceWin32 *getDeviceFromHWnd(HWND hWnd)
|
||||
{
|
||||
const irr::u32 end = EnvMap.size();
|
||||
for (irr::u32 i = 0; i < end; ++i) {
|
||||
const u32 end = EnvMap.size();
|
||||
for (u32 i = 0; i < end; ++i) {
|
||||
const SEnvMapper &env = EnvMap[i];
|
||||
if (env.hWnd == hWnd)
|
||||
return env.irrDev;
|
||||
|
@ -502,29 +499,29 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
#define WHEEL_DELTA 120
|
||||
#endif
|
||||
|
||||
irr::CIrrDeviceWin32 *dev = 0;
|
||||
irr::SEvent event;
|
||||
CIrrDeviceWin32 *dev = 0;
|
||||
SEvent event;
|
||||
|
||||
static irr::s32 ClickCount = 0;
|
||||
static s32 ClickCount = 0;
|
||||
if (GetCapture() != hWnd && ClickCount > 0)
|
||||
ClickCount = 0;
|
||||
|
||||
struct messageMap
|
||||
{
|
||||
irr::s32 group;
|
||||
s32 group;
|
||||
UINT winMessage;
|
||||
irr::s32 irrMessage;
|
||||
s32 irrMessage;
|
||||
};
|
||||
|
||||
static messageMap mouseMap[] = {
|
||||
{0, WM_LBUTTONDOWN, irr::EMIE_LMOUSE_PRESSED_DOWN},
|
||||
{1, WM_LBUTTONUP, irr::EMIE_LMOUSE_LEFT_UP},
|
||||
{0, WM_RBUTTONDOWN, irr::EMIE_RMOUSE_PRESSED_DOWN},
|
||||
{1, WM_RBUTTONUP, irr::EMIE_RMOUSE_LEFT_UP},
|
||||
{0, WM_MBUTTONDOWN, irr::EMIE_MMOUSE_PRESSED_DOWN},
|
||||
{1, WM_MBUTTONUP, irr::EMIE_MMOUSE_LEFT_UP},
|
||||
{2, WM_MOUSEMOVE, irr::EMIE_MOUSE_MOVED},
|
||||
{3, WM_MOUSEWHEEL, irr::EMIE_MOUSE_WHEEL},
|
||||
{0, WM_LBUTTONDOWN, EMIE_LMOUSE_PRESSED_DOWN},
|
||||
{1, WM_LBUTTONUP, EMIE_LMOUSE_LEFT_UP},
|
||||
{0, WM_RBUTTONDOWN, EMIE_RMOUSE_PRESSED_DOWN},
|
||||
{1, WM_RBUTTONUP, EMIE_RMOUSE_LEFT_UP},
|
||||
{0, WM_MBUTTONDOWN, EMIE_MMOUSE_PRESSED_DOWN},
|
||||
{1, WM_MBUTTONUP, EMIE_MMOUSE_LEFT_UP},
|
||||
{2, WM_MOUSEMOVE, EMIE_MOUSE_MOVED},
|
||||
{3, WM_MOUSEWHEEL, EMIE_MOUSE_WHEEL},
|
||||
{-1, 0, 0},
|
||||
};
|
||||
|
||||
|
@ -545,8 +542,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
}
|
||||
|
||||
event.EventType = irr::EET_MOUSE_INPUT_EVENT;
|
||||
event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT)m->irrMessage;
|
||||
event.EventType = EET_MOUSE_INPUT_EVENT;
|
||||
event.MouseInput.Event = (EMOUSE_INPUT_EVENT)m->irrMessage;
|
||||
event.MouseInput.X = (short)LOWORD(lParam);
|
||||
event.MouseInput.Y = (short)HIWORD(lParam);
|
||||
event.MouseInput.Shift = ((LOWORD(wParam) & MK_SHIFT) != 0);
|
||||
|
@ -555,11 +552,11 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
event.MouseInput.ButtonStates = wParam & (MK_LBUTTON | MK_RBUTTON);
|
||||
// middle and extra buttons
|
||||
if (wParam & MK_MBUTTON)
|
||||
event.MouseInput.ButtonStates |= irr::EMBSM_MIDDLE;
|
||||
event.MouseInput.ButtonStates |= EMBSM_MIDDLE;
|
||||
if (wParam & MK_XBUTTON1)
|
||||
event.MouseInput.ButtonStates |= irr::EMBSM_EXTRA1;
|
||||
event.MouseInput.ButtonStates |= EMBSM_EXTRA1;
|
||||
if (wParam & MK_XBUTTON2)
|
||||
event.MouseInput.ButtonStates |= irr::EMBSM_EXTRA2;
|
||||
event.MouseInput.ButtonStates |= EMBSM_EXTRA2;
|
||||
event.MouseInput.Wheel = 0.f;
|
||||
|
||||
// wheel
|
||||
|
@ -570,20 +567,20 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
ClientToScreen(hWnd, &p);
|
||||
event.MouseInput.X -= p.x;
|
||||
event.MouseInput.Y -= p.y;
|
||||
event.MouseInput.Wheel = ((irr::f32)((short)HIWORD(wParam))) / (irr::f32)WHEEL_DELTA;
|
||||
event.MouseInput.Wheel = ((f32)((short)HIWORD(wParam))) / (f32)WHEEL_DELTA;
|
||||
}
|
||||
|
||||
dev = getDeviceFromHWnd(hWnd);
|
||||
if (dev) {
|
||||
dev->postEventFromUser(event);
|
||||
|
||||
if (event.MouseInput.Event >= irr::EMIE_LMOUSE_PRESSED_DOWN && event.MouseInput.Event <= irr::EMIE_MMOUSE_PRESSED_DOWN) {
|
||||
irr::u32 clicks = dev->checkSuccessiveClicks(event.MouseInput.X, event.MouseInput.Y, event.MouseInput.Event);
|
||||
if (event.MouseInput.Event >= EMIE_LMOUSE_PRESSED_DOWN && event.MouseInput.Event <= EMIE_MMOUSE_PRESSED_DOWN) {
|
||||
u32 clicks = dev->checkSuccessiveClicks(event.MouseInput.X, event.MouseInput.Y, event.MouseInput.Event);
|
||||
if (clicks == 2) {
|
||||
event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT)(irr::EMIE_LMOUSE_DOUBLE_CLICK + event.MouseInput.Event - irr::EMIE_LMOUSE_PRESSED_DOWN);
|
||||
event.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_DOUBLE_CLICK + event.MouseInput.Event - EMIE_LMOUSE_PRESSED_DOWN);
|
||||
dev->postEventFromUser(event);
|
||||
} else if (clicks == 3) {
|
||||
event.MouseInput.Event = (irr::EMOUSE_INPUT_EVENT)(irr::EMIE_LMOUSE_TRIPLE_CLICK + event.MouseInput.Event - irr::EMIE_LMOUSE_PRESSED_DOWN);
|
||||
event.MouseInput.Event = (EMOUSE_INPUT_EVENT)(EMIE_LMOUSE_TRIPLE_CLICK + event.MouseInput.Event - EMIE_LMOUSE_PRESSED_DOWN);
|
||||
dev->postEventFromUser(event);
|
||||
}
|
||||
}
|
||||
|
@ -608,23 +605,23 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
case WM_KEYUP: {
|
||||
BYTE allKeys[256];
|
||||
|
||||
event.EventType = irr::EET_KEY_INPUT_EVENT;
|
||||
event.KeyInput.Key = (irr::EKEY_CODE)wParam;
|
||||
event.EventType = EET_KEY_INPUT_EVENT;
|
||||
event.KeyInput.Key = (EKEY_CODE)wParam;
|
||||
event.KeyInput.PressedDown = (message == WM_KEYDOWN || message == WM_SYSKEYDOWN);
|
||||
|
||||
if (event.KeyInput.Key == irr::KEY_SHIFT) {
|
||||
event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey(((lParam >> 16) & 255), MAPVK_VSC_TO_VK_EX);
|
||||
if (event.KeyInput.Key == KEY_SHIFT) {
|
||||
event.KeyInput.Key = (EKEY_CODE)MapVirtualKey(((lParam >> 16) & 255), MAPVK_VSC_TO_VK_EX);
|
||||
}
|
||||
if (event.KeyInput.Key == irr::KEY_CONTROL) {
|
||||
event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey(((lParam >> 16) & 255), MAPVK_VSC_TO_VK_EX);
|
||||
if (event.KeyInput.Key == KEY_CONTROL) {
|
||||
event.KeyInput.Key = (EKEY_CODE)MapVirtualKey(((lParam >> 16) & 255), MAPVK_VSC_TO_VK_EX);
|
||||
// some keyboards will just return LEFT for both - left and right keys. So also check extend bit.
|
||||
if (lParam & 0x1000000)
|
||||
event.KeyInput.Key = irr::KEY_RCONTROL;
|
||||
event.KeyInput.Key = KEY_RCONTROL;
|
||||
}
|
||||
if (event.KeyInput.Key == irr::KEY_MENU) {
|
||||
event.KeyInput.Key = (irr::EKEY_CODE)MapVirtualKey(((lParam >> 16) & 255), MAPVK_VSC_TO_VK_EX);
|
||||
if (event.KeyInput.Key == KEY_MENU) {
|
||||
event.KeyInput.Key = (EKEY_CODE)MapVirtualKey(((lParam >> 16) & 255), MAPVK_VSC_TO_VK_EX);
|
||||
if (lParam & 0x1000000)
|
||||
event.KeyInput.Key = irr::KEY_RMENU;
|
||||
event.KeyInput.Key = KEY_RMENU;
|
||||
}
|
||||
|
||||
GetKeyboardState(allKeys);
|
||||
|
@ -677,7 +674,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
break;
|
||||
|
||||
case WM_USER:
|
||||
event.EventType = irr::EET_USER_EVENT;
|
||||
event.EventType = EET_USER_EVENT;
|
||||
event.UserEvent.UserData1 = static_cast<size_t>(wParam);
|
||||
event.UserEvent.UserData2 = static_cast<size_t>(lParam);
|
||||
dev = getDeviceFromHWnd(hWnd);
|
||||
|
@ -704,9 +701,6 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
|||
return DefWindowProcW(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
namespace irr
|
||||
{
|
||||
|
||||
//! constructor
|
||||
CIrrDeviceWin32::CIrrDeviceWin32(const SIrrlichtCreationParameters ¶ms) :
|
||||
CIrrDeviceStub(params), HWnd(0), Resized(false),
|
||||
|
@ -958,7 +952,7 @@ void CIrrDeviceWin32::resizeIfNecessary()
|
|||
snprintf_irr(tmp, sizeof(tmp), "Resizing window (%ld %ld)", r.right, r.bottom);
|
||||
os::Printer::log(tmp);
|
||||
|
||||
getVideoDriver()->OnResize(irr::core::dimension2du((u32)r.right, (u32)r.bottom));
|
||||
getVideoDriver()->OnResize(core::dimension2du((u32)r.right, (u32)r.bottom));
|
||||
getWin32CursorControl()->OnResize(getVideoDriver()->getScreenSize());
|
||||
}
|
||||
|
||||
|
@ -1101,7 +1095,7 @@ void CIrrDeviceWin32::OnResized()
|
|||
}
|
||||
|
||||
//! Resize the render window.
|
||||
void CIrrDeviceWin32::setWindowSize(const irr::core::dimension2d<u32> &size)
|
||||
void CIrrDeviceWin32::setWindowSize(const core::dimension2d<u32> &size)
|
||||
{
|
||||
if (ExternalWindow || !getVideoDriver() || CreationParams.Fullscreen)
|
||||
return;
|
||||
|
@ -1253,7 +1247,7 @@ float CIrrDeviceWin32::getDisplayDensity() const
|
|||
|
||||
// Convert an Irrlicht texture to a Windows cursor
|
||||
// Based on http://www.codeguru.com/cpp/w-p/win32/cursors/article.php/c4529/
|
||||
HCURSOR CIrrDeviceWin32::TextureToCursor(HWND hwnd, irr::video::ITexture *tex, const core::rect<s32> &sourceRect, const core::position2d<s32> &hotspot)
|
||||
HCURSOR CIrrDeviceWin32::TextureToCursor(HWND hwnd, video::ITexture *tex, const core::rect<s32> &sourceRect, const core::position2d<s32> &hotspot)
|
||||
{
|
||||
//
|
||||
// create the bitmaps needed for cursors from the texture
|
||||
|
@ -1389,9 +1383,9 @@ gui::ECURSOR_ICON CIrrDeviceWin32::CCursorControl::addIcon(const gui::SCursorSpr
|
|||
cW32.FrameTime = icon.SpriteBank->getSprites()[icon.SpriteId].frameTime;
|
||||
|
||||
for (u32 i = 0; i < icon.SpriteBank->getSprites()[icon.SpriteId].Frames.size(); ++i) {
|
||||
irr::u32 texId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].textureNumber;
|
||||
irr::u32 rectId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].rectNumber;
|
||||
irr::core::rect<s32> rectIcon = icon.SpriteBank->getPositions()[rectId];
|
||||
u32 texId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].textureNumber;
|
||||
u32 rectId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].rectNumber;
|
||||
core::rect<s32> rectIcon = icon.SpriteBank->getPositions()[rectId];
|
||||
|
||||
HCURSOR hc = Device->TextureToCursor(HWnd, icon.SpriteBank->getTexture(texId), rectIcon, icon.HotSpot);
|
||||
cW32.Frames.push_back(CursorFrameW32(hc));
|
||||
|
@ -1416,9 +1410,9 @@ void CIrrDeviceWin32::CCursorControl::changeIcon(gui::ECURSOR_ICON iconId, const
|
|||
CursorW32 cW32;
|
||||
cW32.FrameTime = icon.SpriteBank->getSprites()[icon.SpriteId].frameTime;
|
||||
for (u32 i = 0; i < icon.SpriteBank->getSprites()[icon.SpriteId].Frames.size(); ++i) {
|
||||
irr::u32 texId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].textureNumber;
|
||||
irr::u32 rectId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].rectNumber;
|
||||
irr::core::rect<s32> rectIcon = icon.SpriteBank->getPositions()[rectId];
|
||||
u32 texId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].textureNumber;
|
||||
u32 rectId = icon.SpriteBank->getSprites()[icon.SpriteId].Frames[i].rectNumber;
|
||||
core::rect<s32> rectIcon = icon.SpriteBank->getPositions()[rectId];
|
||||
|
||||
HCURSOR hc = Device->TextureToCursor(HWnd, icon.SpriteBank->getTexture(texId), rectIcon, icon.HotSpot);
|
||||
cW32.Frames.push_back(CursorFrameW32(hc));
|
||||
|
@ -1439,6 +1433,4 @@ core::dimension2di CIrrDeviceWin32::CCursorControl::getSupportedIconSize() const
|
|||
return result;
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
||||
#endif // _IRR_COMPILE_WITH_WINDOWS_DEVICE_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue