No mouse pressed/released in on_input

#1

I am testing Defold. I am trying to recognize mouse clicks. I have a game object with the following script. I only get mouse position, no pressed or released. Also, I can get key clicks (I removed that for this test).

– t_to_str converts a LUA table to a string.
function t_to_str(t)
s = ""
for k, v in pairs(t) do
s = s … tostring(k) … “:” … tostring(v) … " "
end
return s
end

function init(self)
msg.post(".", “acquire_input_focus”)
end

function final(self)
msg.post(".", “release_input_focus”)
end

function on_input(self, action_id, action)
if action.pressed then
print("on_input: pressed " … t_to_str(action))
elseif action.released then
print("on_input: released " … t_to_str(action))
else
print("on_input: weird " … t_to_str(action))
end
end

0 Likes

#2

Have you added a mouse button trigger to your input file (MOUSE_BUTTON_LEFT or MOUSE_BUTTON_1)?

0 Likes

#3

Yes. I have tried both.

0 Likes

#4

Side note/tip: You can use the “pprint(table)” to print a table. E.g.

function on_input(self, action_id, action)
    print(action_id)
    pprint(action)
end
0 Likes

#5

Thanks. That will be helpful.

0 Likes

#6

I figured it out (sort of). In game_input.binding I had touch set to generate the same action. When I removed this everything started to work.

0 Likes

#7

Ah, are you using multi-touch? If not, then you don’t need to set any touch trigger at all.

0 Likes

#8

I was intending to eventually use multi-touch. But that was probably a misunderstanding. If my test only needs single touch I just need to handle the mouse click and that will also handle single touch?

0 Likes

#9

Correct. The input documentation mentions “Currently, MOUSE_BUTTON_LEFT (or MOUSE_BUTTON_1) input actions are sent for single touch inputs as well.”

Maybe we should clarify that you have to bind MOUSE_BUTTON_LEFT/1 to get touch events @sicher?

1 Like

#10

Yes. I didn’t understand.

But why would my setting both interfere with mouse clicks (pressed and released)?

0 Likes

#11

Good question. I know for a fact that if you have multi-touch and mouse left button bound to the same trigger action then it messes up single touch. @Ragnar_Svensson maybe knows more?

0 Likes

Input issues with Mac/Linux builds but not HTML
#12

That should absolutely not happen, I think multi-touch is buggy.

0 Likes

#13

Thanks. We have two issues related to multi-touch: DEF-1726 and DEF-2024. We should probably give these a bit higher priority in the next planning meeting @jakob.pogulis?

0 Likes

#14

Though I agree with you, the backlog looks kind of packed for the next sprints. Maybe @Sara (or @saracederberg?) could give a better answer in case we could move something around.

0 Likes

#15

Thanks for all of your help.

0 Likes

#16

Is this already fixed?
I cannot bind mouse and multitouch to the same action id name “touch”. If I do, I only get multitouch input on mobile, and nothing on PC. But if I set separated IDs, trying to find a hack like “touch” and “mtouch”, then I get fine input on PC, but now I got BOTH “touch” and “mtouch” on mobile… so I’ll need a 2nd hack to ignore “touch” on mobile platform :roll_eyes:
Clipboard01__fru

Also, wondering what would happen if the Desktop PC has multitouch, I can’t use Sys_info to assume the support of multi-touch or not…

0 Likes

#17

We don’t support touch on desktop I’m afraid.

0 Likes

#18

Also, tested that is not supported on HTML 5.
Would be nice to have multi-touch on HTML5, the full screen mode makes the game looks like a native app when opening in a mobile browser, is perfect for sending a game demo to people with a simple web link.

0 Likes

#19

Yes, this was discussed internally not too long ago. I hope that we can find some time to fix this soon.

1 Like