Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: 'relX' : is not a member of 'OIS::MouseState'  (Read 1815 times)

mtrinca

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 6
    • View Profile
'relX' : is not a member of 'OIS::MouseState'
« on: November 19, 2006, 11:45:12 AM »

Hi all,

I'm developing and app on winXP using Ogre, OIS and CEGUI. I have the keyboard and mouse listeners implemented in a class "Input". Everything is working fine with the keys and mouse buttons, but I'm getting an error when I try to inject mouseMoved: 'relX' : is not a member of 'OIS::MouseState' and 'relY' : is not a member of 'OIS::MouseState'

ATM my listeners looks like :

// MouseListener
bool InputHandler::mouseMoved(const OIS::MouseEvent &evt) {
   CEGUI::System::injectMouseMove(mMouse->getMouseState().relX, mMouse->getMouseState().relY);
   return true;
}

bool InputHandler::mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
   CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(btn));
   return true;
}

bool InputHandler::mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
   CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(btn));
   // just a test to see if it's working and it is.
   if (convertOISMouseButtonToCegui(btn) == CEGUI::LeftButton)
      m_simulation->requestStateChange(SHUTDOWN);
   return true;
}
      
// KeyListener
bool InputHandler::keyPressed(const OIS::KeyEvent &evt) {
   return true;
}

bool InputHandler::keyReleased(const OIS::KeyEvent &evt) {
   if (evt.key == OIS::KC_ESCAPE)
      m_simulation->requestStateChange(SHUTDOWN);

   return true;
}

When I press ESC or released the left button the app quits, so, the listeners are working fine.
I'm trying to put the mouse cursos to move, but I'm getting the error.

Does anyone have some info about it?

I tried some lines of code from the demo, some topics I found in this forum also and my knowhow is not enough to understand why it works in some examples that I saw and why in my code it's not working.

Thanks all.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2653
    • View Profile
    • http://www.wreckedgames.com
'relX' : is not a member of 'OIS::MouseState'
« Reply #1 on: November 19, 2006, 12:04:29 PM »

Your first issue, of relY, relX, etc not being a member of mouse state is because of a design change in cvs head. In the new API, you would do:
mouseState.X.rel or mouseState.X.abs, or mouseState.Y.rel
Basically, the axis member inheiritance changed a bit to adjust for joystick changes.

Now, in your code, I should make one little observation... You call mMouse->getMouseState() multiple times. What I suggest, is just doing:
const MouseState &state = mMouse->getMouseState();
And just using that state reference around where you need it... Just a little optimization not having to call a method an unneeded amount of times.
Logged

mtrinca

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 6
    • View Profile
'relX' : is not a member of 'OIS::MouseState'
« Reply #2 on: November 19, 2006, 12:14:57 PM »

Cool pj :)

I did some modifications:

// MouseListener
bool InputHandler::mouseMoved(const OIS::MouseEvent &evt) {
   const OIS::MouseState &ms = mMouse->getMouseState();
   CEGUI::System::getSingleton().injectMouseMove(ms.X.rel, ms.Y.rel);
   return true;
}

bool InputHandler::mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
   CEGUI::System::getSingleton().injectMouseButtonDown(convertOISMouseButtonToCegui(btn));
   return true;
}

bool InputHandler::mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
   CEGUI::System::getSingleton().injectMouseButtonUp(convertOISMouseButtonToCegui(btn));
   return true;
}

It's working really fine.
Thanks a lot.  :D
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2653
    • View Profile
    • http://www.wreckedgames.com
'relX' : is not a member of 'OIS::MouseState'
« Reply #3 on: November 19, 2006, 12:22:28 PM »

Glad to hear :D
Logged

rewb0rn

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 4
    • View Profile
'relX' : is not a member of 'OIS::MouseState'
« Reply #4 on: January 16, 2007, 12:55:05 PM »

Hey, is this onvertOISMouseButtonToCegui function part of ois? I dont find it, but I want to use it.. If you wrote it your own, would you post it here?
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2653
    • View Profile
    • http://www.wreckedgames.com
'relX' : is not a member of 'OIS::MouseState'
« Reply #5 on: January 16, 2007, 02:03:23 PM »

It is included in the Ogre GUI demo. And, also in an older cvs version of OIS demos... anyway, here you go:

Code: [Select]
//----------------------------------------------------------------//
CEGUI::MouseButton convertOISMouseButtonToCegui(int buttonID)
{
    switch (buttonID)
    {
case 0: return CEGUI::LeftButton;
case 1: return CEGUI::RightButton;
case 2: return CEGUI::MiddleButton;
case 3: return CEGUI::X1Button;
default: return CEGUI::LeftButton;
    }
}
Logged

rewb0rn

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 4
    • View Profile
'relX' : is not a member of 'OIS::MouseState'
« Reply #6 on: January 16, 2007, 05:11:59 PM »

thank you!
Logged