Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Author Topic: OIS Mouse initialization fails and keyboard issues. OIS tutorials???  (Read 1300 times)

simulacrum111

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 10
    • View Profile

Hello,

Are there any OIS tutorials?  I seem to be making a lot of mistakes but I don't know where to look to clean up my act.

--------------------

I get the following error upon trying to initialize a mouse within OIS:
X_ChangeWindowAttributes: BadAccess (attempt to access private resource denied)

the mouse device is detected as:
Device: OISKeyboard Vendor: X11InputManager

I am unfamiliar with X in general.  What could be causing this error?

--------------------

In the console demo that comes with OIS a keyboard input device is created that is buffered.  A function is created that handles non-buffered input to the keyboard.  If the keyboard is buffered how is this function ever called?  handleNonBufferedKeys gets called in the demo application but when I integrate that code (virtually verbatim) into my existing app for testing the handleNonBufferedKeys function is not called if I use a buffered keyboard and is called if I do not.  What could be causing this?

--------------------

I free all input devices upon termination of my application however my system keyboard no long generates repeated keyDown events.  For example as I type this I cannot use the arrow key to scroll through this text.  I must repeatedly hit the arrow keys in order to navigate.  I suspect I am unaware of even more problems.

Is there more to OIS cleanup/shutdown than this code from the console demo?
   //Destroying the manager will cleanup unfreed devices
   if( g_InputManager )
      InputManager::destroyInputSystem(g_InputManager);
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: OIS Mouse initialization fails and keyboard issues. OIS tutorials???
« Reply #1 on: September 08, 2009, 05:03:51 PM »

The first message, BadAccess, means the x11 window is invalid. Which I suspect is your problem on shutdown as well. Make sure you create OIS after you create your window. Also, make sure you shut it down before you destroy your window.

device->capture() for each device needs to be called once per frame to fire input events. If you set buffered = true, you will get messages (if you also register a callback). Otherwise, you get no events.
Logged

simulacrum111

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 10
    • View Profile
Re: OIS Mouse initialization fails and keyboard issues. OIS tutorials???
« Reply #2 on: September 08, 2009, 05:19:49 PM »

The first message, BadAccess, means the x11 window is invalid. Which I suspect is your problem on shutdown as well. Make sure you create OIS after you create your window. Also, make sure you shut it down before you destroy your window.

device->capture() for each device needs to be called once per frame to fire input events. If you set buffered = true, you will get messages (if you also register a callback). Otherwise, you get no events.

Okay the xWindow is invalid.  I don't understand why yet.  Why doesn't the initialization of the keyboard and joysticks complain of the same problem?

I am forced to create my windows with a library instead of directly but I can get native window handles from that library.  Are there any taboos to initializing OIS with them?

I originally shutdown OIS after my window were destroyed, but I will change that.   Thank you for the pointer in the right direction.

I also understand what buffered and un-buffered means to OIS now so thank you again.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: OIS Mouse initialization fails and keyboard issues. OIS tutorials???
« Reply #3 on: September 08, 2009, 05:30:08 PM »

Joystick does not require a Window, really.

Keyboard works nearly flawlessly with other libs messing with x11. However, Mouse is a different beast. Only one listener for x11 mouse events can be registered per x11 window. So, if the other lib you are using is handling x11 mouse events, OIS mouse will not work. You have to decide to use OIS mouse or the lib mouse (if you can disable their mouse processing code). It might (can't recall for sure) be possible via x11 calls to remove the previous registered listener as well.
Logged

simulacrum111

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 10
    • View Profile
Re: OIS Mouse initialization fails and keyboard issues. OIS tutorials???
« Reply #4 on: September 08, 2009, 05:41:07 PM »

If I could unregister the mouse from the window through x11/win32 and then re-register the mouse so that OIS was in control of it that would be a TREMENDOUS help to me as I would MUCH MUCH MUCH prefer to use OIS in this instance.

I know virtually nothing about X so learning how to do it basically means I need to learn X programming very quickly.   The possibility is worth exploring despite that so thanks for the suggestion.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: OIS Mouse initialization fails and keyboard issues. OIS tutorials???
« Reply #5 on: September 08, 2009, 07:46:22 PM »

Hmm, I'm not seeing any good way so far to work around the problem... The problem is:
XSelectInput when passing in the ButtonPressMask flag - which for whatever lame reason, only allows one client to register like that. Subsequent registrations fail with that error, and no messages will be given for mouse.

What library are you trying to use that is also using x11?
Logged

simulacrum111

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 10
    • View Profile
Re: OIS Mouse initialization fails and keyboard issues. OIS tutorials???
« Reply #6 on: September 08, 2009, 09:15:52 PM »

Sorry its late.  I'll be back to pester...slightly :) tomorrow.

The library I am using is called fltk.  Its a library for making GUIs similar to wxWidgets and Qt.

I want OIS to handle human HIDs and to use fltk for dialogs and other gui related things rather than writing all that myself.  I will have to investigate my options but one that comes to mind is not creating a view window with fltk but rather creating a window from scratch and then using fltk to place a GUI frame around it.  So in essence fltk will be a window with gui controls around a window that displays stuff.

The problem and benefit is that fltk and OIS would be oblivious of one another.  I would have to keep them in sync somethow but perhaps this is less engineering effort than diving into either X lib programming or fltk/OIS source code.  I think I primarily have two problems.  Resizing windows - which I can affect programmatically and syncing window drag...which I am not sure how I'm going to accomplish just yet.  One window will have to "follow" the other.  My guess is to make one window a child of the other through raw XII/win32 calls.

This is the simplest solution I can think of at present which doesn't force me to drop features.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: OIS Mouse initialization fails and keyboard issues. OIS tutorials???
« Reply #7 on: September 09, 2009, 06:51:21 AM »

One option, is you could always use that GUI libraries mouse (and optionally keyboard) input systems. And just use OIS for Joystick support.
Logged

simulacrum111

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 10
    • View Profile
Re: OIS Mouse initialization fails and keyboard issues. OIS tutorials???
« Reply #8 on: September 09, 2009, 11:17:36 AM »

Yes, that is the sanest option at this moment.  However, that is dropping a lot of what OIS has to offer me.  Thanks for your time.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 2652
    • View Profile
    • http://www.wreckedgames.com
Re: OIS Mouse initialization fails and keyboard issues. OIS tutorials???
« Reply #9 on: September 09, 2009, 04:56:27 PM »

OIS has a large collection of features just for Joysticks, so you wouldn't really be dropping much. Though, if all you need is mouse and keyboard, and you are making a GUI project & using a GUI toolkit, I do really recommend using it. For instance, if/when I'm using .Net (or Qt, wxWindows, etc), I generally would use what it offers for mouse/keyboard input.
Logged