mirror of
https://github.com/luanti-org/luanti.git
synced 2025-11-07 10:45:18 +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;
|
||||
|
||||
@@ -41,5 +41,4 @@
|
||||
#cmakedefine01 CURSES_HAVE_NCURSESW_CURSES_H
|
||||
#cmakedefine01 BUILD_UNITTESTS
|
||||
#cmakedefine01 BUILD_BENCHMARKS
|
||||
#cmakedefine01 USE_SDL2
|
||||
#cmakedefine01 BUILD_WITH_TRACY
|
||||
|
||||
@@ -129,23 +129,14 @@ void set_default_settings()
|
||||
settings->setDefault("chat_weblink_color", "#8888FF");
|
||||
|
||||
// Keymap
|
||||
#if USE_SDL2
|
||||
#define USEKEY2(name, value, _) settings->setDefault(name, value)
|
||||
#else
|
||||
#define USEKEY2(name, _, value) settings->setDefault(name, value)
|
||||
#endif
|
||||
USEKEY2("keymap_forward", "SYSTEM_SCANCODE_26", "KEY_KEY_W");
|
||||
settings->setDefault("keymap_autoforward", "");
|
||||
USEKEY2("keymap_backward", "SYSTEM_SCANCODE_22", "KEY_KEY_S");
|
||||
USEKEY2("keymap_left", "SYSTEM_SCANCODE_4", "KEY_KEY_A");
|
||||
USEKEY2("keymap_right", "SYSTEM_SCANCODE_7", "KEY_KEY_D");
|
||||
USEKEY2("keymap_jump", "SYSTEM_SCANCODE_44", "KEY_SPACE");
|
||||
#if !USE_SDL2 && defined(__MACH__) && defined(__APPLE__)
|
||||
// Altered settings for CIrrDeviceOSX
|
||||
settings->setDefault("keymap_sneak", "KEY_SHIFT");
|
||||
#else
|
||||
USEKEY2("keymap_sneak", "SYSTEM_SCANCODE_225", "KEY_LSHIFT");
|
||||
#endif
|
||||
settings->setDefault("keymap_dig", "KEY_LBUTTON");
|
||||
settings->setDefault("keymap_place", "KEY_RBUTTON");
|
||||
USEKEY2("keymap_drop", "SYSTEM_SCANCODE_20", "KEY_KEY_Q");
|
||||
|
||||
Reference in New Issue
Block a user