Auto-toggle TouchControls in-game when receiving touch/mouse input

This commit is contained in:
Gregor Parzefall 2024-04-13 18:39:14 +02:00
parent 28d8a00173
commit fb059f1e30
17 changed files with 160 additions and 89 deletions

View File

@ -19,7 +19,7 @@
local BASE_SPACING = 0.1
local function get_scroll_btn_width()
return core.settings:get_bool("enable_touch") and 0.8 or 0.5
return core.settings:get_bool("gui_touch") and 0.8 or 0.5
end
local function buttonbar_formspec(self)

View File

@ -190,7 +190,7 @@ local function get_info_formspec(text)
return table.concat({
"formspec_version[6]",
"size[15.75,9.5]",
core.settings:get_bool("enable_touch") and "padding[0.01,0.01]" or "position[0.5,0.55]",
core.settings:get_bool("gui_touch") and "padding[0.01,0.01]" or "position[0.5,0.55]",
"label[4,4.35;", text, "]",
"container[0,", H - 0.8 - 0.375, "]",
@ -221,7 +221,7 @@ local function get_formspec(dlgdata)
local formspec = {
"formspec_version[6]",
"size[15.75,9.5]",
core.settings:get_bool("enable_touch") and "padding[0.01,0.01]" or "position[0.5,0.55]",
core.settings:get_bool("gui_touch") and "padding[0.01,0.01]" or "position[0.5,0.55]",
"style[status,downloading,queued;border=false]",
@ -472,7 +472,7 @@ end
local function handle_events(event)
if event == "DialogShow" then
-- On touchscreen, don't show the "MINETEST" header behind the dialog.
mm_game_theme.set_engine(core.settings:get_bool("enable_touch"))
mm_game_theme.set_engine(core.settings:get_bool("gui_touch"))
-- If ContentDB is already loaded, auto-install packages here.
do_auto_install()

View File

@ -313,11 +313,14 @@ local function check_requirements(name, requires)
local video_driver = core.get_active_driver()
local shaders_support = video_driver == "opengl" or video_driver == "opengl3" or video_driver == "ogles2"
local touch_controls = core.settings:get("touch_controls")
local special = {
android = PLATFORM == "Android",
desktop = PLATFORM ~= "Android",
touchscreen_gui = core.settings:get_bool("enable_touch"),
keyboard_mouse = not core.settings:get_bool("enable_touch"),
-- When touch_controls is "auto", we don't which input method will be used,
-- so we show settings for both.
touchscreen = touch_controls == "auto" or core.is_yes(touch_controls),
keyboard_mouse = touch_controls == "auto" or not core.is_yes(touch_controls),
shaders_support = shaders_support,
shaders = core.settings:get_bool("enable_shaders") and shaders_support,
opengl = video_driver == "opengl",
@ -449,13 +452,13 @@ local function get_formspec(dialogdata)
local extra_h = 1 -- not included in tabsize.height
local tabsize = {
width = core.settings:get_bool("enable_touch") and 16.5 or 15.5,
height = core.settings:get_bool("enable_touch") and (10 - extra_h) or 12,
width = core.settings:get_bool("gui_touch") and 16.5 or 15.5,
height = core.settings:get_bool("gui_touch") and (10 - extra_h) or 12,
}
local scrollbar_w = core.settings:get_bool("enable_touch") and 0.6 or 0.4
local scrollbar_w = core.settings:get_bool("gui_touch") and 0.6 or 0.4
local left_pane_width = core.settings:get_bool("enable_touch") and 4.5 or 4.25
local left_pane_width = core.settings:get_bool("gui_touch") and 4.5 or 4.25
local left_pane_padding = 0.25
local search_width = left_pane_width + scrollbar_w - (0.75 * 2)
@ -469,7 +472,7 @@ local function get_formspec(dialogdata)
local fs = {
"formspec_version[6]",
"size[", tostring(tabsize.width), ",", tostring(tabsize.height + extra_h), "]",
core.settings:get_bool("enable_touch") and "padding[0.01,0.01]" or "",
core.settings:get_bool("gui_touch") and "padding[0.01,0.01]" or "",
"bgcolor[#0000]",
-- HACK: this is needed to allow resubmitting the same formspec
@ -618,6 +621,18 @@ function write_settings_early()
end
end
local function regenerate_page_list(dialogdata)
local suggested_page_id = update_filtered_pages(dialogdata.query)
dialogdata.components = nil
if not filtered_page_by_id[dialogdata.page_id] then
dialogdata.leftscroll = 0
dialogdata.rightscroll = 0
dialogdata.page_id = suggested_page_id
end
end
local function buttonhandler(this, fields)
local dialogdata = this.data
@ -642,27 +657,7 @@ local function buttonhandler(this, fields)
local value = core.is_yes(fields.show_advanced)
core.settings:set_bool("show_advanced", value)
write_settings_early()
end
-- enable_touch is a checkbox in a setting component. We handle this
-- setting differently so we can hide/show pages using the next if-statement
if fields.enable_touch ~= nil then
local value = core.is_yes(fields.enable_touch)
core.settings:set_bool("enable_touch", value)
write_settings_early()
end
if fields.show_advanced ~= nil or fields.enable_touch ~= nil then
local suggested_page_id = update_filtered_pages(dialogdata.query)
dialogdata.components = nil
if not filtered_page_by_id[dialogdata.page_id] then
dialogdata.leftscroll = 0
dialogdata.rightscroll = 0
dialogdata.page_id = suggested_page_id
end
regenerate_page_list(dialogdata)
return true
end
@ -695,20 +690,26 @@ local function buttonhandler(this, fields)
end
end
for i, comp in ipairs(dialogdata.components) do
if comp.on_submit and comp:on_submit(fields, this) then
write_settings_early()
local function after_setting_change(comp)
write_settings_early()
if comp.setting.name == "touch_controls" then
-- Changing the "touch_controls" setting may result in a different
-- page list.
regenerate_page_list(dialogdata)
else
-- Clear components so they regenerate
dialogdata.components = nil
end
end
for i, comp in ipairs(dialogdata.components) do
if comp.on_submit and comp:on_submit(fields, this) then
after_setting_change(comp)
return true
end
if comp.setting and fields["reset_" .. i] then
core.settings:remove(comp.setting.name)
write_settings_early()
-- Clear components so they regenerate
dialogdata.components = nil
after_setting_change(comp)
return true
end
end

View File

@ -94,7 +94,7 @@ function singleplayer_refresh_gamebar()
local btnbar = buttonbar_create(
"game_button_bar",
core.settings:get_bool("enable_touch") and {x = 0, y = 7.25} or {x = 0, y = 7.475},
core.settings:get_bool("gui_touch") and {x = 0, y = 7.25} or {x = 0, y = 7.475},
{x = 15.5, y = 1.25},
"#000000",
game_buttonbar_button_handler)

View File

@ -61,7 +61,7 @@
#
# # This is a comment
# #
# # Requires: shaders, enable_dynamic_shadows, !touchscreen_gui
# # Requires: shaders, enable_dynamic_shadows, !touchscreen
# name (Readable name) type type_args
#
# A requirement can be the name of a boolean setting or an engine-defined value.
@ -72,7 +72,7 @@
# * shaders_support (a video driver that supports shaders, may not be enabled)
# * shaders (both enable_shaders and shaders_support)
# * desktop / android
# * touchscreen_gui / keyboard_mouse
# * touchscreen / keyboard_mouse
# * opengl / gles
# * You can negate any requirement by prepending with !
#
@ -152,40 +152,42 @@ invert_hotbar_mouse_wheel (Hotbar: Invert mouse wheel direction) bool false
[*Touchscreen]
# Enables touchscreen mode, allowing you to play the game with a touchscreen.
enable_touch (Enable touchscreen) bool true
# Enables the touchscreen controls, allowing you to play the game with a touchscreen.
# "auto" means that the touchscreen controls will be enabled and disabled
# automatically depending on the last used input method.
touch_controls (Enable touchscreen controls) enum auto auto,true,false
# Touchscreen sensitivity multiplier.
#
# Requires: touchscreen_gui
# Requires: touchscreen
touchscreen_sensitivity (Touchscreen sensitivity) float 0.2 0.001 10.0
# The length in pixels after which a touch interaction is considered movement.
#
# Requires: touchscreen_gui
# Requires: touchscreen
touchscreen_threshold (Movement threshold) int 20 0 100
# The delay in milliseconds after which a touch interaction is considered a long tap.
#
# Requires: touchscreen_gui
# Requires: touchscreen
touch_long_tap_delay (Threshold for long taps) int 400 100 1000
# Use crosshair to select object instead of whole screen.
# If enabled, a crosshair will be shown and will be used for selecting object.
#
# Requires: touchscreen_gui
# Requires: touchscreen
touch_use_crosshair (Use crosshair for touch screen) bool false
# Fixes the position of virtual joystick.
# If disabled, virtual joystick will center to first-touch's position.
#
# Requires: touchscreen_gui
# Requires: touchscreen
fixed_virtual_joystick (Fixed virtual joystick) bool false
# Use virtual joystick to trigger "Aux1" button.
# If enabled, virtual joystick will also tap "Aux1" button when out of main circle.
#
# Requires: touchscreen_gui
# Requires: touchscreen
virtual_joystick_triggers_aux1 (Virtual joystick triggers Aux1 button) bool false
# The gesture for for punching players/entities.
@ -198,7 +200,7 @@ virtual_joystick_triggers_aux1 (Virtual joystick triggers Aux1 button) bool fals
# Known from the classic Minetest mobile controls.
# Combat is more or less impossible.
#
# Requires: touchscreen_gui
# Requires: touchscreen
touch_punch_gesture (Punch gesture) enum short_tap short_tap,long_tap
@ -685,6 +687,10 @@ language (Language) enum ,be,bg,ca,cs,da,de,el,en,eo,es,et,eu,fi,fr,gd,gl,hu,i
[**GUI]
# When enabled, the GUI is optimized to be more usable on touchscreens.
# Whether this is enabled by default depends on your hardware.
gui_touch (Optimize GUI for touchscreens) bool false
# Scale GUI by a user specified value.
# Use a nearest-neighbor-anti-alias filter to scale the GUI.
# This will smooth over some of the rough edges, and blend

View File

@ -7,6 +7,7 @@
#include "ILogger.h"
#include "Keycodes.h"
#include "irrString.h"
#include <cstring>
namespace irr
{
@ -297,6 +298,11 @@ enum EGUI_EVENT_TYPE
//! SEvents hold information about an event. See irr::IEventReceiver for details on event handling.
struct SEvent
{
SEvent()
{
memset(this, 0, sizeof(*this));
}
//! Any kind of GUI event.
struct SGUIEvent
{
@ -345,6 +351,9 @@ struct SEvent
//! Type of mouse event
EMOUSE_INPUT_EVENT Event;
//! Is this a simulated mouse event generated by Minetest itself?
bool Simulated;
};
//! Any kind of keyboard event.

View File

@ -40,6 +40,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "content/subgames.h"
#include "client/event_manager.h"
#include "fontengine.h"
#include "gui/pointer_type.h"
#include "gui/touchcontrols.h"
#include "itemdef.h"
#include "log.h"
@ -1242,6 +1243,7 @@ void Game::shutdown()
// Clear text when exiting.
m_game_ui->clearText();
g_touchcontrols_tsrc = nullptr;
if (g_touchcontrols)
g_touchcontrols->hide();
@ -1573,8 +1575,9 @@ bool Game::initGui()
gui_chat_console = new GUIChatConsole(guienv, guienv->getRootGUIElement(),
-1, chat_backend, client, &g_menumgr);
if (g_settings->getBool("enable_touch"))
g_touchcontrols = new TouchControls(device, texture_src);
g_touchcontrols_tsrc = texture_src;
if (should_show_touch_controls())
g_touchcontrols = new TouchControls(device, g_touchcontrols_tsrc);
return true;
}

View File

@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "gui/pointer_type.h"
#include "util/numeric.h"
#include "inputhandler.h"
#include "gui/mainmenumanager.h"
@ -113,13 +114,28 @@ bool MyEventReceiver::OnEvent(const SEvent &event)
return true;
}
if (event.EventType == EET_MOUSE_INPUT_EVENT && !event.MouseInput.Simulated)
g_last_pointer_type = PointerType::Mouse;
else if (event.EventType == EET_TOUCH_INPUT_EVENT)
g_last_pointer_type = PointerType::Touch;
// Let the menu handle events, if one is active.
if (isMenuActive()) {
if (g_touchcontrols)
g_touchcontrols->setVisible(false);
g_touchcontrols->hide();
return g_menumgr.preprocessEvent(event);
}
bool should_show = should_show_touch_controls();
if (g_touchcontrols_tsrc && !should_show && g_touchcontrols) {
TouchControls *gui = g_touchcontrols;
g_touchcontrols = nullptr;
delete gui;
} else if (g_touchcontrols_tsrc && should_show && !g_touchcontrols) {
g_touchcontrols = new TouchControls(RenderingEngine::get_raw_device(),
g_touchcontrols_tsrc);
}
// Remember whether each key is down or up
if (event.EventType == irr::EET_KEY_INPUT_EVENT) {
const KeyPress keyCode(event.KeyInput);

View File

@ -44,7 +44,7 @@ ClientDynamicInfo ClientDynamicInfo::getCurrent()
v2f32 ClientDynamicInfo::calculateMaxFSSize(v2u32 render_target_size, f32 gui_scaling)
{
f32 factor = (g_settings->getBool("enable_touch") ? 10 : 15) / gui_scaling;
f32 factor = (g_settings->getBool("gui_touch") ? 10 : 15) / gui_scaling;
f32 ratio = (f32)render_target_size.X / (f32)render_target_size.Y;
if (ratio < 1)
return { factor, factor / ratio };

View File

@ -104,7 +104,8 @@ void set_default_settings()
// Client
settings->setDefault("address", "");
settings->setDefault("enable_sound", "true");
settings->setDefault("enable_touch", bool_to_cstr(has_touch));
settings->setDefault("touch_controls", "auto");
settings->setDefault("gui_touch", bool_to_cstr(has_touch));
settings->setDefault("sound_volume", "0.8");
settings->setDefault("sound_volume_unfocused", "0.3");
settings->setDefault("mute_sound", "false");

View File

@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "constants.h"
#include "gamedef.h"
#include "client/keycode.h"
#include "gui/pointer_type.h"
#include "util/strfnd.h"
#include <IGUIButton.h>
#include <IGUICheckBox.h>
@ -315,7 +316,7 @@ void GUIFormSpecMenu::parseSize(parserData* data, const std::string &element)
data->invsize.Y = MYMAX(0, stof(parts[1]));
lockSize(false);
if (!g_settings->getBool("enable_touch") && parts.size() == 3) {
if (!g_settings->getBool("gui_touch") && parts.size() == 3) {
if (parts[2] == "true") {
lockSize(true,v2u32(800,600));
}
@ -3283,7 +3284,7 @@ void GUIFormSpecMenu::regenerateGui(v2u32 screensize)
s32 min_screen_dim = std::min(padded_screensize.X, padded_screensize.Y);
double prefer_imgsize;
if (g_settings->getBool("enable_touch")) {
if (g_settings->getBool("gui_touch")) {
// The preferred imgsize should be larger to accommodate the
// smaller screensize.
prefer_imgsize = min_screen_dim / 10 * gui_scaling;
@ -3770,7 +3771,7 @@ void GUIFormSpecMenu::showTooltip(const std::wstring &text,
int tooltip_offset_x = m_btn_height;
int tooltip_offset_y = m_btn_height;
if (m_pointer_type == PointerType::Touch) {
if (g_last_pointer_type == PointerType::Touch) {
tooltip_offset_x *= 3;
tooltip_offset_y = 0;
if (m_pointer.X > (s32)screenSize.X / 2)

View File

@ -18,6 +18,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
*/
#include "guiInventoryList.h"
#include "gui/pointer_type.h"
#include "guiFormSpecMenu.h"
#include "client/hud.h"
#include "client/client.h"
@ -153,7 +154,7 @@ void GUIInventoryList::draw()
// Add hovering tooltip
bool show_tooltip = !item.empty() && hovering && !selected_item;
// Make it possible to see item tooltips on touchscreens
if (m_fs_menu->getPointerType() == PointerType::Touch) {
if (g_last_pointer_type == PointerType::Touch) {
show_tooltip |= hovering && selected && m_fs_menu->getSelectedAmount() != 0;
}
if (show_tooltip) {

View File

@ -26,6 +26,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "modalMenu.h"
#include "gettext.h"
#include "gui/guiInventoryList.h"
#include "gui/pointer_type.h"
#include "porting.h"
#include "settings.h"
#include "touchcontrols.h"
@ -62,7 +63,7 @@ GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent,
m_gui_scale = std::max(g_settings->getFloat("gui_scaling"), 0.5f);
const float screen_dpi_scale = RenderingEngine::getDisplayDensity();
if (g_settings->getBool("enable_touch")) {
if (g_settings->getBool("gui_touch")) {
m_gui_scale *= 1.1f - 0.3f * screen_dpi_scale + 0.2f * screen_dpi_scale * screen_dpi_scale;
} else {
m_gui_scale *= screen_dpi_scale;
@ -193,6 +194,7 @@ bool GUIModalMenu::simulateMouseEvent(ETOUCH_INPUT_EVENT touch_event, bool secon
mouse_event.EventType = EET_MOUSE_INPUT_EVENT;
mouse_event.MouseInput.X = m_pointer.X;
mouse_event.MouseInput.Y = m_pointer.Y;
mouse_event.MouseInput.Simulated = true;
switch (touch_event) {
case ETIE_PRESSED_DOWN:
mouse_event.MouseInput.Event = EMIE_LMOUSE_PRESSED_DOWN;
@ -216,7 +218,6 @@ bool GUIModalMenu::simulateMouseEvent(ETOUCH_INPUT_EVENT touch_event, bool secon
}
bool retval;
m_simulated_mouse = true;
do {
if (preprocessEvent(mouse_event)) {
retval = true;
@ -228,7 +229,6 @@ bool GUIModalMenu::simulateMouseEvent(ETOUCH_INPUT_EVENT touch_event, bool secon
}
retval = target->OnEvent(mouse_event);
} while (false);
m_simulated_mouse = false;
if (!retval && !second_try)
return simulateMouseEvent(touch_event, true);
@ -331,7 +331,6 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
holder.grab(this); // keep this alive until return (it might be dropped downstream [?])
if (event.TouchInput.touchedCount == 1) {
m_pointer_type = PointerType::Touch;
m_pointer = v2s32(event.TouchInput.X, event.TouchInput.Y);
gui::IGUIElement *hovered = Environment->getRootGUIElement()->getElementFromPoint(core::position2d<s32>(m_pointer));
@ -374,9 +373,8 @@ bool GUIModalMenu::preprocessEvent(const SEvent &event)
}
if (event.EventType == EET_MOUSE_INPUT_EVENT) {
if (!m_simulated_mouse) {
// Only set the pointer type to mouse if this is a real mouse event.
m_pointer_type = PointerType::Mouse;
if (!event.MouseInput.Simulated) {
// Only process if this is a real mouse event.
m_pointer = v2s32(event.MouseInput.X, event.MouseInput.Y);
m_touch_hovered.reset();
}

View File

@ -26,10 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <porting_android.h>
#endif
enum class PointerType {
Mouse,
Touch,
};
struct PointerAction {
v2s32 pos;
@ -74,14 +70,10 @@ public:
porting::AndroidDialogState getAndroidUIInputState();
#endif
PointerType getPointerType() { return m_pointer_type; };
protected:
virtual std::wstring getLabelByID(s32 id) = 0;
virtual std::string getNameByID(s32 id) = 0;
// Stores the last known pointer type.
PointerType m_pointer_type = PointerType::Mouse;
// Stores the last known pointer position.
// If the last input event was a mouse event, it's the cursor position.
// If the last input event was a touch event, it's the finger position.
@ -96,9 +88,6 @@ protected:
// This is set to true if the menu is currently processing a second-touch event.
bool m_second_touch = false;
// This is set to true if the menu is currently processing a mouse event
// that was synthesized by the menu itself from a touch event.
bool m_simulated_mouse = false;
private:
IMenuManager *m_menumgr;

10
src/gui/pointer_type.h Normal file
View File

@ -0,0 +1,10 @@
#pragma once
#include "client/texturesource.h"
enum class PointerType {
Mouse,
Touch,
};
inline PointerType g_last_pointer_type = PointerType::Mouse;
inline ITextureSource *g_touchcontrols_tsrc = nullptr;

View File

@ -31,6 +31,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/keycode.h"
#include "client/renderingengine.h"
#include "util/numeric.h"
#include "pointer_type.h"
#include <ISceneCollisionManager.h>
#include <iostream>
@ -515,6 +516,11 @@ TouchControls::TouchControls(IrrlichtDevice *device, ISimpleTextureSource *tsrc)
}
}
TouchControls::~TouchControls()
{
releaseAll();
}
void TouchControls::addButton(touch_gui_button_id id, const std::string &image, const recti &rect)
{
IGUIImage *btn_gui_button = m_guienv->addImage(rect, nullptr, id);
@ -796,6 +802,23 @@ void TouchControls::applyJoystickStatus()
}
}
void TouchControls::releaseAll()
{
while (!m_pointer_pos.empty())
handleReleaseEvent(m_pointer_pos.begin()->first);
// Release those manually too since the change initiated by
// handleReleaseEvent will only be applied later by applyContextControls.
if (m_dig_pressed) {
emitMouseEvent(EMIE_LMOUSE_LEFT_UP);
m_dig_pressed = false;
}
if (m_place_pressed) {
emitMouseEvent(EMIE_RMOUSE_LEFT_UP);
m_place_pressed = false;
}
}
void TouchControls::step(float dtime)
{
// simulate keyboard repeats
@ -844,6 +867,9 @@ void TouchControls::registerHotbarRect(u16 index, const recti &rect)
void TouchControls::setVisible(bool visible)
{
if (m_visible == visible)
return;
m_visible = visible;
for (auto &button : m_buttons) {
if (button.gui_button)
@ -853,10 +879,8 @@ void TouchControls::setVisible(bool visible)
if (m_joystick_btn_off)
m_joystick_btn_off->setVisible(visible);
// clear all active buttons
if (!visible) {
while (!m_pointer_pos.empty())
handleReleaseEvent(m_pointer_pos.begin()->first);
releaseAll();
for (AutoHideButtonBar &bar : m_buttonbars) {
bar.deactivate();
bar.hide();
@ -869,17 +893,11 @@ void TouchControls::setVisible(bool visible)
void TouchControls::hide()
{
if (!m_visible)
return;
setVisible(false);
}
void TouchControls::show()
{
if (m_visible)
return;
setVisible(true);
}
@ -904,6 +922,7 @@ void TouchControls::emitMouseEvent(EMOUSE_INPUT_EVENT type)
event.MouseInput.Control = false;
event.MouseInput.ButtonStates = 0;
event.MouseInput.Event = type;
event.MouseInput.Simulated = true;
m_receiver->OnEvent(event);
}
@ -990,3 +1009,12 @@ void TouchControls::applyContextControls(const TouchInteractionMode &mode)
m_place_pressed = false;
}
}
bool should_show_touch_controls()
{
const std::string &touch_controls = g_settings->get("touch_controls");
if (touch_controls == "auto")
return g_last_pointer_type == PointerType::Touch;
return is_yes(touch_controls);
}

View File

@ -33,6 +33,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "itemdef.h"
#include "client/game.h"
#include "util/basic_macros.h"
using namespace irr;
using namespace irr::core;
@ -187,6 +188,8 @@ class TouchControls
{
public:
TouchControls(IrrlichtDevice *device, ISimpleTextureSource *tsrc);
~TouchControls();
DISABLE_CLASS_COPY(TouchControls);
void translateEvent(const SEvent &event);
void applyContextControls(const TouchInteractionMode &mode);
@ -220,7 +223,6 @@ public:
void step(float dtime);
inline void setUseCrosshair(bool use_crosshair) { m_draw_crosshair = use_crosshair; }
void setVisible(bool visible);
void hide();
void show();
@ -238,6 +240,7 @@ private:
double m_touchscreen_threshold;
u16 m_long_tap_delay;
bool m_visible = true; // is the whole touch screen gui visible
void setVisible(bool visible);
std::unordered_map<u16, recti> m_hotbar_rects;
std::optional<u16> m_hotbar_selection = std::nullopt;
@ -295,6 +298,9 @@ private:
// apply joystick status
void applyJoystickStatus();
// release all buttons etc.
void releaseAll();
// map to store the IDs and original positions of currently pressed pointers
std::unordered_map<size_t, v2s32> m_pointer_downpos;
// map to store the IDs and positions of currently pressed pointers
@ -315,3 +321,5 @@ private:
};
extern TouchControls *g_touchcontrols;
bool should_show_touch_controls();