Wrecked Games

Please login or register.

Login with username, password and session length
Advanced search  

News:

We're just that awesome.

Pages: [1] 2

Author Topic: Exception being thrown in DIEnumDeviceObjectsCallback  (Read 4402 times)

kojack

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 8
    • View Profile
Exception being thrown in DIEnumDeviceObjectsCallback
« on: January 14, 2007, 10:54:29 PM »

I just got OIS 1.0 rc1 (never tried it before, so don't know if it's a new or old issue).

I have a Saitek X52 hotas joystick. When I try to run Demo_Console, DIEnumDeviceObjectsCallback throws an exception ("Failed to set mapping ptr property") when it reaches the 8th axis.

The 8th axis is the vertical axis of the analog hat switch on the throttle. The 9th axis (never reached) is the x axis of the analog hat.

Some info on the 8th axis:


All the other analog axes are on usage page 1 ("Generic Desktop", in the USB HID standard). But axis 8 and 9 are on usage page 5 ("Game Controller").

If I replace the exception throw with a return, the demo runs and everything is fine, except the analog hat does nothing (as expected) and buttons 31-33 don't work. Everything else (buttons 0-30, axes 0-7, primary hat (the other 2 hats emulate buttons)) works perfectly.

I guess the easy fix is to just skip freaky usage page controls. I'll look into it more and see if I can work out why it's having trouble...
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #1 on: January 15, 2007, 03:05:43 PM »

Hmm, I'm not exactly following, is it a hat or an axis? A HAT should not be enumerated, and is seperate from an axis. An axis being analog, while a hat is digtal with (usually)  9 positions (centered, north, south, east, west, northeast, etc). So, an axis should not even get that far.

If it is an axis, and should be being enumerated, I have no idea why it would fail to allow it's userpointer to be set... Te way I have it in 1.0 is the best way I have found to enumerate all axes, assign them a position in the axis array, and later identify them as the events start arriving. Previously, I attempted to use the dwOffset member in the enumeration, but as there as a big fat warning I didn't notice before in the DXSDk that the dwOffset in enumeration does not match the dwOffset in polling (although, on my controller, it happened to be the case, so I never noticed it until a user reported problems). Perhaps, that exception can be changed so that it just ignores the axis... solves the problem of crashing, but of course the user will be left wondering why some axes don't work :|
Logged

kojack

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 8
    • View Profile
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #2 on: January 15, 2007, 11:12:38 PM »

Yep, good old dwOffset. I ran into that when I added joystick support to my input library a while ago. :)

For reference, this is the joystick:


Sorry, calling it a hat was probably misleading. The thing in question is a left hand thumb operated mini analog joystick, like the little joystick knob thing on ibm laptops. It acts as 2 analog axes. I don't know any other games which can read it, so if OIS can't it's ok, but not crashing would be good. :) It's not exactly a rare joystick, it's very popular with flight sim and space sim fans.

Even installing the saitek programmable software and binding the mini joystick to mouse emulation doesn't stop the exception.

Currently, I've just inserted a bypass to skip any control which fails the DIPROP_APPDATA property set, rather than throwing an exception.


(The hid reference is at http://www.usb.org/developers/devclass_docs/Hut1_12.pdf and covers every allocated usage page and usage, including keyboards, mice, joysticks, submarine controllers, etc).


Oh, and while here, I believe the following line in Win32JoyStick::capture()
Code: [Select]
if( diBuff[i].dwOfs >= DIJOFS_BUTTON(0) && diBuff[i].dwOfs <= DIJOFS_BUTTON(30) )
should probably have 31 at the end rather than 30. DirectX handles 32 buttons.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #3 on: January 16, 2007, 08:36:33 AM »

I'll see about replacing that exception with something else.

As for the button number, yup: 0-31 buttons. I'll fix that.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #4 on: January 17, 2007, 02:05:36 PM »

Oh, and one other thing that could work, is if that company provides an API for developers to communicate with the device... In OIS 1.1 (cvs head), it is possible (as I do with the wiimote) to create seperate drivers for a set of controls. In the case of the wii, it is neccessary as directinput does not detect it, nor could it handle the values the wii sends.

In your case, you could create a seperate JoyStick derived class to handle that controller, interfacing directly with the manufacturer supplied API (and you need to create a factorycreator to create and destroy the object). Now, you would see two devices when polling the inputmanager for number of joysticks, but you could allow users to chose which device driver to use, in cases where your driver might function better then the generic directinput driver...

Anyway, this all depends on if that joystick manufacturer infact has a better API you can use... Or, you can use the HID api directly to interface with that controller, maybe you could still get better results (the wiimote interface uses the HID interface to create/poll it).
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #5 on: January 17, 2007, 02:13:27 PM »

But, for your two reported problems (ignore error, and button range), those have both been fixed in 1.1 and 1.0 branches.
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #6 on: January 19, 2007, 07:55:17 AM »

Read that document (well skimmed, quickly), doesn't it say that joysticks can support either 128 or 256 buttons (don't recall which it was) with 6 axis and a POV and so forth?
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #7 on: January 19, 2007, 08:29:57 AM »

