0 votes

Hi all,

This code:

func input(event):
        if (event.type==InputEvent.MOUSE_BUTTON and event.is_action_released("mouse_clicked") and !event.is_echo()):
            print("yup, you clicked it")
            print("Mouse mode: ", str(Input.get_mouse_mode()))

prints the following:

yup, you clicked it
Mouse mode: 32767
yup, you clicked it
Mouse mode: 32767

I just don't understand that. I though that based on this:http://docs.godotengine.org/en/stable/classes/class_input.html#numeric-constants it would be 0, 1 or 2.

Any help would be really appreciated.

in Engine by (837 points)

Which OS are you on?

OS X sorry. Godot 2.1 stable.

1 Answer

+2 votes
Best answer

You get 32767 because... mouse_mode was not initialized in the engine :p
https://github.com/godotengine/godot/blob/master/platform/osx/os_osx.mm#L1767
So you just get garbage. That's a nice bug!
I opened an issue since I'm about to fall asleep, it will be fixed quickly in next version https://github.com/godotengine/godot/issues/7766

by (29,090 points)
selected by

ahhhh, is there a way... I can work around it?

I think the default should have been MOUSE_VISIBLE, so you could call OS.set_mouse_mode(MOUSE_VISIBLE) when your game starts (or whatever value you want) so it gets an initial value.

Thank you. I tried to add OS.set_mouse_mode(MOUSE_VISIBLE) to my func _ready(): but got this error:

Parser Error: Identifier not found: MOUSE_VISIBLE

EDIT: I also tried MOUSE_MODE_VISIBLE and 0 with the same issue

Sorry, the constant is Input.MOUSE_MODE_VISIBLE.
If the returned mouse mode is higher than the maximum one, just assume it's Input.MOUSE_MODE_VISIBLE.

Thank you, adding Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) to the func _input(event): worked. I really appreciate your help. I'd have never figured that one out!

No, don't put it in _event, put it in _ready or some other place it would run only at game start ;).

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.