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)

arkos

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 14
    • View Profile
Multiple Joystick Support Please Help
« on: September 16, 2006, 09:30:52 AM »

Hey guys,

Sorry for the NOOB questions,

I am making a game with Ogre and I want it to have 4 way multiplayer. Does OIS support multiple game pads?

How would one go about making multiple game pads in the application. I am guessing each one would have its own framelistener. Any suggestions would be useful.

Also I have read that OIS supports the Xbox360 controller, but with some lag, is this still the case?
Logged

pjcast

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

OIS still does not use XInput for the 360 controller, patches are welsome :)

Using multiple joysticks is very easy. First, you can determine how many joys are connected by querying the Inputmanager, then create joysticks up to that number (anything over that number - or any other error will throw an exception).

As for use. It is the same as using one joystick, use listeners or query the state directly. Your Actor class could be the listener, or however you have your engine setup.
Logged

arkos

  • Newbie
  • *
  • Karma: +0/-0
  • Posts: 14
    • View Profile
Multiple Joystick Support Please Help
« Reply #2 on: September 16, 2006, 10:19:35 AM »

thanks for the lightning fast reply,

It has taken me a few hours to get basic OIS functions into my app, but I think this system is going to workout great. I was amazed when I plugged in my Thrustmaster controller and the buttons worked alright.

I am puzzled though because the Xbox360 controller didn't seem to register all of its buttons. Ex: when I called

Code: [Select]
buttonPressed( const OIS::JoyStickEvent &arg, int button )
{
  exit(0);
}


the program would only exit when I hit the top shoulder keys. I know that you said OIS doesn't use XInput, but I thought the controller would still work properly (just with some lag). Am I mistaken?

Also, with the joysticks, I have my application be its own frame listener. Then I added it as the framelistener for both joysticks. Is this how I would go about it, or would I have to make a framelistener for each controller?
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Multiple Joystick Support Please Help
« Reply #3 on: September 16, 2006, 10:27:58 AM »

There are a couple joystick button issues fixed in latest cvs (in both cvs head, and cvs v0-7 branch) - and these fixes are not in any file releases. I do not plan to offer anymore 0.7.x releases. As, I plan to release 1.0 pretty soon. I suggest you update to cvs head of OIS. The major changes (besides many bugfixes) include removal of the singleton nature of OIS (just keep track of the manager you create), and no more axis pairs (or sticks for joysticks). For mouse, it is simply: mouseState.X.rel or abs, mouseState.Y.rel or abs, etc instead of mouseState.absX, absY, etc. And, joystick state no longer has the stick enum. It is just one large list of axes, which you can do what you want which each axis.

Quote
Also, with the joysticks, I have my application be its own frame listener. Then I added it as the framelistener for both joysticks. Is this how I would go about it, or would I have to make a framelistener for each controller?

You could have one master framelistener for all devices. And, you would probably be best to use the address of the joystick state class to differentiate them, as the jid member of joystick is not currently used.

However, i suggest one listener class instance per device.
Logged

arkos

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

thanks for your help pjcast,

I will make one instance of a framelistener for each device.

I don't know how to do all of the cvs stuff really, but I guess I could look into it. Do I need to know anything special for compiling from cvs?

alright, you have been more than helpful, I'll leave you alone for a while  :D
Logged

pjcast

  • Administrator
  • Veteran
  • *****
  • Karma: +1/-0
  • Posts: 2661
    • View Profile
    • http://www.wreckedgames.com
Multiple Joystick Support Please Help
« Reply #5 on: September 16, 2006, 11:22:25 AM »

np :)

For cvs, tortoise cvs is a really good client. All you need to compile OIS from cvs is to have DirectX SDk.
Logged

arkos

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

alright, last comment, I swear.

I have absolutely no idea how to obtain the latest OIS through your cvs. I searched the forum, the download section, your main page, and I couldn't find any references to downloading the files from cvs. If you could just point me to your instructions page I would really appreciate it.