Not sure, I havn't read that HID document. As, OIS doesn't use HID directly (except the WiiMote code), and DI only supports 32 buttons.
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #8 on: January 19, 2007, 02:13:14 PM »

You did say you were going to support pluggable systems, so you may want to abstract it out.  Instead of setting aside memory for all axis though, why not make it configurable by the pluggable system, ergo, a method to access the joystick axis (ex:->axis(3)) instead of a variable, along with a method to get the how many axis and so forth as well.  Perhaps it should just all be abstracted out since it is being designed to be abstracted anyway...  Would be very good to do so with force feedback as well since many (most?) devices support far more force feedback and of varying types then just what DI reports...
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #9 on: January 19, 2007, 05:18:02 PM »

Hmm, it already is abstracted out. However, in practice I have not seen any joystick with more than 32 buttons, so I am not worried about that. Sometimes, limits are there for practical reasons. OIS JoyStick supports unlimited axes, 32 buttons, 4 hats, 4 sliders, etc. Having more than that would be insane on one control.

As fr force feedback, you can only abstract so far. At some point, you have to have an implementation. OIS supports both DirectInput and Linux force feedback types (even though the Linux implementation is not complete). Anything more requires (as we have been over before) use of specific (non-free) API's. You are free to use such an API instead of the generic force feedback support in OIS.
Logged

kojack

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 8
    • View Profile
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #10 on: January 19, 2007, 11:12:30 PM »

Quote
and DI only supports 32 buttons

If you use c_dfDIJoystick as the data format, you only get 32 buttons, 2 sliders, 6 axes and 4 povs.

But OIS initialises the joystick with c_dfDIJoystick2, that means it has 128 buttons, 4 povs, 24 analog axes and 8 analog sliders, using the DIJOYSTATE2 structure. That's the same format used in the DirectX SDK joystick tutorial.

I think some of those axes may be for output rather than input, the docs aren't clear.

Having all those on a single device would be rather crazy. My joystick only has so many things because both pieces (left and right hand) act as a single joystick, rather than having both act independently and appear in direct input as 2 seperate joysticks.
Logged

OvermindDL1

  • Administrator
  • Veteran
  • *****
  • Karma: +0/-0
  • Posts: 288
    • View Profile
    • http://www.overminddl1.com/forum/
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #11 on: January 19, 2007, 11:54:09 PM »

I've seen some flight sim setups (costing over a thousand dollars) that have foot pedals, flight stick, buttons on a large control panel, so forth, completely loaded out, designed to be used in the Microsoft Flight Simulator's, so yes, they do exist.
Logged

kojack

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 8
    • View Profile
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #12 on: January 20, 2007, 01:41:07 AM »

I've just checked the latest cvs head. The exception still occurs. It happens on the first set property call (DIPROP_APPDATA), not the second call (DIPROP_RANGE) which is the one that was fixed.

Of course I'm guessing the range would fail too, I've just never had it get that far.

I'm thinking the axis number might need to be decremented on failure. Currently, it increments before the axis fails. If the axis which causes problems isn't the last one, there might be a gap in the numbers. Or maybe that's ok, since the axis will still be counted, it's just not set up. I'm not sure.


On the positive side, I just tested the XBox 360 controller (using the xbcd drivers) I bought yesterday, and it works perfectly. Except the middle button of course, which directinput can't see anyway.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #13 on: January 20, 2007, 09:50:22 AM »

Oh, damn, didn't think it was failing in both places. And, good point about decreasing counter on failuer. I'll fix those.

As for the 360 controller, plans are to create a different joystick class for that using XInput. I do not, however, have a 360 controller yet. Nor do I hvae the time at the moment. But, it is part of the goals of 1.1.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Exception being thrown in DIEnumDeviceObjectsCallback
« Reply #14 on: January 20, 2007, 09:54:42 AM »

Quote from: "OvermindDL1"
I've seen some flight sim setups (costing over a thousand dollars) that have foot pedals, flight stick, buttons on a large control panel, so forth, completely loaded out, designed to be used in the Microsoft Flight Simulator's, so yes, they do exist.


Yeah, your probably right. I didn't realize that the joystick structure I was using supported 128 buttons. Hmm, I'll look into changing that (I don't think Linux handles that many, but I could be wrong there). It requires a little changing of the JoyStick class, so I won't be adding it to the 1.0 branch.
Logged
Pages: [1] 2