Jump to content

[SOLVED] enable mouse input by default, hide cursor, lock cursor to window


photo

Recommended Posts

I would like to avoid having to click on the Unigine window to enable camera controls. Here is what I have tried so far, all of which has gone into the init() function in my world's script:

engine.controls.setMouseEnabled(1);

This enables camera control with the mouse, but leaves the Unigine mouse cursor visible when inside the Unigine window, as well as the OS mouse cursor visible when outside the Unigine window. I added the following:

engine.gui.setMouseEnabled(0);

This hides the Unigine mouse cursor, but the cursor is not locked to the Unigine window. If I move the mouse too far, the OS mouse cursor becomes visible. I tried adding the following:

engine.gui.setMouseGrab(1);

This unfortunately does not do at all what I expected. The only thing this seems to change is prevent me from being able to click to restore camera controls once having pressed ESC. It is otherwise the same -- the Unigine cursor is hidden, the OS cursor is visible, and the mouse is not locked to the Unigine window.

 

This is using the 2014.11.20 SDK.

Link to comment

Have you tried to use engine.app.setMouseGrab(1) and adding #define MOUSE_SOFT in unigine.cpp system script? 

 

If I understand you correctly you want to have a system mouse pointer that cannot leave the window borders? What video mode are you using (video_fullscreen 0 / 2)? Also, please check this forum topic, maybe it would be useful in your case.

 

Thanks!

How to submit a good bug report
---
FTP server for test scenes and user uploads:

Link to comment

The desired behavior is almost identical to that which happens when first starting the app and clicking the Unigine window: the mouse controls the camera direction, the mouse cursors are hidden (both the system cursor and the Unigine cursor), and the mouse is locked to the Unigine window.  The only difference is I don't want to have to click the Unigine window, but rather to have this all set up automatically on launch. Will MOUSE_SOFT aid with this?

 

I am not sure if it is still relevant, but video_fullscreen is currently set to windowed+bordered (a value of 0 if I remember correctly).

 

Also, I am away from this project until Monday of next week, but will experiment with MOUSE_SOFT then.

Link to comment
×
×
  • Create New...