mirror of
https://github.com/luanti-org/luanti.git
synced 2025-11-10 11:55:27 +01:00
Remove Irrlicht devices except SDL (#16580)
This commit is contained in:
@@ -2049,10 +2049,10 @@ void Game::updateCameraDirection(CameraOrientation *cam, float dtime)
|
||||
{
|
||||
auto *cur_control = device->getCursorControl();
|
||||
|
||||
/* With CIrrDeviceSDL on Linux and Windows, enabling relative mouse mode
|
||||
somehow results in simulated mouse events being generated from touch events,
|
||||
although SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS are set to 0.
|
||||
Since Minetest has its own code to synthesize mouse events from touch events,
|
||||
/* On Linux and Windows, enabling relative mouse mode somehow results
|
||||
in simulated mouse events being generated from touch events, even though
|
||||
SDL_HINT_MOUSE_TOUCH_EVENTS and SDL_HINT_TOUCH_MOUSE_EVENTS are set to 0.
|
||||
Since we have our own code to synthesize mouse events from touch events,
|
||||
this results in duplicated input. To avoid that, we don't enable relative
|
||||
mouse mode if we're in touchscreen mode. */
|
||||
if (cur_control)
|
||||
|
||||
@@ -143,8 +143,7 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
|
||||
IrrlichtDevice *device = RenderingEngine::get_raw_device();
|
||||
|
||||
bool new_fullscreen = !device->isFullscreen();
|
||||
// Only update the setting if toggling succeeds - it always fails
|
||||
// if Minetest was built without SDL.
|
||||
// Only update the setting if toggling succeeds
|
||||
if (device->setFullscreen(new_fullscreen)) {
|
||||
g_settings->setBool("fullscreen", new_fullscreen);
|
||||
}
|
||||
|
||||
@@ -305,31 +305,24 @@ KeyPress::KeyPress(const std::string &name)
|
||||
|
||||
KeyPress::KeyPress(const SEvent::SKeyInput &in)
|
||||
{
|
||||
if (USE_SDL2) {
|
||||
if (in.SystemKeyCode)
|
||||
scancode.emplace<u32>(in.SystemKeyCode);
|
||||
else
|
||||
scancode.emplace<EKEY_CODE>(in.Key);
|
||||
} else {
|
||||
loadFromKey(in.Key, in.Char);
|
||||
}
|
||||
if (in.SystemKeyCode)
|
||||
scancode.emplace<u32>(in.SystemKeyCode);
|
||||
else
|
||||
scancode.emplace<EKEY_CODE>(in.Key);
|
||||
}
|
||||
|
||||
std::string KeyPress::formatScancode() const
|
||||
{
|
||||
if (USE_SDL2) {
|
||||
if (auto pv = std::get_if<u32>(&scancode))
|
||||
return *pv == 0 ? "" : "SYSTEM_SCANCODE_" + std::to_string(*pv);
|
||||
}
|
||||
if (auto pv = std::get_if<u32>(&scancode))
|
||||
return *pv == 0 ? "" : "SYSTEM_SCANCODE_" + std::to_string(*pv);
|
||||
return "";
|
||||
}
|
||||
|
||||
std::string KeyPress::sym() const
|
||||
{
|
||||
std::string name = lookup_scancode(scancode).Name;
|
||||
if (USE_SDL2 || name.empty())
|
||||
if (auto newname = formatScancode(); !newname.empty())
|
||||
return newname;
|
||||
if (auto newname = formatScancode(); !newname.empty())
|
||||
return newname;
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -353,18 +346,14 @@ wchar_t KeyPress::getKeychar() const
|
||||
|
||||
bool KeyPress::loadFromScancode(const std::string &name)
|
||||
{
|
||||
if (USE_SDL2) {
|
||||
if (!str_starts_with(name, "SYSTEM_SCANCODE_"))
|
||||
return false;
|
||||
char *p;
|
||||
const auto code = strtoul(name.c_str()+16, &p, 10);
|
||||
if (p != name.c_str() + name.size())
|
||||
return false;
|
||||
scancode.emplace<u32>(code);
|
||||
return true;
|
||||
} else {
|
||||
if (!str_starts_with(name, "SYSTEM_SCANCODE_"))
|
||||
return false;
|
||||
}
|
||||
char *p;
|
||||
const auto code = strtoul(name.c_str()+16, &p, 10);
|
||||
if (p != name.c_str() + name.size())
|
||||
return false;
|
||||
scancode.emplace<u32>(code);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unordered_map<std::string, KeyPress> specialKeyCache;
|
||||
|
||||
Reference in New Issue
Block a user