[SOLVED] InjectKeys to CEGUI Problems

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

xifoxex
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 20, 2013 07:21

Re: injectKeys to CEGUI Problems

Postby xifoxex » Wed Aug 07, 2013 18:44

Yep , looks like SetWindowsHookEx( WH_GETMESSAGE ) is having troubles with D3D9 mouse positions. I need another hook method then.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: injectKeys to CEGUI Problems

Postby Ident » Wed Aug 07, 2013 18:47

i don't like these windows functions and types, a pity we have to use that poorly programmed trash... especially when i got to use this redundant windows special types like LPSTR that require special conversion functions etc. i start getting mad, it is just eww...

anyways- if u found a working solution please post it in case someone else steps into the same trap, obviously cegui wasnt the culprit in this case 8)
CrazyEddie: "I don't like GUIs"

xifoxex
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 20, 2013 07:21

Re: injectKeys to CEGUI Problems

Postby xifoxex » Wed Aug 07, 2013 18:52

Don't worry , i will post all the code i have when i solve everything.

My idea was to create a base for D3DX Overaly with CEGUI , so people can create theyr own menus without need to worry about Hooks, just CEGUI.

Anyways i need to clean A LOT my code , most of it its just copy paste of CEGUI Classes from FrameWorkBase.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: injectKeys to CEGUI Problems

Postby Ident » Wed Aug 07, 2013 18:55

Sounds useful, go for it
CrazyEddie: "I don't like GUIs"

xifoxex
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 20, 2013 07:21

Re: injectKeys to CEGUI Problems

Postby xifoxex » Thu Aug 08, 2013 11:54

Solved the problem within mouse position:

Code: Select all

Old:
       case WM_MOUSEMOVE:
             mouseEnters();
             this->injectMousePosition((float)(LOWORD(lParam)), (float)(HIWORD(lParam)));
             SendMessage( hWndServer, UWM_MOUSEMOVE, 0, 0);
       break;

New:
       case WM_MOUSEMOVE:
             mouseEnters();
             this->injectMousePosition((float)msg->pt.x, (float)msg->pt.y);
             SendMessage( hWndServer, UWM_MOUSEMOVE, 0, 0);
       break;


Looks like Msg Struct have another struct inside it called PT with X/Y Position of Mouse.


Now the mouse position updates correctly , Mouse Cursor with TaharezLook draws correctly and Event Triggers correctly too.

Anyways there r still 2 issues , one is the reposition of CEGUI Cursor since OS Cursor and CEGUI Cursor rn't on the same X/Y values.

Second issues still on FrameWindow Animations Like HelloWorld Demo , they don't even trigger.

I'll look into it today.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: injectKeys to CEGUI Problems

Postby Ident » Thu Aug 08, 2013 12:23

If you send the correct absolute values of the mouse cursor to cegui i dont see how it can be wrong
CrazyEddie: "I don't like GUIs"

xifoxex
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 20, 2013 07:21

Re: injectKeys to CEGUI Problems

Postby xifoxex » Thu Aug 08, 2013 12:30

Still Looking into MSDN , maybe i can find something in there.

Anyways looks like OS Mouse is Faster than CEGUI Mouse.

xifoxex
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 20, 2013 07:21

Re: injectKeys to CEGUI Problems

Postby xifoxex » Thu Aug 08, 2013 13:51

On FullScreen Mode , mouse position is updated correctly , anyways still no visible animations :/

On windowed mode , mouse position dosn't update correctly and no animations.

Looks like Absolute Positioning is what's causing the problem in windowed mode... i could be wrong anyways.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: injectKeys to CEGUI Problems

Postby Ident » Thu Aug 08, 2013 14:13

you can simply debug whatever u are injecting the right stuff into CEGUI to figure if it is your mistake or CEGUI's (most likely it is yours)...
CrazyEddie: "I don't like GUIs"

xifoxex
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 20, 2013 07:21

Re: injectKeys to CEGUI Problems

Postby xifoxex » Thu Aug 08, 2013 14:34

100% sure isn't CEGUI. I don't know about animation problem , but this weird mouse positioning is my fault.

xifoxex
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 20, 2013 07:21

Re: injectKeys to CEGUI Problems

Postby xifoxex » Thu Aug 08, 2013 15:31

Tryd to use GetPosition within Direct3D9 Window without hooks and printed X/Y , its exactly the same value that i pass with MessageHook. It's Absolute to my ScreenSize. That explains why work with Full-Screen Mode.


Then added this to RenderGUI Function:

Code: Select all

   CEGUI::GUIContext * mainContext = &CEGUI::System::getSingleton().getDefaultGUIContext(); // #### must be done *after* MyGUIInit() ####
   CEGUI::Vector2f  mousePos = mainContext->getMouseCursor().getPosition();



The most shocking part was discover that the 3 functions had exactly the same cursor position:


D3D APP Position :620.000000 and 509.000000
SystemWideHook Position: 620.000000 and 509.000000
CEGUI Position: 620.000000 and Y 509.000000


Ok , now i'm lost lol.

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: injectKeys to CEGUI Problems

Postby Ident » Thu Aug 08, 2013 16:12

everything works as it should. obviously u cant use this function for windowed mode mouse positions. i cant help u with d3d or windows functions, this is the CEGUI forum.
CrazyEddie: "I don't like GUIs"

xifoxex
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 20, 2013 07:21

Re: injectKeys to CEGUI Problems

Postby xifoxex » Thu Aug 08, 2013 17:09

Ok, if everything works as it should then I misunderstood the concept behind injecting Mouse Positions.

Thought CEGUI was using the ScreenSize not WindowSize, since i'm injecting Mouse Position based on my ScreenSize the CEGUI Cursor will never be on the correct position.

So I should calculate WndSize b4 injecting my input if Windowed and then do some maths with ScreenSize.

xifoxex
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 20, 2013 07:21

Re: injectKeys to CEGUI Problems

Postby xifoxex » Fri Aug 09, 2013 09:02

Ok after some trys on getting Relative Position with Maths and not getting any solution i found the problem.

So after all CEGUI Positoning use :

D3DPRESENT_PARAMETERS -> BackBufferWidth && BackBufferHeight for Mouse positoning ,
not Window width and height.


Using:

Code: Select all

   CEGUI::Sizef sized = guiContext->getSurfaceSize();
   printf/fods("%f and %f \n",sized.d_height,sized.d_width);



Found my resolution inside APP is 800x600 ... I was trying to obtain relative position using Window Width and Height , so never matched....

So , from that point i will need to do so many things inside Mouse Hook that could cause a severe lose of performance...

Since games can change from FullScreen to Windowed any given time , at least I must keep checking for it , i can do the maths just one time , if window isn't resized.....

Well , i will post the result later when i'm done with all this...

xifoxex
Not too shy to talk
Not too shy to talk
Posts: 23
Joined: Thu Jun 20, 2013 07:21

Re: injectKeys to CEGUI Problems

Postby xifoxex » Fri Aug 09, 2013 13:49

Ok found the problem and now positoning works Ok.

D3D9 app I was using to test my hooks wasn't using AdjustWIndowRect() after resizing.... So Everything was incorrectly set because of that.


Well still no animations but at least i learned some useful tricks.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 9 guests