Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: Cursor grabbing and hidding in windowed mode  (Read 2711 times)

Steven 'lazalong' Gay

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 22
    • View Profile
    • OGE - Open Game Engine
Cursor grabbing and hidding in windowed mode
« on: August 17, 2006, 05:03:54 AM »

Hello,

@pjcast: In this thread http://www.wreckedgames.com/forum/viewtopic.php?t=35 you proposed:

Quote

virtual void enableHardwareCursor( bool enable )

When the hardware (OS) cursor is visible (active) then the mouse is not grabbed at all... It will just move in and out of app window. Now, when you set it to enabled (the default setting), the mouse dissappears and becomes grabbed. IMO, grabbing and visibility go hand in hand - if you are grabbing the mouse, you do not want to show the mouse warping back to center. Also, grabbing can be accomplished two ways (1) the Mouse Device can be destroyed and then created again with EXCLUSIVE Access which hides and captures the mouse - best way I think - or (2) Hide the cursor using Win32API, then begin warping cursor around to keep it from leaving using SetCursorPosition(,).

What is the status of it ?
Is it in the next release (1.0) ?

Can I use it to achieve the following?

- Set the mouse in "nonexclusive foreground"
- then when the system cursor moves inside the window it dissapears and the CEGUI cursor is positionned at the entry place.
- when the cursor leaves the window, the system window reappears and the CEGUI "follows" the window border (in the direction of the system window)

Thanks

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Cursor grabbing and hidding in windowed mode
« Reply #1 on: August 17, 2006, 10:21:10 AM »

I havn't touch this feature at all, sorry.

DirectX is just not that flexible in this regard. It would involve a lot of work. I suggest, always allow the mouse to go in and out of the window (hence, use the OS cursor by going nonexclusive), or keep the cursor always contained, only allowing for alt-tab'ing to release the mouse (standard default behavior in OIS).

Now, the only use I see of having this feature is an editor or multiwindow games.

For Editors, I don't suggest you use OIS, as widget libs contain their own event systems. Or, if this is ingame, you still can use OIS for an ingame editor, and just always show the mouse.

For multi-window apps, you would be best to no capture the mouse at all, and just use nonexclusive. Or, better yet, use multiple viewports and not windows ;)

Although, I would be willing to accept patches, I just don't have the time to implement this on multiple platforms currently.
Logged

Steven 'lazalong' Gay

  • Regular
  • *
  • Karma: +0/-0
  • Posts: 22
    • View Profile
    • OGE - Open Game Engine
Cursor grabbing and hidding in windowed mode
« Reply #2 on: August 17, 2006, 10:31:20 AM »

OK no problem.

Perhaps for v1.1 ;)
You could set it in a list: "Help welcome".

If I found or think of a solution I will tell you.

Bye

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Cursor grabbing and hidding in windowed mode
« Reply #3 on: August 17, 2006, 10:35:41 AM »

Oh, trust me, I've posted help wanted topics around in various places before ;) For a little perspective, OIS has been out for almost a year, and only now am I soo close to having an OSX port (and this is due mainly to the fact that Ogre Eihort uses OIS, and hence it is vital for Ogre OSX users to have OIS working ;)) - my sneaky tatic, j/k.
Logged

SuperMegaMau

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 6
    • View Profile
Re: Cursor grabbing and hidding in windowed mode
« Reply #4 on: November 09, 2009, 03:21:26 AM »

Hi,

Three years later I found this topic where someone needs the same thing as me. I'm creating an ingame editor, and need to be able to release the mouse in edit time, and grab it in play time. So, I need to change the grab behaviour in runtime.

I managed to change the grab function from the mouse and keyboard to give me public access from OISObject class (no big deal), but I'm just having a little problem after I release the mouse from the window. The problem is that the mouse ingame does not have the same position outside. This problem does not happen when the mouse is grabbed and I use the alt-tab, or when the mouse is always free, this only happens when I switch in realtime.

From reading this thread, I realise that it will be very difficult to change this in windows, but sticking with linux for now, how do I solve this problem?

Thanks!

BTW: Of course I will submit a patch for this, along with a keyboard patch to allow certain dead keys to work on latin1 keyboards.
Logged

SuperMegaMau

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 6
    • View Profile
Update!
« Reply #5 on: November 09, 2009, 06:52:40 AM »

ok, done it!

I managed to solve my problem, and I am now able to grab and "ungrab" the mouse and keyboard at runtime under linux! Going windows now!
Logged