Skip to content

Commit

Permalink
minetest: allow configurable touchscreen
Browse files Browse the repository at this point in the history
Signed-off-by: David Heidelberg <[email protected]>
  • Loading branch information
okias committed Dec 6, 2023
1 parent 55f40a7 commit f640f7c
Show file tree
Hide file tree
Showing 19 changed files with 164 additions and 245 deletions.
5 changes: 5 additions & 0 deletions builtin/settingtypes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ invert_hotbar_mouse_wheel (Hotbar: Invert mouse wheel direction) bool false

[*Touchscreen]

# Enables the touch screen.
# If disabled, touchscreen wouldn't be usable in-game
# Changing this setting requires a restart.
enable_touch (Enable Touchscreen) bool true

# The length in pixels it takes for touchscreen interaction to start.
#
# Requires: touchscreen_gui
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ if(BUILD_CLIENT AND ENABLE_SOUND)
endif()
endif()

option(ENABLE_TOUCH "Enable Touchscreen support" FALSE)
option(ENABLE_TOUCH "Enable touchscreen by default" FALSE)
if(ENABLE_TOUCH)
add_definitions(-DHAVE_TOUCHSCREENGUI)
add_definitions(-DENABLE_TOUCH)
endif()

if(BUILD_CLIENT)
Expand Down
16 changes: 8 additions & 8 deletions src/client/clientlauncher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,10 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
m_rendering_engine->get_video_driver()->setTextureCreationFlag(
video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map"));

#ifdef HAVE_TOUCHSCREENGUI
receiver->m_touchscreengui = new TouchScreenGUI(m_rendering_engine->get_raw_device(), receiver);
g_touchscreengui = receiver->m_touchscreengui;
#endif
if (g_settings->getBool("enable_touch")) {
g_touchscreengui = receiver->m_touchscreengui;
} else

the_game(
kill,
Expand All @@ -286,11 +286,11 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)

m_rendering_engine->get_scene_manager()->clear();

#ifdef HAVE_TOUCHSCREENGUI
delete g_touchscreengui;
g_touchscreengui = NULL;
receiver->m_touchscreengui = NULL;
#endif
if (g_settings->getBool("enable_touch")) {
delete g_touchscreengui;
g_touchscreengui = NULL;
receiver->m_touchscreengui = NULL;
}

// If no main menu, show error and exit
if (skip_main_menu) {
Expand Down
Loading

0 comments on commit f640f7c

Please sign in to comment.