Add multitouch for scroll correct scrolling with several fingers

This commit is contained in:
Insality 2020-04-28 19:06:29 +03:00
parent 05425fb76c
commit f77fa8e8a8
5 changed files with 15 additions and 12 deletions

View File

@ -61,7 +61,7 @@ end
local function find_touch(action_id, action, touch_id) 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 if action_id ~= act then
return return
@ -135,7 +135,7 @@ end
function M.on_input(self, action_id, action) 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 return
end end
@ -172,7 +172,7 @@ function M.on_input(self, action_id, action)
if touch.released and self.is_touch then if touch.released and self.is_touch then
if action.touch then if action.touch then
-- Mobile -- Mobile
on_touch_release(action_id, action, self) on_touch_release(self, action_id, action)
else else
-- PC -- PC
end_touch(self) end_touch(self)
@ -189,9 +189,9 @@ function M.on_input(self, action_id, action)
self.dy = touch_modified.screen_y - self.screen_y self.dy = touch_modified.screen_y - self.screen_y
end end
if touch then if touch_modified then
self.screen_x = touch.screen_x self.screen_x = touch_modified.screen_x
self.screen_y = touch.screen_y self.screen_y = touch_modified.screen_y
end end
if self.is_drag then if self.is_drag then

View File

@ -235,7 +235,6 @@ end
function M.set_size(self, size) function M.set_size(self, size)
pprint(size)
gui.set_size(self.content_node, size) gui.set_size(self.content_node, size)
update_size(self) update_size(self)
end end

View File

@ -14,6 +14,7 @@ M.ACTION_ESC = hash("key_esc")
M.ACTION_TOUCH = hash("touch") M.ACTION_TOUCH = hash("touch")
M.ACTION_SCROLL_UP = hash("scroll_up") M.ACTION_SCROLL_UP = hash("scroll_up")
M.ACTION_MULTITOUCH = hash("multitouch")
M.ACTION_SCROLL_DOWN = hash("scroll_down") M.ACTION_SCROLL_DOWN = hash("scroll_down")

View File

@ -60,7 +60,6 @@ M["scroll"] = {
BACK_SPEED = 0.2, -- lerp speed BACK_SPEED = 0.2, -- lerp speed
LERP_SPEED = 1, LERP_SPEED = 1,
BORDER_LERP_SPEED = 0.3,
} }

View File

@ -18,10 +18,6 @@ key_trigger {
input: KEY_ESC input: KEY_ESC
action: "key_esc" action: "key_esc"
} }
mouse_trigger {
input: MOUSE_BUTTON_1
action: "touch"
}
mouse_trigger { mouse_trigger {
input: MOUSE_WHEEL_UP input: MOUSE_WHEEL_UP
action: "scroll_up" action: "scroll_up"
@ -30,6 +26,14 @@ mouse_trigger {
input: MOUSE_WHEEL_DOWN input: MOUSE_WHEEL_DOWN
action: "scroll_down" action: "scroll_down"
} }
mouse_trigger {
input: MOUSE_BUTTON_1
action: "touch"
}
touch_trigger {
input: TOUCH_MULTI
action: "multitouch"
}
text_trigger { text_trigger {
input: TEXT input: TEXT
action: "text" action: "text"