directInput.. system-cursor visible

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
random
Posts: 158
Joined: Wed Aug 11, 2010 6:01 am

directInput.. system-cursor visible

Post by random »

i know how to make the system cursor invisble by

Code: Select all

device->getCursorControl()->setVisible(false);
but while i am playing arround with directInput in OIS i found only configurations like

DISCL_EXCLUSIVE

to set the mouse invisble but in OIS the mouse than is also invisible when the mouse is outside the window or even not leaving it.

how is this solved in IRRLICHT?
pc0de
Posts: 300
Joined: Wed Dec 05, 2007 4:41 pm

Post by pc0de »

A while back I added some OIS/Irrlicht documentation to the wiki:

http://www.irrlicht3d.org/wiki/index.php?n=Main.IntegratingOISWithIrrlicht

I don't use OIS anymore but you may find the example code useful. Regarding your specific question, I think you're going to need a combination of DISCL_FOREGROUND & DISCL_EXCLUSIVE/DISCL_NONEXCLUSIVE. I don't remember which...
random
Posts: 158
Joined: Wed Aug 11, 2010 6:01 am

Post by random »

well i was playing arround with use in OGRE

Code: Select all

    std::ostringstream windowHndStr;

    mWindow->getCustomAttribute("WINDOW", &windowHnd);
    windowHndStr << windowHnd;
    pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));

    //!---------- CUSTOM CODE FOR DISPLAY CURSOR -------- START --------!//
    /**********************************************************************
    This Code uses the System own Mouse-Cursor, so it will be able to move
    outside the Render-Window but can not display a Custom Image source from:

    http://www.ogre3d.org/tikiwiki/How+to+show+the+mouse+cursor+without+CEGUI&structure=Cookbook#Second_way:_System_cursor_OIS_cursor_

    **********************************************************************/

    #if defined OIS_WIN32_PLATFORM
    pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND" )));
    pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_NONEXCLUSIVE")));
    pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_FOREGROUND")));
    pl.insert(std::make_pair(std::string("w32_keyboard"), std::string("DISCL_NONEXCLUSIVE")));
    #elif defined OIS_LINUX_PLATFORM
    pl.insert(std::make_pair(std::string("x11_mouse_grab"), std::string("false")));
    pl.insert(std::make_pair(std::string("x11_mouse_hide"), std::string("false")));
    pl.insert(std::make_pair(std::string("x11_keyboard_grab"), std::string("false")));
    pl.insert(std::make_pair(std::string("XAutoRepeatOn"), std::string("true")));
    #endif

    //!---------- CUSTOM CODE FOR DISPLAY CURSOR --------  END  --------!//


    mInputManager = OIS::InputManager::createInputSystem( pl );

    mKeyboard = static_cast<OIS::Keyboard*>(mInputManager->createInputObject( OIS::OISKeyboard, true ));
    mMouse = static_cast<OIS::Mouse*>(mInputManager->createInputObject( OIS::OISMouse, true ));
will make system mouse available inside the render window but overlays a custom image

Code: Select all

DISCL_EXCLUSIVE
would make system cursor invisible but prevent the mouse to leave the render window or even make system cursor also invisible outside.

when i use

Code: Select all

device->getCursorControl()->setVisible(false);
it makes the system cursor invisble while over the render window so that it would be possible to use a custom image but does not prevent that the system cursor leaves the render window or make it also invisible outside it.

but i guess i found the answhere here for win32:

Code: Select all

//! Changes the visible state of the mouse cursor.
                  virtual void setVisible(bool visible)
                  {
                        CURSORINFO info;
                        info.cbSize = sizeof(CURSORINFO);
                        BOOL gotCursorInfo = GetCursorInfo(&info);
                        while ( gotCursorInfo )
                        {
                              if ( (visible && info.flags == CURSOR_SHOWING)  // visible
                                    || (!visible && info.flags == 0 ) )             // hidden
                              {
                                    break;
                              }
                              int showResult = ShowCursor(visible);   // this only increases an internal display counter in windows, so it might have to be called some more
                              if ( showResult < 0 )
                              {
                                    break;
                              }
                              info.cbSize = sizeof(CURSORINFO);   // yes, it really must be set each time
                              gotCursorInfo = GetCursorInfo(&info);
                        }
                        IsVisible = visible;
                  }

which implements

showCursor from Windows.h

and for linux and mac:

Code: Select all

                  //! Changes the visible state of the mouse cursor.
                  virtual void setVisible(bool visible)
                  {
                        if (visible==IsVisible)
                              return;
                        IsVisible = visible;
#ifdef _IRR_COMPILE_WITH_X11_
                        if (!Null)
                        {
                              if ( !IsVisible )
                                    XDefineCursor( Device->display, Device->window, invisCursor );
                              else
                                    XUndefineCursor( Device->display, Device->window );
                        }
#endif
                  }
which uses

XDefineCursor
and
XUndefineCursor


from
X11/Xlib.h


thx for the OIS link to your implementation
Post Reply