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: Multiple Joystick Support Please Help  (Read 4502 times)

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Multiple Joystick Support Please Help
« Reply #15 on: September 16, 2006, 06:28:26 PM »

I think it would be best for you to get through this yourself, if I sent you the files, it would only be a work inprogress release, and i don't want to keep track of those things atm :)

You have to add the DirectX include & lib directory to your IDE. In tools -> options -> vc projects & files -> directories (IIRC), add the locations. Also, since you seem to be using Visual Express, make sure you have installed the platform SDK. As for the 64 bit stuff, yup, just uncheck it. - express can't handle that ;)
Logged

arkos

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 14
    • View Profile
Multiple Joystick Support Please Help
« Reply #16 on: September 16, 2006, 08:11:37 PM »

thanks for the reply,

I did what you said for the directx sdk. Then I started fresh again. This time compiling went smooth right out of the box. However when I tried running the command line demo, again the buttons on the crappy controller worked, while its d-pad and all the buttons on the xbox controller caused a crash to occur.

I deleted the Platform SDK that I had on my machine and downloaded the newest one. Then I went into VS 2005 and under the tools->options project directories, I added the three folder paths (just as I did for dx). Again the app compiled fine and again the command line demo crashes like crazy.

Just to reiterate, compiling with vs 2003, both controllers worked fine.
Here are the warnings I got during compile time (minus conversion warnings), that may help.

VS 2003 (which works fine)
Code: [Select]
OIS warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/OPT:ICF' specification


VS 2005 (compiles but crashes a lot)
Code: [Select]
Warning 6 warning LNK4221: no public symbols found; archive member will be inaccessible OISJoyStick.obj


The 2005 warning appears twice and seems ominous, but I can't say for sure. Do you have any idea if this is troublesome and what causes this?

I don't think it matters that much but when I run the debug exe and press a button on the xbox360 controller I get the Debug Assertion Failed message. It looks like this:

Code: [Select]

Program: ...
File: f:\program files\microsoft visual studio 8\vc\include\vector
Line: 756

Expression: vector subscript out of range


This is a stupid question, pjcast, but are you sure that when you compile the command line demo with your 2005 solution, everything works exactly as it does with the 2003 build?

thanks

p.s. here is a link to the folder which contains the buggy executables that I produced with vs 2005. I think with this one I opened vs 8 and converted the vs 7 solution. This gets rid of the x64 stuff and still yeilds the same crashes

http://www-personal.umich.edu/~howery/ois.zip
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Multiple Joystick Support Please Help
« Reply #17 on: September 17, 2006, 09:34:42 AM »

Don't worry about either of those warnings.

As for the vector subscript out of range, you will have to debug in that method to find the cause. I don't have a 360 Controller to test against.
Logged

arkos

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 14
    • View Profile
Multiple Joystick Support Please Help
« Reply #18 on: September 17, 2006, 02:45:14 PM »

at this point I'm pretty frustrated  :?

I have been looking through your code for a few hours now, and I'm having a hard time figuring out what is gong on, much less finding how to fix the problem.

The functions in Win32JoyStick.cpp don't seem to do anything (I put exit statements in few functions and they are never called).

Lets forget about the Xbox360 controller for the time being. Lets focus on my generic gamepad with a dpad, 4 face btns, and 4 shoulder btns.

Since the vs03 works, I messed around with things in there. I have found out that all the btns work and when I hit left and right I get
Code: [Select]
Joy Axis #: 1 Value: -32767 or 32767

When I hit up and down
Code: [Select]
Joy Axis #: 2 Value: -32767 or 32767

Moving on to vs05, again all of the buttons work and when I hit left and right I get the same results as vs2003, but when I hit up and down the program crashes.

After debugging I have found that when I hit up/down, the program never gets to axisMoved in EventHandler like it does when I hit left and right. Because EventHandler inherits from JoyStickListener I look in there and find
Code: [Select]
virtual bool axisMoved( const JoyStickEvent &arg, int axis ) = 0;
which I don't know what to make of. Also, where the heck is that dang capture function. It is called but where is the code that runs it? I have no idea what calls axisMoved.