Also, you mentioned that you are moving away from the singleton pointers. So I am assuming that http://www.ogre3d.org/wiki/index.php/Using_OIS
(which I know that you don't support) will not work with what I download from cvs. Is this correct?
Logged

pjcast

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

Instructions are here: http://sourceforge.net/cvs/?group_id=149835
Replace module name with "ois". That will give you cvs head (1.0).

Yeah, the code on the ogre wiki will need to change. All you have to remeber, is to store the manager you create.
Logged

arkos

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

I lied  :( ,

I couldn't get the cvs to find the module. What am I doing wrong?

zektor% cvs -d:pserver:anonymous@wgois.cvs.sourceforge.net:/cvsroot/wgois login
Logging in to :pserver:anonymous@wgois.cvs.sourceforge.net:2401/cvsroot/wgois
CVS password:
zektor% cvs -z3 -d:pserver:anonymous@wgois.cvs.sourceforge.net:/cvsroot/wgois co -P ios
cvs server: cannot find module `ios' - ignored
cvs [checkout aborted]: cannot expand modules
zektor%

If it matters, I am logging in using SSH command shell.
Logged

pjcast

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

You missspelled it :) ios should be ois
Logged

arkos

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

Hey pjcast,

that was stupid of me. I downloaded the files, but of course I am having more problems.

I am using visual studio 8.0 and was able to get the OIS project to compile. I don't think that I am using the same hierarchy as you so I had to change some linker directories. After compiling just the OIS project, it output OIS_static.lib into ois\lib.

Unfortunately the other projects will not run because
Code: [Select]

Linking...
LINK : fatal error LNK1181: cannot open input file 'ois_static.lib'
Build log was saved at "file://f:\Program Files\OgreSDK VC 2005\ois\Win32\CommandLine\Release\BuildLog.htm"
Demo_Console - 1 error(s), 0 warning(s)
------ Build started: Project: Demo_FFTest, Configuration: Release Win32 ------
Linking...
LINK : fatal error LNK1181: cannot open input file 'ois_.lib'
Build log was saved at "file://f:\Program Files\OgreSDK VC 2005\ois\Win32\DemoFFTest\Release\BuildLog.htm"
Demo_FFTest - 1 error(s), 0 warning(s)
========== Build: 0 succeeded, 2 failed, 1 up-to-date, 0 skipped ==========


I have changed their linker directories to lookinto the directorie where the OIS project output its library so the Demo_Console should atleast work, but the damn compiler doesn't want to find it. Note I am positive that the linker directory is correct because when I typed ..\lib\ intellisense told me that the other folders in lib were CVS and obj. This means that OIS_static.lib is in there. Did you run into any problems like this or do you know what to do?


What is the difference between OIS_static.lib and OIS.lib?

Also, why is one of the projects in the solution dependent on OIS_static.lib while the other is dependent on just OIS.lib?

I tried changing the Configuration Properties of the OIS project to dynamic library instead of static, but it gave me all sorts of errors.

And how do I get just OIS.lib?
thanks  :wink:
Logged

pjcast

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

You should not have to adjust any paths. What I suggest you do, is revert to the old project files you got from cvs (a simple: cvs update -C). Then, when you build, use the batch build -> select all -> rebuild all. OIS builds both static and dynamic (dll) libs.
Logged

arkos

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

alright... :(

I grabbed the files again. Opened up the VS 2003 solution. I go to Build->BatchBuild, select all, build. Everything compiles and links. And the command line demo works great! The xbox controller works with all of the joysticks which is awesome.

What sucks is that when I try to get the VS 2005 solution going (my app is built in 2005), I run into all sorts of problems. For starters ois_vc8.sln shows up as an "unrecognized version". When I open it in VS 2005 File->open->Solution/Project, the projects show up on the right. When I do Build->BatchBuild, select all, build, then nothing happens.And there is all this x64 crap that doesn't appear in the VS 2003 version of batch build.

So that wasn't working so I close VS 2005 and open it again. Then I do file->open->solution/project, only this time I click on the VS 2003 solution. It asks me if I want to convert it and I click yes. The projects come up and I do a batch build (this time there are no x64 references). Everything seems to be going fine, when the compiler tells me it is missing dinput.h. To fix this I go to my direct x sdk folder and grab dinput.h out of the include folder and place it in the Includes folder for ois. This gets rid of that error, then a link error comes up saying it can't find dinput8.lib and dxguid.lib, so I go back into the directx sdk, grab those libraries and put them in the ois Win32 folder with the solution and projects.

I go and do a batch build. And this time success!!! But my joy is quickly crushed as I run the newly made command line demo and the xbox controller crashes the program if ANYTHING is touched. My other controller crashes the program when I touch the dpad, but the other buttons register.

I don't know what the heck is going on, but I started working on this at 12pm and it is now 9:30pm which really sucks  :( . I reinstalled the DirectX SDK in the hopes that it links with VS 2005 somehow, but got the same results. I find it weird that VS 2003 was able to find dinput.h and the libraries, but VS 2005 was not.

If you have any ideas on how I can fix this, I am begging you to let me know. Please help!!!!  :cry:  :cry:  :cry:
Logged

pjcast

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

You are probably having a line endings problem. If you used something like cygwin to checkout the files from cvs, you will have Linux line returns, wheras windows expects CRLF line endings. There is a utility called unix2dos and dos2unix in linux (probably cygwin too) to convert files between both. Cvs automatically does, though, under cygwin - it treats it as linux.

Or, open the project files in wordpad, save. Then try to open in VS ;)
Logged

arkos

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

okay, I tried that (opened the solution and projects for VS 8 ), and the Visual Studio 2005 solution now does NOT come up as an unrecognized version. It shows that it is associated with Version 8. When I open it and go to batch build all of that x64 crap shows up besides the win32 stuff and the program will not let me build until I uncheck all of the x64 ones. Once I do build, I get the same problems as mentioned above (can't find dinput.h and can't find the two libs).

Do you know why the 2003 version would be able to find the libs and .h file but 2005 wouldn't?

Do I need to link directx sdk somehow with VS 2005?

Do you think that this would be a problem with my computer and VS 2005 or do you think there is something wrong with the solution file?

What the heck is with the x64 stuff?

Is it possible for you to just send me the .lib and .dll generated from vs 2005? because I feel like I am getting nowhere fast, or rather I am getting nowhere extremely slowly  :)

thanks
Logged
Pages: [1] 2