Place nodes with single tap on Android (+ bugfix) (#13187)

Don't place nodes when closing button bars.
Update docs (also in-game).
Rename "Default controls" -> "Controls" in Android pause menu since players can't change them (normally), so calling them "default" doesn't make sense.
This commit is contained in:
Gregor Parzefall 2023-05-29 07:30:30 +02:00 committed by GitHub
parent 6832bf044e
commit fc3d6c1dd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 56 deletions

@ -1,5 +1,3 @@
**This document is based on the Minetest 5.6.1 version for Android**
# Minetest Android build
All Minetest builds, including the Android variant, are based on the same code.
However, additional Java code is used for proper Android integration.
@ -11,8 +9,8 @@ due to limited capabilities of common devices. What can be done is described bel
While you're playing the game normally (that is, no menu or inventory is
shown), the following controls are available:
* Look around: touch screen and slide finger
* Double tap: Place a node
* Long tap: Dig node or use the holding item
* Tap: Place a node
* Long tap: Dig node or use the held item
* Press back: Pause menu
* Touch buttons: Press button
* Buttons:
@ -33,9 +31,8 @@ When a menu or inventory is displayed:
--> places a single item from dragged stack into current (first touched) slot. If a stack is selected, the stack will be split as half and one of the splitted stack will be selected
### Limitations
* Android player have to double tap to place node, this can be annoying in some game/mod
* Some old Android device only support 2 touch at a time, some game/mod contain button combination that need 3 touch (example: jump + Aux1 + hold)
* Complicated control like pick up an cart in MTG can be difficult or impossible on Android device
* Complicated control can be difficult or impossible on Android device
## File Path
There are some settings especially useful for Android users. The Minetest-wide

@ -4335,14 +4335,14 @@ void Game::showDeathFormspec()
void Game::showPauseMenu()
{
#ifdef HAVE_TOUCHSCREENGUI
static const std::string control_text = strgettext("Default Controls:\n"
"No menu visible:\n"
"- single tap: button activate\n"
"- double tap: place/use\n"
static const std::string control_text = strgettext("Controls:\n"
"No menu open:\n"
"- slide finger: look around\n"
"Menu/Inventory visible:\n"
"- tap: place/use\n"
"- long tap: dig/punch/use\n"
"Menu/inventory open:\n"
"- double tap (outside):\n"
" -->close\n"
" --> close\n"
"- touch stack, touch slot:\n"
" --> move stack\n"
"- touch&drag, tap 2nd finger\n"

@ -692,9 +692,8 @@ void TouchScreenGUI::handleReleaseEvent(size_t evt_id)
}
m_receiver->OnEvent(*translated);
delete translated;
} else {
// do double tap detection
doubleTapDetection();
} else if (!m_move_has_really_moved) {
doRightClick();
}
}
@ -773,8 +772,11 @@ void TouchScreenGUI::translateEvent(const SEvent &event)
// already handled in isSettingsBarButton()
} else {
// handle non button events
if (m_settingsbar.active() || m_rarecontrolsbar.active()) {
m_settingsbar.deactivate();
m_rarecontrolsbar.deactivate();
return;
}
s32 dxj = event.TouchInput.X - button_size * 5.0f / 2.0f;
s32 dyj = event.TouchInput.Y - (s32)m_screensize.Y + button_size * 5.0f / 2.0f;
@ -999,29 +1001,9 @@ void TouchScreenGUI::handleChangedButton(const SEvent &event)
event.TouchInput.ID, true);
}
bool TouchScreenGUI::doubleTapDetection()
bool TouchScreenGUI::doRightClick()
{
m_key_events[0].down_time = m_key_events[1].down_time;
m_key_events[0].x = m_key_events[1].x;
m_key_events[0].y = m_key_events[1].y;
m_key_events[1].down_time = m_move_downtime;
m_key_events[1].x = m_move_downlocation.X;
m_key_events[1].y = m_move_downlocation.Y;
u64 delta = porting::getDeltaMs(m_key_events[0].down_time, porting::getTimeMs());
if (delta > 400)
return false;
double distance = sqrt(
(m_key_events[0].x - m_key_events[1].x) *
(m_key_events[0].x - m_key_events[1].x) +
(m_key_events[0].y - m_key_events[1].y) *
(m_key_events[0].y - m_key_events[1].y));
if (distance > (20 + m_touchscreen_threshold))
return false;
v2s32 mPos = v2s32(m_key_events[0].x, m_key_events[0].y);
v2s32 mPos = v2s32(m_move_downlocation.X, m_move_downlocation.Y);
if (m_draw_crosshair) {
mPos.X = m_screensize.X / 2;
mPos.Y = m_screensize.Y / 2;
@ -1111,10 +1093,6 @@ void TouchScreenGUI::step(float dtime)
if (!button.ids.empty()) {
button.repeatcounter += dtime;
// in case we're moving around digging does not happen
if (m_has_move_id)
m_move_has_really_moved = true;
if (button.repeatcounter < button.repeatdelay)
continue;

@ -130,6 +130,9 @@ public:
// step handler
void step(float dtime);
// return whether the button bar is active
bool active() { return m_active; }
// deactivate button bar
void deactivate();
@ -284,8 +287,8 @@ private:
// handle pressed hud buttons
bool isHUDButton(const SEvent &event);
// handle double taps
bool doubleTapDetection();
// do a right-click
bool doRightClick();
// handle release event
void handleReleaseEvent(size_t evt_id);
@ -293,20 +296,9 @@ private:
// apply joystick status
void applyJoystickStatus();
// double-click detection variables
struct key_event
{
u64 down_time;
s32 x;
s32 y;
};
// array for saving last known position of a pointer
std::map<size_t, v2s32> m_pointerpos;
// array for double tap detection
key_event m_key_events[2];
// settings bar
AutoHideButtonBar m_settingsbar;