Mouse does not move (injectMousePosition)


21-04-2009 18:43:55

Hi there!

In my mouseMoved(const OIS::MouseEvent &mouseEventRef) function there is the following code:
float mouseX = mouseEventRef.state.X.abs;
float mouseY = mouseEventRef.state.Y.abs;
float mouseZ = mouseEventRef.state.Z.rel;
im_pGuiMgr->injectMousePosition(mouseX, mouseY);
if (mouseZ != 0)
The problem is, that injectMousePosition(mouseX, mouseY) just delivers false. If i read out mouseX, mouseY or mouseEventRef.state.width they are correct. Any ideas?


21-04-2009 18:57:39

The majority of the injectX functions return true if the cursor is over some GUI widget, false otherwise. For example if you have a plain Sheet being displayed, most likely it has 'transparencyPicking' set to true, and so there is no widget detected underneath the cursor, because the Sheet is 100% transparent. This is why false is returned.

As for the mouse cursor not moving at all:

what values are you seeing for X.abs and Y.abs?

What are the dimensions of the viewport the GUImanager is using to draw the Sheet?

Are you rendering frames? Is the main rendering loop automatically driven, or do you drive the loop yourself? If you aren't rendering any frames, the mouse cursor's position will not be drawn in the position expected.


21-04-2009 19:15:16

The cursor is rendered in the upper left corner but does not move at all, thats the Problem.
X.abs and Y.abs are 0 at the beginning but if I move the mouve they change properly to wherever I move the mouse.
Viewport width is 1, Viewport heigth is 1 as well, I think thats the problem. Damn.

And yes, I am rendering frames, loop is driven by myself. Trying a bigger viewport now ;)


21-04-2009 19:23:47

OK, viewportsize is now 1024x768 but the problem still exists...


21-04-2009 19:59:37

Can you paste your GUIManager creation code? (Maybe your scenemanager isn't being set?)

Does the PlayPen or Editor work correctly?

Can you put a breakpoint in the GUIManager::draw function and see if it ever gets hit? You can also put a breakpoint inside the GUIManager::injectMousePosition and see what the values are. Also, make sure you haven't disabled the mouse cursor.


21-04-2009 20:39:54

new QuickGUI::Root();
m_GuiManDesc.sceneManager = m_pSceneMgr;
m_GuiManDesc.viewport = m_pCamera->getViewport();
m_GuiManDesc.queueID = Ogre::RENDER_QUEUE_OVERLAY;
m_pGuiMgr = QuickGUI::Root::getSingletonPtr()->createGUIManager(m_GuiManDesc);


21-04-2009 22:27:02

Nothing really pops out at me with that code... what about the other questions? Setting break points would be the quickest way to determine whats hapenning


22-04-2009 08:52:43

I just tried to use m_GuiMgr->getMouseCursor()->setPosition(mouseX, mouseY) and it works as it should. Mouse is moving.
If that is not causing any problems I can cope with that solution.


22-04-2009 18:16:03

OH! I bet the problem is that you never set an active Sheet!

You need code similar to the following:

QuickGUI::SheetDesc* sd = QuickGUI::DescManager::getSingleton().getDefaultSheetDesc();
QuickGUI::Sheet* s = new QuickGUI::Sheet(sd);

You shouldn't call MoueCursor::setPosition directly, its meant to be called by the GUIManager when you inject positions. In fact, maybe that API should be protected.. :twisted:


22-04-2009 19:27:41

OH! I bet the problem is that you never set an active Sheet!Uhm, should I? *cough*
OK, is on the ToDo List ;)


04-05-2009 23:38:31

Nonono, please don't make it protected. For some reason whenever I use moveMouse or whatever the other command is, OIS and QuickGUI get out of sync. Please let me keep setMousing! :D


05-05-2009 01:31:14

Really? Thats very odd.. lol.

Well I guess we can make it public again, I had already changed its access. You can change this if you like. Maybe we should add a note that the intended route to controlling the cursor is through the GUIManager, however if your cursor gets out of sync, or for any other advanced reason, you can manually adjust the cursor position using this API.


05-05-2009 03:03:04

Sorry, I meant the injectMousePosition() method of the GUIManager. Whatever the other one is, that's fine if you do away with it, just any but my beloved GUIManager injecting. ;-)