1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00

Re-add "long tap to punch" as a client-side setting

This commit is contained in:
Gregor Parzefall 2024-03-24 22:35:55 +01:00 committed by grorp
parent e8a8525bcd
commit 517f1602aa
8 changed files with 54 additions and 19 deletions

View file

@ -40,24 +40,37 @@ with this program; if not, write to the Free Software Foundation, Inc.,
TouchInteraction::TouchInteraction()
{
pointed_nothing = LONG_DIG_SHORT_PLACE;
pointed_node = LONG_DIG_SHORT_PLACE;
// Map punching to single tap by default.
pointed_object = SHORT_DIG_LONG_PLACE;
pointed_nothing = TouchInteractionMode_USER;
pointed_node = TouchInteractionMode_USER;
pointed_object = TouchInteractionMode_USER;
}
TouchInteractionMode TouchInteraction::getMode(const PointedThing &pointed) const
TouchInteractionMode TouchInteraction::getMode(PointedThingType pointed_type) const
{
switch (pointed.type) {
TouchInteractionMode result;
switch (pointed_type) {
case POINTEDTHING_NOTHING:
return pointed_nothing;
result = pointed_nothing;
break;
case POINTEDTHING_NODE:
return pointed_node;
result = pointed_node;
break;
case POINTEDTHING_OBJECT:
return pointed_object;
result = pointed_object;
break;
default:
FATAL_ERROR("Invalid PointedThingType given to TouchInteraction::getMode");
}
if (result == TouchInteractionMode_USER) {
if (pointed_type == POINTEDTHING_OBJECT)
result = g_settings->get("touch_punch_gesture") == "long_tap" ?
LONG_DIG_SHORT_PLACE : SHORT_DIG_LONG_PLACE;
else
result = LONG_DIG_SHORT_PLACE;
}
return result;
}
void TouchInteraction::serialize(std::ostream &os) const