Frankly, after two straight days of trying to get just the OIS demo to work properly for vs 2005 and not even getting started on integrating it into my project, I am getting tired of messing around with this.

I could possibly go out and buy the controllers that have been reported to work. Regular XBox(tm) Controller or the Microsoft Sidewinder Freestyle Pro. But I don't know if they are going to work anybetter because if the two different compiled exe's vs03 and vs05 act differently, then all bets are pretty much off.

I could revert back to OIS .7.2 in which case I can't use the Xbox360 controller which bites.

I have a very short development deadline for this project (I basically wasted two days for something that I thought would take an hour, granted some of that time was caused by my own stupidity). What do you think I should do?

Ideally I would like to use the 360 controller with the newest cvs head.

thank you very much for all of your help so far.
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Multiple Joystick Support Please Help
« Reply #19 on: September 17, 2006, 02:56:38 PM »

Integrating a library is never easy. Nor is it a waste of time. How long would it take you to write a DirectInput or XInput wrapper? Not so long I imagine. But, to test it, let alone make it multiplatform, months.

As for differences between 2005 and 2003, it has nothing to do with OIS. It works the same regardless of compiler. My guess, is that you are not fully doing a clean build between building with 2003 and building with 2005. And, are having missed matched object files - causing odd problems. I in fact use VC8 primarily nowadays, and can attest to OIS working flawlessly under it.

I don't really have any suggestions. Except, you say that you put exit statements in the code and it has no effect. That means that the code is indeed not getting called (probably missed matched libs/source/dll's).

I suggest you just use the v0-7 branch and avoid the 360 controller.
Logged

arkos

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 14
    • View Profile
Multiple Joystick Support Please Help
« Reply #20 on: September 17, 2006, 04:32:13 PM »

Ok, I grabbed the source from the cvs again and this time I opened the vs8 solution in wordpad, saved it, then opened it in vs (like I had previous times). Then I removed all of the source code files and header files. Then I added then back manually. After compiling I still got the same crap, but this time, when I put exit statements in Win32JoyStick.cpp, they actually worked!

I was able to track down the problem to this section of code in Win32JoyStick.cpp in capture

Code: [Select]

//First check to see if entry is a Axis as enumerated earlier:
std::map<int, int>::iterator it = mAxisMapping.find( diBuff[i].dwOfs );
if(it != mAxisMapping.end() )
{
            int axis = it->second;
// quarantine /////////////////////////////////////////////////////
            mState.mAxes[axis].abs = diBuff[i].dwData; // Out of bounds
// quarantine ////////////////////////////////////////////////////
            axisMoved[axis] = true;
}


This is what was causing the vector subscript bound problem. I tracked down where mAxisMapping was getting its value from:

Code: [Select]
_this->mAxisMapping[lpddoi->dwOfs] = ++_this->_AxisNumber;

It was in DIEnumDeviceObjectsCallback. It looks like the axis number is being enumerated prematurely so I changed it to:

Code: [Select]
_this->mAxisMapping[lpddoi->dwOfs] = _this->_AxisNumber++;

and the crashes went away!!!!!!!!!!!!!!!!!!

Since I know practically nothing about OIS, since I haven't gotten past the demos, I don't know if this is a good fix, or if this will cause problems later on.

PJcast, it has been a long two days and you have been very generous in both helping me and writing this project. It would take a great weight off my chest if you would please tell me that my fix won't break anything and I am ok to forge ahead.

Awaiting your reply,  :|
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Multiple Joystick Support Please Help
« Reply #21 on: September 17, 2006, 04:42:12 PM »

Yes, probably should be post increment there :) I'll change it in cvs.

Thanks for your efforts and time sticking with it. I know how difficult using other peoples code can be ;)
Logged

arkos

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 14
    • View Profile
Multiple Joystick Support Please Help
« Reply #22 on: September 17, 2006, 04:59:37 PM »

:D ha ha, SUCCESS!!!!!  :D

Hours upon hours of frustration all for one line one code; well, that's life I guess. I am just happy that we were able to fix this.

thanks again for all of your help, and it might be a tad premature (haven't done testing), but you can now say that OIS supports the Xbox360 controller which is a big plus!!!!!

Good luck in future developments with OIS and the job hunting!
Logged
Pages: 1 [2]