From f77fa8e8a819cc19a08ae31dd15bd4f7a79c78e5 Mon Sep 17 00:00:00 2001 From: Insality Date: Tue, 28 Apr 2020 19:06:29 +0300 Subject: [PATCH] Add multitouch for scroll correct scrolling with several fingers --- druid/base/drag.lua | 12 ++++++------ druid/base/scroll.lua | 1 - druid/const.lua | 1 + druid/styles/default/style.lua | 1 - input/game.input_binding | 12 ++++++++---- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/druid/base/drag.lua b/druid/base/drag.lua index 8c31b7f..f4439d8 100644 --- a/druid/base/drag.lua +++ b/druid/base/drag.lua @@ -61,7 +61,7 @@ end local function find_touch(action_id, action, touch_id) - local act = const.ACTION_TOUCH + local act = helper.is_mobile() and const.ACTION_MULTITOUCH or const.ACTION_TOUCH if action_id ~= act then return @@ -135,7 +135,7 @@ end function M.on_input(self, action_id, action) - if action_id ~= const.ACTION_TOUCH then + if action_id ~= const.ACTION_TOUCH and action_id ~= const.ACTION_MULTITOUCH then return end @@ -172,7 +172,7 @@ function M.on_input(self, action_id, action) if touch.released and self.is_touch then if action.touch then -- Mobile - on_touch_release(action_id, action, self) + on_touch_release(self, action_id, action) else -- PC end_touch(self) @@ -189,9 +189,9 @@ function M.on_input(self, action_id, action) self.dy = touch_modified.screen_y - self.screen_y end - if touch then - self.screen_x = touch.screen_x - self.screen_y = touch.screen_y + if touch_modified then + self.screen_x = touch_modified.screen_x + self.screen_y = touch_modified.screen_y end if self.is_drag then diff --git a/druid/base/scroll.lua b/druid/base/scroll.lua index 694fb13..6255c30 100644 --- a/druid/base/scroll.lua +++ b/druid/base/scroll.lua @@ -235,7 +235,6 @@ end function M.set_size(self, size) - pprint(size) gui.set_size(self.content_node, size) update_size(self) end diff --git a/druid/const.lua b/druid/const.lua index 8e5c4ac..1db17e2 100644 --- a/druid/const.lua +++ b/druid/const.lua @@ -14,6 +14,7 @@ M.ACTION_ESC = hash("key_esc") M.ACTION_TOUCH = hash("touch") M.ACTION_SCROLL_UP = hash("scroll_up") +M.ACTION_MULTITOUCH = hash("multitouch") M.ACTION_SCROLL_DOWN = hash("scroll_down") diff --git a/druid/styles/default/style.lua b/druid/styles/default/style.lua index b05dd48..8bd8c60 100644 --- a/druid/styles/default/style.lua +++ b/druid/styles/default/style.lua @@ -60,7 +60,6 @@ M["scroll"] = { BACK_SPEED = 0.2, -- lerp speed LERP_SPEED = 1, - BORDER_LERP_SPEED = 0.3, } diff --git a/input/game.input_binding b/input/game.input_binding index b873ebd..0b6d8ca 100644 --- a/input/game.input_binding +++ b/input/game.input_binding @@ -18,10 +18,6 @@ key_trigger { input: KEY_ESC action: "key_esc" } -mouse_trigger { - input: MOUSE_BUTTON_1 - action: "touch" -} mouse_trigger { input: MOUSE_WHEEL_UP action: "scroll_up" @@ -30,6 +26,14 @@ mouse_trigger { input: MOUSE_WHEEL_DOWN action: "scroll_down" } +mouse_trigger { + input: MOUSE_BUTTON_1 + action: "touch" +} +touch_trigger { + input: TOUCH_MULTI + action: "multitouch" +} text_trigger { input: TEXT action: "text"